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
# Fowler–Noll–Vo hash function | |
# https://en.wikipedia.org/wiki/Fowler%E2%80%93Noll%E2%80%93Vo_hash_function | |
fnv_prime_32 = 2**24 + 2**8 + 0x93 | |
offset_basis_32 = 0x811c9dc5 | |
def fnv1a_hash_32(bs): | |
r = offset_basis_32 | |
for b in bs: | |
r = r ^ b |
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
# The world's stupidest HTTP server | |
def http_serve_data(data, bind_address, bind_port): | |
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock: | |
sock.bind((bind_address, bind_port)) | |
sock.listen() | |
conn, addr = sock.accept() | |
with conn: | |
conn.recv(1024) # Read and discard request | |
conn.sendall(b'HTTP/1.1 200 OK\r\nContent-Type: application/octet-stream\r\nContent-Length: ' + str(len(data)).encode('ascii') + b'\r\n\r\n') | |
conn.sendall(data) |
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
[user] | |
name = Your Name | |
email = [email protected] | |
[init] | |
defaultBranch = main | |
[pull] | |
ff = only | |
rebase = true | |
autoStash = true | |
[fetch] |
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
objdump -d /usr/bin/* | cut -f3 | grep -oE ^[a-z]+ | sort | uniq -c | sort -nr |
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
#!/bin/sh | |
GCC_O0_OPTS_DISABLED=$(gcc -Q -O0 --help=optimizers | awk -v ORS=" " '($1 ~ /^-f/) && ($2 ~ /enabled/) {print "-fno-" substr($1,3)}') | |
exec gcc -O0 $GCC_O0_OPTS_DISABLED "$@" |
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 <stdlib.h> | |
#include <stdio.h> | |
#include <stdint.h> | |
#include <math.h> | |
#define RGB(r,g,b) (((r) & 0xFF) | (((g) & 0xFF) << 8) | (((b) & 0xFF) << 16)) | |
#define RED(rgb) ((rgb) & 0xFF) | |
#define GRN(rgb) (((rgb) >> 8) & 0xFF) | |
#define BLU(rgb) (((rgb) >> 16) & 0xFF) |
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
#!/bin/sh | |
# | |
# Run C programs for fun! | |
# | |
# Disables all optimizations, enables warnings, debug info and some hardening options. | |
# | |
if [ $# -lt 1 ]; then | |
echo "usage: $0 FILE.c" | |
exit 1 | |
fi |
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> | |
int main(void) | |
{ | |
union { uint8_t bytes[4]; uint32_t value; } x = { .bytes = {0x11, 0x22, 0x33, 0x44} }; | |
switch (x.value) { | |
case 0x11223344: | |
printf("big\n"); | |
return 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 <assert.h> | |
#include <stdint.h> | |
#include <stdio.h> | |
uint32_t umul32(uint32_t a, uint32_t b) | |
{ | |
if (a < b) { | |
uint32_t tmp = a; | |
a = b; | |
b = tmp; |
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> | |
#include <inttypes.h> | |
#include <SDL2/SDL.h> | |
int main() | |
{ | |
SDL_Init(SDL_INIT_VIDEO); | |
SDL_Window *window = SDL_CreateWindow("SDL Test", 0, 0, 320, 240, SDL_WINDOW_SHOWN); | |
SDL_Renderer *renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED); | |
SDL_Texture *texture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STATIC, 8, 8); |