Skip to content

Instantly share code, notes, and snippets.

View kojiromike's full-sized avatar

Michael A. Smith kojiromike

View GitHub Profile
$ brew doctor
Your system is raring to brew.
$ brew --config
HOMEBREW_VERSION: 0.9
HEAD: 506e48d7c5c0875daec12b189206e59f02bc31ab
HOMEBREW_PREFIX: /usr/local
HOMEBREW_CELLAR: /usr/local/Cellar
CPU: quad-core 64-bit core2
OS X: 10.6.8
Homebrew 0.9
==> Upgrading glib
==> Downloading ftp://ftp.gnome.org/pub/gnome/sources/glib/2.30/glib-2.30.3.tar.xz
Already downloaded: /Users/smithm5/Library/Caches/Homebrew/glib-2.30.3.tar.xz
xz -dc "/Users/smithm5/Library/Caches/Homebrew/glib-2.30.3.tar.xz" | /usr/bin/tar xf -
==> Downloading patches
/usr/bin/curl -qf#LA Homebrew 0.9 (Ruby 1.8.7-249; Mac OS X 10.6.8) https://trac.macports.org/export/87537/trunk/dports/devel/glib2/files/patch-configure.diff -o 000-homebrew.diff https://trac.macports.org/export/87537/trunk/dports/devel/glib2/files/patch-glib-2.0.pc.in.diff -o 001-homebrew.diff https://trac.macports.org/export/87537/trunk/dports/devel/glib2/files/patch-glib_gunicollate.c.diff -o 002-homebrew.diff https://trac.macports.org/export/87537/trunk/dports/devel/glib2/files/patch-gi18n.h.diff -o 003-homebrew.diff https://trac.macports.org/export/87537/trunk/dports/devel/glib2/files/patch-gio_xdgmime_xdgmime.c.diff -o 004-homebrew.diff https://trac.macports.org/export/87537/trunk/dports/devel/glib2/fil
@kojiromike
kojiromike / log output
Created May 2, 2012 14:22
hup celeryd on debian
[2012-05-02 14:21:39,374: DEBUG/PoolWorker-7] worker got EOFError or IOError -- exiting
[2012-05-02 14:21:39,374: DEBUG/PoolWorker-8] worker got EOFError or IOError -- exiting
[2012-05-02 14:21:39,374: DEBUG/PoolWorker-7] worker exiting after 0 tasks
[2012-05-02 14:21:39,374: DEBUG/PoolWorker-8] worker exiting after 1 tasks
[2012-05-02 14:21:39,374: INFO/PoolWorker-7] process shutting down
[2012-05-02 14:21:39,374: INFO/PoolWorker-8] process shutting down
[2012-05-02 14:21:39,374: DEBUG/PoolWorker-8] running all "atexit" finalizers with priority >= 0
[2012-05-02 14:21:39,374: DEBUG/PoolWorker-7] running all "atexit" finalizers with priority >= 0
[2012-05-02 14:21:39,375: DEBUG/PoolWorker-8] running the remaining "atexit" finalizers
[2012-05-02 14:21:39,375: DEBUG/PoolWorker-7] running the remaining "atexit" finalizers
@kojiromike
kojiromike / pretty_print_avro.py
Created May 10, 2012 14:43
Completely untested avro pretty-printer
#!/usr/bin/env python
# Translate avro into json and pretty print it.
from avro import schema
from avro.io import BinaryDecoder, DatumReader
from json import dumps
from sys import argv
def read_avro(avro_file_no_schema, avro_schema):
2>/dev/null wget -O- http://www.law.uchicago.edu/alumni/magazine/feed.rss | cat -e | grep -F 'In juven'
<p> ^RIn juvenile justice proceedings, the developmental deficits the adolescents bring to court can also be expected to be great. And because their offending reflects problematic decision making and a certain openness to defining themselves as outside of, or even in opposition to, the system of laws and legal actors that govern them, we should be particularly eager to afford these young people opportunities to develop their decision-making competence and engage with government actors in positive ways.</p>$
#!/bin/bash
generate_lines() {
local length=$1 # Generate this many lines.
local input_file=$2 # Leave $2 and $3 empty to generate an independant file.
local -i input_length # The number of lines in the input file.
local freq_dupes=$(( ${3:-length+1} )) # Copy a line from $input every $freq_dupes iterations
if [[ -r $input_file ]]; then
input_length=$(( $(wc -l < "$input_file") ))
fi
@kojiromike
kojiromike / gist:2938493
Created June 15, 2012 20:14
list only changed files for each commit
logchanged() {
local thiscommit
local prevcommit
(( numcommits < 0 )) || unset numcommits
while read prevcommit; do
if [[ $thiscommit && $prevcommit ]]; then
printf -- '========================================\n'
printf -- '%s\n' "$thiscommit"
printf -- '----------------------------------------\n'
git diff --name-only "$thiscommit" "$prevcommit"
@kojiromike
kojiromike / gist:3071880
Created July 8, 2012 17:19
Compare implementations of islice
from timeit import timeit
setup = '''
l = range(20)
def islice(iterable, *args):
# islice('ABCDEFG', 2) --> A B
# islice('ABCDEFG', 2, 4) --> C D
# islice('ABCDEFG', 2, None) --> C D E F G
# islice('ABCDEFG', 0, None, 2) --> A C E G
s = slice(*args)
#!/usr/bin/env python
from itertools import chain, groupby
from csv import reader, writer
with open('foo.csv') as infile:
r = reader(infile)
groups = groupby(r, lambda x:x[0]) # Group by the first column
lines = []
for group in groups:
@kojiromike
kojiromike / phpCantCloseThis.php
Created October 10, 2012 20:30
PHP closures of $this
// Apparently this is fixed in php 5.4
$ php -a
Interactive shell
php > /**
/* > * Demonstrate that you can use $this to refer to a member variable / property.
/* > */
php > class NullHypothesis {
php { function foo() {