Skip to content

Instantly share code, notes, and snippets.

@akheron
akheron / gitconfig
Created October 31, 2011 13:17
Git aliases and hooks for CPython workflow
# Aliases for working with a hg-git enabled mercurial repository in .git/hg
[alias]
hg-dir = "!echo ${GIT_DIR:-.git}/hg"
hg-run = "!hg -R $(git hg-dir)"
hg-git-dir = "!echo $(git hg-dir)/.hg/git"
hg-git-branch = "!f() { [ \"$1\" = default ] && echo master || echo \"$1\"; }; f"
hg-update-bookmarks = "!git hg-run branches | while read branch rev rest; do target=$(git hg-git-branch $branch); rev=$(echo $rev | sed -r \"s/([0-9]+):.*/\\1/\"); git hg-run bookmark -f -r $rev $target; done"
hg-delete-bookmarks = "!git hg-run bookmarks | sed -r 's/[[:space:]]+(.+?)[[:space:]]+.*/\\1/' | xargs -n 1 git hg-run bookmark -d"
hg-hg2git = "!git hg-update-bookmarks && git hg-run gexport"
hg-git2hg = "!git hg-delete-bookmarks && git hg-run gimport"
@akheron
akheron / .gitconfig
Last active September 28, 2015 05:38
My .gitconfig
[alias]
st = status --short --branch
dc = diff --cached -M -B -C
typo = commit --amend
fixup = commit --amend --no-edit
logk = log --graph --pretty=\"format:%C(yellow)%h%C(red)%d%Creset %s %C(green)%an, %ar%Creset\"
ffpull = pull --ff-only
ffmerge = merge --ff-only
ri = "!f() { rev=$(git rev-parse $1 2>/dev/null) || rev=HEAD~$1; git rebase -i $rev; }; f"
rc = rebase --continue
/* JavaScript progress bar
*
* Reads the percentage value from the content of an element and
* replaces it with a progress bar.
*
* Example:
*
* <span class="progress">100 %</span>
* <script>
* $('.progress').progressbar();
@akheron
akheron / salacomplete.sh
Created January 2, 2012 07:28
bash completion for sala
#!bash
_sala() {
local IFS=$'\n' dir=${SALADIR:-.} cur
if ! type _get_comp_words_by_ref >/dev/null 2>&1; then
cur=${COMP_WORDS[$COMP_CWORD]}
else
_get_comp_words_by_ref cur
fi
@akheron
akheron / config
Created May 2, 2012 10:50
git config for detached worktree
# Create the repository with "git init --bare", then edit config to match this:
[core]
repositoryformatversion = 0
filemode = true
bare = false
worktree = /path/to/worktree
[receive]
denycurrentbranch = ignore
@akheron
akheron / python-tracker-stats.py
Created May 18, 2012 07:42
Python tracker statistic plotter
# Search for statistic messages from the Python trakcer robot in
# python-dev archives and plot the result.
#
# $ python-traker-stats.py collect
#
# Collects statistics from the mailing list and saves to
# python-tracker-stats.json
#
# $ python-tracker-stats.py plot
#
@akheron
akheron / mailcap
Created May 24, 2012 10:44
mailcap for text/html alternatives in mutt
# Open in browser when viewing interactively
text/html; /usr/bin/sensible-browser '%s'; description=HTML Text; nametemplate=%s.html
# Dump with w3cm and the correct encoding when viewing non-interactively
text/html; /usr/bin/w3m -dump -T text/html -I %{charset} -O utf-8 %s; copiousoutput; description=HTML Text; nametemplate=%s.html
# Support non-standard image/jpg, too
image/jpg; display 'jpeg:'%s''; test=test -n "$DISPLAY"
@akheron
akheron / postactivate
Created May 29, 2012 05:31
virtualenvwrapper hooks for sala
#!/bin/bash
# This hook is run after this virtualenv is activated.
export SALADIR=/path/to/passwords
. /path/to/sala/contrib/sala-completion.bash
@akheron
akheron / xorg-valgrind.log
Created July 30, 2012 11:58
Valgrind log for xorg serve crash
==7657== Memcheck, a memory error detector
==7657== Copyright (C) 2002-2011, and GNU GPL'd, by Julian Seward et al.
==7657== Using Valgrind-3.7.0 and LibVEX; rerun with -h for copyright info
==7657== Command: /usr/bin/Xorg :0 -auth /var/run/lightdm/root/:0 -nolisten tcp vt7 -novtswitch -verbose 10
==7657==
X.Org X Server 1.11.3
Release Date: 2011-12-16
X Protocol Version 11, Revision 0
Build Operating System: Linux 2.6.42-26-generic x86_64 Ubuntu
@akheron
akheron / xorg-valgrind.log
Created July 30, 2012 13:26
Valgrind log with patched xserver-xorg
==20591== Memcheck, a memory error detector
==20591== Copyright (C) 2002-2011, and GNU GPL'd, by Julian Seward et al.
==20591== Using Valgrind-3.7.0 and LibVEX; rerun with -h for copyright info
==20591== Command: /usr/bin/Xorg :1 -auth /var/run/lightdm/root/:1 -nolisten tcp vt7 -novtswitch -verbose 10
==20591==
X.Org X Server 1.11.3
Release Date: 2011-12-16
X Protocol Version 11, Revision 0
Build Operating System: Linux 3.2.0-27-generic x86_64 Ubuntu