Skip to content

Instantly share code, notes, and snippets.

@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 / 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
{
"metadata": {
"name": "",
"signature": "sha256:d2f389e058e5bdca375e594db6578970fa9ed3b67ca98e85e2b9865dd974ef37"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
@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
-- AppleScript to log into Cisco AnyConnect VPN
--
-- Based on https://gist.github.com/andrewh/7135352
--
-- 1. Edit the "vpn" variable below.
-- 2. Add your VPN password into your keychain. Use
-- "security add-generic-password -a VPN_HOST -s VPN_HOST
-- from the command line, and then edit the password using
-- the Keychain Access application.
-- 3. From AppleScript Editor, use File...Export to export
ls -1 /var/run/cloudera-scm-agent/process/ | \
while read line; do
id=$(echo $line | cut -d "-" -f1)
process=$(echo $line | sed -e "s/^[0-9]*-//")
echo "$process $id"
done | sort -k1,1r -k2,2nr | \
while read key value; do
if [ "$cur_key" = "$key" ]; then
echo -n ",$value"
else
@philz
philz / gist:7944334
Created December 13, 2013 13:39
HDFS Tests
[0]theia:cdh5:hdfs(9781)$pwd
/Users/philip/src/smokes/hadoop/src/main/groovy/com/cloudera/itest/hadoop/hdfs
[0]theia:cdh5:hdfs(9782)$git log --oneline -n 1 HEAD
a7ff5ea CDH-16198: itests should accomodate name changes of CDK to Kite(Fixing the skipped morphline)
[0]theia:cdh5:hdfs(9783)$git grep -A1 '@Test' | grep public | sed -e 's!.*/!!' | sed -e 's/().*$//' | sed -e 's/ public void//' | sed -e 's/- /:/'
TestDFSAdmin.java:testBasic
TestDFSAdmin.java:testSafemode
TestDFSAdmin.java:testNamespace
TestDFSAdmin.java:testRefreshCommands
TestDFSAdmin.java:testUpgrades
@philz
philz / README.md
Last active December 24, 2015 14:19
Bookmarklet to highlight a tab after 30 minutes.

Bookmarklet to highlight a tab after 30 minutes. Blinks the title when the timer has run out.

@philz
philz / gist:6444491
Created September 5, 2013 00:18
Inefficient mechanism to find slow Surefire-executed tests. keywords: maven surefire test duration time
$paste <(xpath -q -e '//testcase/@name' $(find . -name 'TEST-*.xml') ) <(xpath -q -e '//testcase/@classname' $(find . -name 'TEST-*.xml') ) <(xpath -q -e '//testcase/@time' $(find . -name 'TEST-*.xml') ) | tr '=' ' ' | tr -d '"' | awk '{ print $6, $4, $2 }' | sort -n > testtimes