Skip to content

Instantly share code, notes, and snippets.

@jaysoffian
jaysoffian / kurosawa_top_100.py
Created Mar 23, 2021
Convert Akira Kurosawa's top 100 films to a CSV for import to Letterboxd
View kurosawa_top_100.py
#!/usr/bin/python3
"""
Convert Akira Kurosawa's top 100 films to a CSV for import to Letterboxd.
List extracted from https://www.openculture.com/2015/01/akira-kurosawas-list-of-his-100-favorite-movies.html
"""
LIST = """
1. Broken Blossoms or The Yellow Man and the Girl (Griffith, 1919) USA
View git-gsr
#!/bin/sh
usage () {
cat >&2 <<'__USAGE__'
usage: git gsr [-P | --perl-regexp] <old> <new> [paths...]
replace all occurrances of <old> with <new> optionally limited to
<paths...> (as interpreted by git grep)
-P, --perl-regexp interpret <old> as perl regular expression;
@jaysoffian
jaysoffian / .bashrc
Created Feb 1, 2017
.bashrc for staging/production machines
View .bashrc
# .bashrc
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
# User specific aliases and functions
set_prompt() {
local titlebar red yellow reset
View dsc_extractor.patch
--- 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"
@jaysoffian
jaysoffian / redis_leaky_bucket.py
Created Feb 11, 2016 — forked from jdunck/redis_leaky_bucket.py
leaky bucket queue - redis 2.6 + lua + python
View redis_leaky_bucket.py
#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
@jaysoffian
jaysoffian / bq_info.md
Last active Aug 29, 2015
Boston Marathon Qualifiers
View bq_info.md

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 / objc_tokenizer.py
Last active Dec 16, 2015
Quick and dirty Objective-C tokenizer in Python
View objc_tokenizer.py
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_.])*)) |
View HockeySender.java
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 / remerge
Created May 6, 2012
A script for rebasing a merge
View remerge
#!/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
View babynames.py
#!/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]: