This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bins = single stdio buffered single.exe until.exe stream.exe buffered.exe | |
all: $(bins) | |
run: $(bins) | |
for bin in $^; do echo -n " - $$bin: "; echo "Hello World !\nNooo\nKO" | strace -e read ./$$bin 2>&1 >/dev/null | grep read | wc -l ; done | |
clean: | |
$(RM) $(bins) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
import json | |
import socket | |
import time | |
def is_json_complete(message: str) -> bool: | |
level = 0 | |
for c in message: | |
level += {'{': 1, '}': -1}.get(c, 0) | |
if level < 0: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdint.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <time.h> | |
#include <unistd.h> | |
#include <linux/ptp_clock.h> | |
struct external_timestamp | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#define C_ARRAY_LENGTH(A) (sizeof(A) / sizeof(*(A))) | |
void print_memory(const void* addr, size_t size); | |
const char config[][8] = { | |
"Hello", | |
"Salut", | |
"Hola", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <inttypes.h> | |
#include <stdbool.h> | |
#include <stdio.h> | |
#define EPOLLIN 1 | |
#define EPOLLOUT 4 | |
struct simple | |
{ | |
bool read; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from random import choice | |
import sys | |
EOC = "\033[0m" | |
BOLD = "\033[1m" | |
RED = "\033[31m" | |
GREEN = "\033[32m" | |
YELLOW = "\033[33m" | |
BLUE = "\033[34m" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Point: | |
def __init__(self, x, y): self.x, self.y = x, y | |
def taxi_distance(self, other): return abs(self.x - other[0]) + abs(self.y - other[1]) | |
def distance(self, other): return math.sqrt((self.x - other[0]) ** 2 + (self.y - other[1]) ** 2) | |
def module(self): return self.distance((0, 0)) | |
def __add__(self, other): return Point(self.x + other[0], self.y + other[1]) | |
def __radd__(self, other): return self + other | |
def __sub__(self, other): return Point(self.x - other[0], self.y - other[1]) | |
def __neg__(self): return Point(-self.x, -self.y) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Possible names of this ordering rule : | |
# * Madelung rule (after Erwin Madelung) | |
# * Janet rule (after Charles Janet) | |
# * Klechkowsky rule (after Vsevolod Klechkovsky) | |
# * aufbau approximation | |
# * Uncle Wiggly path or | |
# * diagonal rule | |
def aufbau(): | |
i = 0 | |
while True: |