Skip to content

Instantly share code, notes, and snippets.

@haberman
haberman / amalgamate.py
Last active August 29, 2015 14:11
For building a upb amalgamator.
#!/usr/bin/python
import sys
import re
INCLUDE_RE = re.compile('^#include "([^"]*)"$')
def parse_include(line):
match = INCLUDE_RE.match(line)
return match.groups()[0] if match else None
@haberman
haberman / intset.rs
Last active August 29, 2015 14:09
Implementation of an IntSet data structure in Rust.
use std::collections::TreeMap;
use std::collections::tree_map::Entries; // This took forever
use std::num::One;
use std::num::Saturating;
// Equivalent to Set<T>, but only works for Ints, and may be more efficient
// if the set contains large contiguous ranges. Each range is stored as a
// single entry instead of storing each member individually.
struct IntSet<T> {
// These correspond to ranges of high->low. The ranges are closed (inclusive)
@haberman
haberman / HistogramFail
Last active August 29, 2015 14:03
My failed attempt at making a nice histogram with IPython.
{
"metadata": {
"name": "HistogramFail"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{