Skip to content

Instantly share code, notes, and snippets.

@jaysoffian
jaysoffian / gem-venv.sh
Last active October 29, 2023 00:13
Like a Python venv, but for installing Ruby gems
#!/bin/bash
# gem-venv.sh
# ~~~~~~~~~~~
# Summary: Like a Python venv, but for installing Ruby gems.
#
# Create a directory and gem wrapper script for installing gems self-contained
# to that directory. Control which `gem` is used via the `-G/--gem` switch,
# defaulting to whatever `gem` is found in PATH.
#
# Optionally takes a list of gems to install using the just created directory
@jaysoffian
jaysoffian / gem-install.sh
Last active March 29, 2023 23:02
A script to install one or more gems in a self-contained directory, similar to installing Python packages in a virtual environment
Replaced by gem-venv.sh.
Please see https://gist.github.com/jaysoffian/3c67711d3f00c364365905d877cc4af4 instead.
@jaysoffian
jaysoffian / git-lost-and-found
Last active July 15, 2022 21:30
"git lost-and-found" command to help recover objects you added but failed to commit and then deleted by accident
#!/bin/sh
find .git/objects -mtime -2h -type f | while read -r path
do
dir=${path#.git/objects/}
dir=${dir%/*}
name=${path##*/}
id=$dir$name
type=$(git cat-file -t "$id")
if test "$type" = blob
then
@jaysoffian
jaysoffian / kurosawa_top_100.py
Created March 23, 2021 17:59
Convert Akira Kurosawa's top 100 films to a CSV for import to Letterboxd
#!/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
#!/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 February 1, 2017 20:17
.bashrc for staging/production machines
# .bashrc
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
# User specific aliases and functions
set_prompt() {
local titlebar red yellow reset
--- 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 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
@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 / 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_.])*)) |