Skip to content

Instantly share code, notes, and snippets.

from IPython.core import ipapi
def istore():
'''Extracts all variable names used in assignments from the input history
and stores them.'''
ipy = ipapi.get()
for v in assignees(assignments(ipy.history_manager.input_hist_raw)):
try:
ipy.magic('store %s' % v)
except:
#!/usr/bin/env python
# Add this to: .git/hooks/pre-commit
# if ! git diff-index --check $against > /dev/null 2>&1; then
# git diff --cached --name-status | $(HOME)/bin/linecleaner.py
# fi
import sys
import re
import fileinput
@fberger
fberger / chromejar.py
Created May 23, 2012 09:34
ChromeCookieJar
from cookielib import CookieJar, Cookie
import sqlite3
import os
import shutil
import tempfile
__all__ = ['ChromeCookieJar']
def to_epoch_seconds(chrome_timestamp):
return chrome_timestamp - 11644473600 * 1000 * 1000
@fberger
fberger / commands
Created July 14, 2011 02:33
bash commands
# export files from branch into a folder for releasing
git archive master | tar -x -C /tmp/test/
@fberger
fberger / .emacs
Last active September 25, 2015 17:48
.emacs
(custom-set-variables
'(dabbrev-upcase-means-case-search t)
'(tags-revert-without-query t)
'(custom-file "~/.emacs")
'(blink-cursor-mode nil)
'(dabbrev-case-fold-search t)
'(iswitchb-mode t nil (iswitchb))
'(global-font-lock-mode t nil (font-lock)))
(setq-default fill-column 80)
(setq-default column-number-mode t)
mvn -D'test=package.ClassTest' verify
# print http headers and body
tshark -R 'http' -S -V -l | awk '/^[HL]/ {p=30} /^[^ HL]/ {p=0} /^ / {--p} {if (p>0) print}'
@fberger
fberger / .Xmodmap
Created August 23, 2010 14:38
.Xmodmap
keycode 135 = Control_R
add Control = Control_R
keycode 134 = Menu
@fberger
fberger / .bashrc
Last active February 12, 2020 20:57
.bashrc
# don't put duplicate lines in the history. See bash(1) for more options
# ... and ignore same sucessive entries.
export HISTCONTROL=ignoredups:ignoreboth:ingorespace
export HISTFILESIZE=100000
export HISTSIZE=10000
# have shells append to your history
shopt -s histappend
# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
function export_file {
line=$1
file=$(echo $line | awk '{print $3}')
prefix=$(echo $line | cut -d':' -f1)
eval "export f${counter}=${file}"
echo "${prefix}: f${counter} ${file}"
let counter=$counter+1
}
import com.sun.jersey.spi.container.ContainerRequest;
import com.sun.jersey.spi.container.ContainerResponse;
import com.sun.jersey.spi.container.ContainerResponseFilter;
import com.sun.jersey.spi.container.ContainerResponseWriter;
import javax.ws.rs.core.HttpHeaders;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.MultivaluedMap;
import java.io.IOException;