Skip to content

Instantly share code, notes, and snippets.

View alekxeyuk's full-sized avatar
⚒️
Workers of the world, unite!

LeLuCh B0й alekxeyuk

⚒️
Workers of the world, unite!
  • Tanelorn
  • United Russian Kingdom
View GitHub Profile

Below is a step‑by‑step, ordered list of the POSIX functions you normally call when you work with a Unix‑domain (AF_LOCAL / AF_UNIX) stream socket (SOCK_STREAM).
I split the list into two sections – one for the server side and one for the client side – because the order of calls differs slightly.


1️⃣ Server side (creates a listening socket)

# Function (header) What it does Typical usage notes
1 socket(int domain, int type, int protocol) #include Creates a new socket descriptor. domain = AF_LOCAL (or AF_UNIX), type = SOCK_STREAM, protocol = 0.
/* parseSudokuBoard()
Reads the live DOM and returns a 9×9 array:
– null for an empty cell
– 1-9 for a filled cell
*/
function parseSudokuBoard() {
const board = Array.from({
length: 9
}, () => Array(9).fill(null));
@alekxeyuk
alekxeyuk / main.cpp
Created April 5, 2024 12:07
bizzarechat
#include <iostream>
#include <unordered_set>
typedef std::unordered_set<int> int_set;
enum AccessLevel : int
{
ADMIN, // Может регистрировать новых пользователей, давать роль админа или модератора другим пользователям, а также полностью останавливать чат
MODERATOR, // Может банить пользователей, создавать других модераторов, а также полностью редактировать все сообщения
BANNED, // Не может ничего, предполагается, что ни ADMIN, ни MODERATOR не станут BANNED
@alekxeyuk
alekxeyuk / list.cpp
Created February 17, 2024 05:53
List struct
#include <iostream>
struct Node {
Node* next;
int value;
};
struct List
{
Node* first;
@alekxeyuk
alekxeyuk / main.cpp
Created January 12, 2024 14:56
std::list with iterator pointing to the middle of the list
#include <iostream>
#include <list>
// std::list with iterator pointing to the middle of the list
int main() {
std::list<int> lst{};
size_t N;
char op;
int i;
@alekxeyuk
alekxeyuk / domino.py
Created September 13, 2021 12:05
Domino game with basic AI
from enum import Enum, auto
from itertools import cycle
from typing import Counter, List, Tuple
import random
class GameState(Enum):
INIT = auto()
RUN = auto()
@alekxeyuk
alekxeyuk / server.py
Last active September 12, 2021 06:43
URL shortener
from http.server import BaseHTTPRequestHandler
from http.server import ThreadingHTTPServer
from typing import Dict
from uuid import uuid4
import json
database: Dict[str, str] = dict()
class HttpGetHandler(BaseHTTPRequestHandler):
def _set_headers(self, status: int = 200, c_type: str = "text/html"):
@alekxeyuk
alekxeyuk / game.py
Last active August 8, 2021 10:23
Hangman game
import random
import string
word_list = ['python', 'java', 'kotlin', 'javascript']
class GameState:
def __init__(self):
self.turns = 8
self.alive = True
package ru.cmtt.osnova.sdk.methods;
import com.facebook.share.internal.ShareConstants;
import com.google.android.gms.actions.SearchIntents;
import com.google.firebase.analytics.FirebaseAnalytics;
import com.google.gson.JsonElement;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.List;
import kotlin.Metadata;