Skip to content

Instantly share code, notes, and snippets.

@jaysoffian
jaysoffian / gist:7bb70e1065f085b46a00
Created April 26, 2011 18:15
network calculator in awk
netfn () {
echo "$1" |
awk 'function nto32b(n){ # converts an integer to a 32-bit ascii bitstring
b=""
while (n>1) {
if (n%2) {b="1"b} else {b="0"b}
n=int(n/2)
}
b="1"b
return sprintf("%032s",b)
commit 573d8d2631 (HEAD, master)
Author: Jay Soffian <jaysoffian@gmail.com>
Date: Fri Sep 23 01:26:04 2011 -0400
diff_tree: honor in-tree .gitattributes when used in a bare repo
diff --git a/tree-diff.c b/tree-diff.c
index b3cc2e4753..6fd84eb2bb 100644
--- a/tree-diff.c
+++ b/tree-diff.c
@jaysoffian
jaysoffian / tmproj
Created December 13, 2011 17:52
tmproj
#!/bin/bash
name=$(git rev-parse --abbrev-ref=strict HEAD | sed 's|/|-|g')
test "$name" = "HEAD" && name=$(git rev-parse --short $name)
OUT=${name}.tmproj
OUT2="${name}(2).tmproj"
exec > "$OUT"
cat <<'__EOF__'
#!/usr/bin/python
import sys
import re
def extract_names(path):
year = None
ranks = {}
def add_rank(name, rank):
# add name to ranks if its not already present or if its smaller
if name not in ranks or rank < ranks[name]:
@jaysoffian
jaysoffian / remerge
Created May 6, 2012 13:06
A script for rebasing a merge
#!/bin/sh -x
# remerge <onto> [<merge_commit>]
# e.g.: remerge origin/trunk
# merge_commit defaults to HEAD
onto=$1
mc=${2:-HEAD}
mc_sha=$(git rev-parse $mc) # original merge commit
p1_sha=$(git rev-parse $onto) # what we want its new first parent to be
package net.hockeyapp.android.demo;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import org.acra.ACRA;
import org.acra.collector.CrashReportData;
import org.acra.ReportField;
@jaysoffian
jaysoffian / objc_tokenizer.py
Last active December 16, 2015 03:18
Quick and dirty Objective-C tokenizer in Python
import re
from collections import deque, namedtuple
# Tokenize per the C preprocessor, more or less...
TOKENIZER = re.compile(r'''
(?P<WHITESPACE>\s+) |
(?P<COMMENT>(?://[^\n]* | /\*.*?\*/)) |
(?P<PREP>\#\s*[a-z][^\n]*) |
(?P<OBJC>@[a-z]+) |
(?P<NUMBER>(?:\.?\d(?:[eEpP][+-]|[a-zA-Z0-9_.])*)) |
@jaysoffian
jaysoffian / bq_info.md
Last active August 29, 2015 14:06
Boston Marathon Qualifiers

Overall Numbers

Year Field Size BQs Accepted BQs Denied Offset Note
2011 27,000 ~ 21,600 ? N/A Sold out in 8 hours.
2012 27,000 20,358 3,228 -1:14 New registration process.
2013 27,000 ~ 21,600 None 0 New BQ standards (-5 mins).
2014 36,000 24,730 2,976 -1:38 Boston Strong.
2015 30,000 TBD TBD TBD
@jaysoffian
jaysoffian / redis_leaky_bucket.py
Created February 11, 2016 04:09 — forked from jdunck/redis_leaky_bucket.py
leaky bucket queue - redis 2.6 + lua + python
#cribbed from http://vimeo.com/52569901 (Twilio carrier call origination moderation)
# The idea is that many fan-in queues can enqueue at any rate, but
# dequeue needs to happen in a rate-controlled manner without allowing
# any individual input queue to starve other queues.
# http://en.wikipedia.org/wiki/Leaky_bucket (second sense, "This version is referred to here as the leaky bucket as a queue.")
#
# requires:
# redis 2.6+
# redis-py>=2.7.0
# anyjson
--- dyld-210.2.3/launch-cache/dsc_extractor.cpp 2012-05-21 02:35:15.000000000 -0400
+++ dyld-210.2.3/launch-cache/dsc_extractor.cpp 2013-07-26 16:05:03.000000000 -0400
@@ -37,6 +37,7 @@
#include <mach-o/arch.h>
#include <mach-o/loader.h>
#include <Availability.h>
+#include <dlfcn.h>
#define NO_ULEB
#include "Architectures.hpp"