Skip to content

Instantly share code, notes, and snippets.

@jflatow
jflatow / Qfile
Last active August 29, 2015 14:07
from qb import conf, rule, sh, Job, Reject, AWOL
from datetime import datetime, timedelta
window_re = r'(\d+s)'
type_re = r'(bri|bid)'
date_re = r'(\d{4}-\d{2}-\d{2})'
def timerange(start, stop=None, step=timedelta(days=1)):
while start < stop:
/*
* Primitive benchmarks of buoy vs tree.
* Assuming {buoy,tree}.{c,h} and hash.h, run like:
* cc bench.c buoy.c tree.c -o bench && ./bench 100000 3 10000
*/
#include <stdio.h>
#include <time.h>
#include "buoy.h"
#include "tree.h"

Keybase proof

I hereby claim:

  • I am jflatow on github.
  • I am jared (https://keybase.io/jared) on keybase.
  • I have a public key whose fingerprint is 63C4 36A4 96C5 15D6 DEFA 3816 8431 3A67 1C4F CF21

To claim this, I am signing this object:

<html>
<head>
<title>Disappearing touch events</title>
</head>
<body>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 30 30">
<g id="g">
<rect id="rect" x="10" y="10" width="10" height="10" fill="rgba(255, 0, 0, .5)" />
<circle id="circle" cx="15" cy="15" r="5" fill="rgba(0, 0, 0, .5)" />
</g>
import collections
import json
class GeoName(collections.namedtuple('GeoName',
['country_code',
'postal_code',
'place_name',
'admin_name_1', 'admin_code_1',
'admin_name_2', 'admin_code_2',
'admin_name_3', 'admin_code_3',
#!/usr/bin/env python
"""
Canonize emails (mostly by decoding), to make them extraction-friendly.
"""
import email
import hashlib
import re
import sys
@jflatow
jflatow / gist:974989
Created May 16, 2011 18:15
gitlib2:git_index_free memory leak minimal example
#include <stdio.h>
#include <git2.h>
int
main(int argc, char **argv) {
git_repository *repo;
git_index *index;
int error = git_repository_open(&repo, ".git");
printf("%s\n", error ? git_strerror(error) : "opened repo");
error = git_repository_index(&index, repo);
@jflatow
jflatow / gist:596216
Created September 24, 2010 23:14
quadratic polynomial to quadratic bezier
from math import factorial
def nchoosek(n, k):
return factorial(n) / (factorial(k) * factorial(n - k))
class point(tuple):
def __add__(self, other):
return point(ps + po for ps, po in zip(self, other))
def __mul__(self, scalar):
@jflatow
jflatow / FastaInputFormat.java
Created January 10, 2009 20:15
Hadoop FASTA reader
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0