Skip to content

Instantly share code, notes, and snippets.

0 / cube.c
Created July 17, 2011 01:06
/* gcc -o cube cube.c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/select.h>
#include <termios.h>
#include <unistd.h>
0 /
Last active January 12, 2019 05:54
Rating Count Histogram Notes
32 Unbearable.
★★ 136 ██████ Drinkable.
★★★ 128 ██████ Beer.
★★★★ 190 █████████ Really enjoyable. (Or tastes like an IPA.)
★★★★★ 69 ███ Amazing!
Brewery-ish/Brand-ish Beer Rating
0 / a_problem.txt
Created November 28, 2012 05:41
Solution generator for the median-of-five problem
"Describe an algorithm that consumes five distinct comparable objects and
produces the median of these objects using a total of at most six comparisons."
Because creative thinking is hard, we use a simpler approach and try to compute
a suitable program recursively. Programs are represented by a tree of
comparisons at the internal nodes and resulting indices at the leaves.
The following code has been tested with Python 2.6.8, 2.7.3, and 3.3.0.
0 / cols.txt
Created April 30, 2013 01:41
Brief awk tutorial
abc 1 2 3
def 4 5 6
ga 7 9 10
hij 1 5 99
0 / arrays_pointers.c
Created December 20, 2013 20:50
Arrays aren't pointers!
/* gcc -std=c99 -pedantic -Wall -Wextra -Werror -o arrays_pointers arrays_pointers.c
#include <stdio.h>
#include <string.h>
#define A_LEN 5
void foo(int a[], int *p);
0 /
Last active August 29, 2015 14:03
Scheme RC4 implementation

For some reason, in January of 2009 I felt the need to implement RC4 in Scheme.


Known to work with Racket.

Specify the key and plaintext on the command-line as arguments, and it will output the ciphertext. For example,

0 /
Created July 20, 2014 05:12
x86 shellcode

x86 shellcode

Back in 2010, I needed some shellcode, so I wrote this. It spawns Vim rather than a shell, so I guess it's technically "vimcode".

It is, of course, null-free. There is a commented version in the test file, but here it is in its entirety:

0 / aif.jl
Last active November 27, 2019 17:24
Some toys in julialang
# Anaphoric if.
macro aif(ex)
@assert (ex.head == :if) "@aif must be applied to an if expression."
cond = ex.args[1]
ex.args[1] = :(convert(Bool, it))
let it = $cond
0 /
Created January 28, 2015 04:22
Calculate complex square roots with the correct sign for trajectories in the complex plane.
#!/usr/bin/env python3
Calculate complex square roots with the correct sign for trajectories in the
complex plane.
Taking the square root of values along a continuous trajectory in the complex
plane is not as simple as calling a sqrt function, because the complex square
root is a multi-valued function whose Riemann surface is composed of two
sheets. If the trajectory crosses the branch cut (conventionally placed along
0 /
Last active August 18, 2023 10:36
Building a GCC cross-compiler for the MSP430.


The following are instructions for building a GCC cross-compiler for the MSP430. They are based in part on Peter Bigot's post to mspgcc-users.


export PREFIX=/usr/local/msp430