Skip to content

Instantly share code, notes, and snippets.

export RUBY_PREFIX="$HOME/.ruby"
export PATH="$RUBY_PREFIX/bin/:$RUBY_PREFIX/lib/ruby/gems/1.8/bin/:$PATH"
export GEM_HOME="$RUBY_PREFIX/lib/ruby/gems/1.8"
export GEM_PATH="$GEM_HOME"
export RUBYLIB="$RUBY_PREFIX/lib/ruby:$RUBY_PREFIX/lib:$RUBY_PREFIX/lib/site_ruby/1.8"
@jbarratt
jbarratt / gist:1343205
Created November 6, 2011 17:30
Bulk HandbrakeCLI Encoder
#!/bin/bash
find . -name "*.mkv" | while read FILE
do
# What would the output file be?
DST=/Volumes/USBRAID/Converted/$(dirname "$FILE")
MKV=$(basename "$FILE")
MP4=${MKV%%.mkv}.mp4
# If it already exists, don't overwrite it
if [ -e "$DST/$MP4" ]
#!/usr/bin/env python
import re
filelist = ["foo.txt", "__foo.html", "bar.txt", "__bar.html", "baz.mp3"]
matchfiles = [i for i in filelist if i.startswith("__")]
matchre = [i for i in filelist if re.search('o+', i)]
print matchfiles
print matchre
@jbarratt
jbarratt / bdaydist.py
Created August 30, 2012 23:13
How many birthdays/day as a function of your friend list size?
#!/usr/bin/env python
import sys
import random
friends = int(sys.argv[1])
counts = {}
iterations = 1000
@jbarratt
jbarratt / multi_package_ci.py
Created September 13, 2012 19:51
Multi-package local python CI with watchdog
#!/usr/bin/env python
'''
Based on http://ginstrom.com/scribbles/2012/05/10/continuous-integration-in-python-using-watchdog/
Dependencies: ``watchdog`` (pip install watchdog)
Montiors the whole tree for changes.
Check for all changes to any files and test the associated package; we might want to test changes to a pyramid test.ini, say, or a file rename as part of a refactor.
@jbarratt
jbarratt / month_summer.py
Created March 20, 2013 03:46
Summing by column with pandas
#!/usr/bin/env python
from collections import Counter
import pandas as pd
import glob
""" Open a bunch of .csv files which have columns that look like
startdate, enddate, account, service, 2010-01, 2010-02, 2010-03, ...
Sum the date-like columns across all of the .csv files and display.
@jbarratt
jbarratt / import_octopress_posts.py
Created March 21, 2013 21:45
Utility to import Octopress and Jekyll posts into Nikola.
#!/usr/bin/env python
import sys
import os
import glob
import re
def octo_parse(octo_post):
"""
@jbarratt
jbarratt / input.py
Last active August 29, 2015 13:58
Simple input grabbing
#!/usr/bin/env python
def get_yn(question):
prompt = question + " [y/n]: "
ok = {'y', 'n'}
answer = None
while answer not in ok:
answer = raw_input(prompt).strip().lower()
return answer == 'y'
@jbarratt
jbarratt / Slow Process Example.ipynb
Created May 15, 2014 21:29
Slow Process Example
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jbarratt
jbarratt / SimpleSinisterStats.py
Created June 3, 2014 17:08
SimpleSinisterStats
from scene import *
import time
import clipboard
import sys
import speech
class SimpleSinister(object):
def __init__(self):