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
@philz
philz / test.md
Last active October 29, 2017 04:22
Hey There
NewLine Bar
@philz
philz / impala-branch-image.pdf
Last active January 12, 2018 23:56
branch image
.
This file has been truncated, but you can view the full file.
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<script type="text/javascript">
google.charts.load("current", {packages:["timeline", "corechart"]});
google.charts.setOnLoadCallback(drawChart);
function ts_to_hms(secs) {
var s = secs % 60;
var m = Math.floor(secs / 60) % 60;
@philz
philz / jq-example.sh
Created August 8, 2019 19:04
Using jq to compute relative timestamps of JSON log files
#!/bin/bash
#
# Given a log file of JSON objects with timestamps, adds a new field called
# "relativeTimeMs" for the duration between successive log lines, and then
# sorts by that field to pull out the "longest" log lines.
echo '{"time":"2019-08-08T17:08:08.343Z","msg":"foo"}
{"time":"2019-08-08T17:08:08.347Z","msg":"bar"}
{"time":"2019-08-08T17:08:08.349Z","msg":"baz"}
{"time":"2019-08-08T17:08:09.322Z","msg":"booooom"}
#!/bin/bash
set -x -euo pipefail
git show HEAD^:$1 > $1
git add $1
git commit --fixup HEAD
git revert --no-edit HEAD
git commit --amend -m"$1"
EDITOR=/usr/bin/true git rebase -i --autosquash HEAD^^^