Skip to content

Instantly share code, notes, and snippets.

@jbulow
jbulow / avl.ml
Created January 19, 2017 07:39 — forked from matthieubulte/avl.ml
(* Good morning everyone, I'm currently learning ocaml for one of my CS class and needed to implement
an avl tree using ocaml. I thought that it would be interesting to go a step further and try
to verify the balance property of the avl tree using the type system. Here's the resulting code
annotated for people new to the ideas of type level programming :)
*)
(* the property we are going to try to verify is that at each node of our tree, the height difference between
the left and the right sub-trees is at most of 1. *)
@jbulow
jbulow / mapread.c
Created October 13, 2016 19:54 — forked from marcetcheverry/mapread.c
mmap and read/write string to file
#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/mman.h>
#include <unistd.h>
int main(int argc, const char *argv[])
{
@jbulow
jbulow / xhyve-freebsd-tutorial-1.md
Created March 31, 2016 06:11 — forked from tanb/xhyve-freebsd-tutorial-1.md
FreeBSD running on xhyve tutorial. (Appendix: Resize image with qemu. Create FreeBSD VM with qemu).

TL;DR

  • Create 5GB FreeBSD image.
  • Install FreeBSD on xhyve.
  • Mount host directory.

Requisites

@jbulow
jbulow / recon.ml
Created January 4, 2016 11:21 — forked from kseo/recon.ml
A Hindley-Milner type inference implementation in OCaml
open Core.Std
type term =
| Ident of string
| Lambda of string * term
| Apply of term * term
| Let of string * term * term
| LetRec of string * term * term
let rec term_to_string = function
@jbulow
jbulow / Makefile
Created December 7, 2015 12:20 — forked from khayrov/Makefile
stock quote parsing with Ragel
CFLAGS=-O2
CXXFLAGS=-O2
all: parser
parser.cpp: parser.rl
ragel -G2 $^ -o $@
parser.o: parser.cpp RawQuote.h
@jbulow
jbulow / isip.rl
Created December 7, 2015 12:20 — forked from jlyo/isip.rl
Ragel IPv4/6 address validator
#include <stdbool.h>
#include <string.h>
#include <stdlib.h>
#include <sys/socket.h>
#include <netdb.h>
%%{
machine isip;
octet4 = [0-9]{1,2}
@jbulow
jbulow / Makefile
Created December 7, 2015 12:19 — forked from willglynn/Makefile
Ragel for classifying log lines
line_classifier: line_classifier.o
%.c: %.rl
ragel -G2 $^ -o $@
@jbulow
jbulow / crypto-wrong-answers.md
Created November 18, 2015 10:36 — forked from paragonie-scott/crypto-wrong-answers.md
An Open Letter to Developers Everywhere (About Cryptography)
@jbulow
jbulow / build-emacs.sh
Created November 4, 2015 09:24 — forked from favadi/build-emacs.sh
Compile latest emacs version (24.5) in Ubuntu 14.04
#!/bin/bash
# Build latest version of Emacs, version management with stow
# OS: Ubuntu 14.04 LTS
# version: 24.5
# Toolkit: lucid
set -e
readonly version="24.5"
@jbulow
jbulow / blocks.cc
Last active August 29, 2015 14:20 — forked from xlz/blocks.cc
// g++ -std=c++11 -O3 blocks.cc -o blocks
#include <iostream>
#include <vector>
#include <bitset>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cstdint>
#include <sstream>
#include <string>