View tag.h
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> // uint64_t | |
#define TSH(a,b) ((uint64_t)(a) << (b * 8)) | |
#define TAG_1(a) (TSH(a,0)) | |
#define TAG_2(b,a) (TSH(b,1)|TSH(a,0)) | |
#define TAG_3(c,b,a) (TSH(c,2)|TSH(b,1)|TSH(a,0)) | |
#define TAG_4(d,c,b,a) (TSH(d,3)|TSH(c,2)|TSH(b,1)|TSH(a,0)) | |
#define TAG_5(e,d,c,b,a) (TSH(e,4)|TSH(d,3)|TSH(c,2)|TSH(b,1)|TSH(a,0)) | |
#define TAG_6(f,e,d,c,b,a) (TSH(f,5)|TSH(e,4)|TSH(d,3)|TSH(c,2)|TSH(b,1)|TSH(a,0)) |
View inso_json.h
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
#define _GNU_SOURCE | |
#include <stdint.h> | |
#include <stdbool.h> | |
#include <string.h> | |
#include <assert.h> | |
// streaming json tokenizer that operates on fixed sized memory chunks | |
// no dynamic memory allocation necessary | |
enum ij_type { |
View asmsort.s
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/bash | |
# example: ./asmsort 3 2 1 -> prints 1 2 3 | |
// 2>/dev/null; as -g $0 -o $0.o && ld -s $0.o -o asmsort; exit | |
.text | |
.global _start | |
quicksort: | |
dec %rsi # base case | |
jle qs_end |
View quicksort.s
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/bash | |
# (gdb) r | |
# -> SIGTRAP | |
# (gdb) x/12g $rax | |
# -> stuff is sorted | |
// 2>/dev/null; as -g $0 -o $0.o && ld $0.o -o $0.bin && gdb $0.bin; exit | |
.data | |
stuff: # numbers to sort | |
.quad 74, 3, 53, 11, 52, 94, 16, 12, 48, 88, 19, 82 |
View freetype-atlas.c
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 STB_IMAGE_WRITE_IMPLEMENTATION | |
#include "stb_image_write.h" | |
#include <ft2build.h> | |
#include FT_FREETYPE_H | |
#define NUM_GLYPHS 128 | |
struct glyph_info { | |
int x0, y0, x1, y1; // coords of glyph in the texture atlas |
View xkeyexample.c
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 <locale.h> | |
#include <X11/Xlib.h> | |
#include <X11/keysym.h> | |
int main(void){ | |
setlocale(LC_ALL, ""); | |
Display* dpy = XOpenDisplay(NULL); |
View script.txt
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
title Lawn-Mowing Robot | |
author Alex Baines | |
homepage abaines.me.uk | |
again_interval 0.5 | |
background_color #1B1825 | |
( | |
debug | |
verbose_logging | |
) | |
======== |
View twitch-notify.sh
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/bash | |
# twitch-notify.sh by Alex Baines | |
# Desktop notifications about twitch.tv streams. | |
# dependencies: | |
# curl | |
# underscore-cli | |
# notify-send | |
# md5sum |
View oggextract.cpp
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 <cstdio> | |
#include <cstdlib> | |
#include <numeric> | |
#include <unistd.h> | |
bool test_header(FILE* f, int magic = 2){ | |
bool r = false; | |
char buf[5]; | |
fread(buf, 1, 5, f); | |
View hls-multi-atomic.cpp
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
#if 0 | |
g++ $0 -std=c++11 -pthread -lcurl -o hls-dl | |
exit | |
#endif | |
#include <thread> | |
#include <mutex> | |
#include <algorithm> | |
#include <vector> | |
#include <array> | |
#include <string> |