Skip to content

Instantly share code, notes, and snippets.

View anthonyraf's full-sized avatar

Anthony Rafidison anthonyraf

View GitHub Profile
@anthonyraf
anthonyraf / socket_portable.c
Created May 14, 2022 15:51 — forked from FedericoPonzi/socket_portable.c
C sockets portable in windows/linux example
// As seen on http://www.di.uniba.it/~reti/LabProRete/Interazione(TCP)Client-Server_Portabile.pdf
#if defined WIN32
#include <winsock.h>
#else
#define closesocket close
#include <sys/socket.h>
#include <arpa/inet.h>
#include <unistd.h>
#endif
#include <stdio.h>
@anthonyraf
anthonyraf / Socket-C++.md
Created May 15, 2022 14:48 — forked from stefan-wolfsheimer/Socket-C++.md
Socket programming pattern C++

Makefile

CPP=g++ -std=c++14

all:server client
	echo "ok"

server: server.cpp config.h socket.o 
	${CPP} server.cpp socket.o -o server
@anthonyraf
anthonyraf / overwrite_repr_str.py
Created January 22, 2023 14:30
Overwrite python function __repr__ and __str__
class CustomFunction:
def __init__(self, func):
self.func = func
def __call__(self, *args, **kwargs):
return self.func(*args, **kwargs)
def __str__(self):
return "A custom function"