Skip to content

Instantly share code, notes, and snippets.

@philz
philz / gist:a2a9f82f6172227b5c14
Last active August 29, 2015 14:05
Installing ipython notebook on OS X
# See https://gist.github.com/westurner/3196564
brew install readline
brew install zeromq
virtualenv ~/py
~/py/bin/pip install ipython pyzmq tornado pygments numpy python-dateutil pytz scipy matplotlib statsmodels pandas
~/py/bin/easy_install pyzmq
~/py/bin/easy_install tornado
# Remove the version check
vi py/lib/python2.7/site-packages/IPython/utils/zmqrelated.py
~/py/bin/ipython notebook
{
"metadata": {
"name": "",
"signature": "sha256:d2f389e058e5bdca375e594db6578970fa9ed3b67ca98e85e2b9865dd974ef37"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
@philz
philz / git-find-branches-with-commit.sh
Last active August 29, 2015 14:08
git-find-branches-with-commit
#!/bin/bash
# https://gist.github.com/philz/dfca51807d9431b662aa
export PAGER=
if [[ $# -ne 1 ]]; then
echo "$0 finds all branches and tags a commit is in, based on"
echo "'git log --grep' and 'git branch --contains'"
echo "Usage: $0 <grep_term>"
exit 1
@philz
philz / gist:d5e59344a537045f6d6d
Last active August 29, 2015 14:11
Join, awk, sort, uniq, lsof to find pids leaking fds
## Leak file descriptors
$ python <<EOF
import time
a=[]
while True:
a.append(open("/tmp/z" + str(len(a)), "w"))
time.sleep(0.5)
EOF
## Find leakers
# Make sense of puppet circular dependency error messages.
# Tags: graphviz, puppet
# See output at http://i41.tinypic.com/b6yeqv.jpg
$ cat circular.pp
node default {
exec { "/a": require => Exec["/b"] }
exec { "/b": require => Exec["/c"] }
exec { "/c": require => Exec["/a"] }
}
#!/usr/bin/env python
#
# Python code for http://www.cloudera.com/blog/2009/06/17/analyzing-apache-logs-with-piganalyzing-apache-logs-with-pig/
import sys
import math
def rescale(values, low=0, high=4095):
"""Linearly rescales values to be strictly between low and high."""
maxval = max(values)
@philz
philz / unixtime.sh
Created November 30, 2012 17:59
seconds since epoch to readable
# $unixtime 1354232717
# local Thu 29 Nov 2012 03:45:17 PM PST utc Thu 29 Nov 2012 11:45:17 PM GMT
unixtime ()
{
gawk "BEGIN { print \"local\", strftime("'"'"%c"'"'", $1), \"utc\", strftime("'"'"%c"'"'", $1, 1) ; }"
}
# Alternately,
# $date -d @1354298146
# Fri Nov 30 09:55:46 PST 2012

Header 1

Header 2

Header 3 ### (Hashes on right are optional)

Header 4

Header 5

Markdown plus h2 with a custom ID ## {#id-goes-here}

Link back to H2

This is a paragraph, which is text surrounded by whitespace. Paragraphs can be on one

@philz
philz / gist:4773497
Created February 12, 2013 21:20
Draw depending graph of jstack/stacks debug servlet output
dot -Tpng -o out.png <(cat stacks.txt | awk '/^Thread/ { cur = $2 } /Blocked by/ { print "t"cur, "->", "t"$3 } BEGIN { print "digraph G {"} END { print "}" }')