Skip to content

Instantly share code, notes, and snippets.

View k0pernikus's full-sized avatar

Philipp Kretzschmar k0pernikus

View GitHub Profile
$ brew install -v gource 2>&1
==> Downloading https://github.com/acaudwell/Gource/releases/download/gource-0.42/gource-0.42.tar.gz
Already downloaded: /opt/boxen/cache/homebrew/gource-0.42.tar.gz
==> Verifying gource-0.42.tar.gz checksum
tar xf /opt/boxen/cache/homebrew/gource-0.42.tar.gz
==> ./configure --disable-dependency-tracking --prefix=/opt/boxen/homebrew/Cellar/gource/0.42 --without-x
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... build-aux/install-sh -c -d
checking for gawk... no
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... build-aux/install-sh -c -d
checking for gawk... no
checking for mawk... no
checking for nawk... no
checking for awk... awk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking build system type... x86_64-apple-darwin13.2.0
@k0pernikus
k0pernikus / svn-zip
Created August 24, 2012 14:17 — forked from blech75/svn-zip
export SVN URL, zip it up, drop it on your desktop
#!/bin/bash
if [ $# -ne 2 ] ; then
echo "Usage: "`basename "$0"` "SVN_URL ZIP_NAME" >&2
exit 1
fi
SVN_URL=$1
DIR_NAME=$2
@k0pernikus
k0pernikus / README.md
Created October 25, 2012 12:12 — forked from oodavid/README.md
Deploy your site with git

Deploy your site with git

This gist assumes:

  • you have a local git repo
  • with an online remote repository (github / bitbucket etc)
  • and a cloud server (Rackspace cloud / Amazon EC2 etc)
    • your (PHP) scripts are served from /var/www/html/
    • your webpages are executed by apache
  • apache's home directory is /var/www/
@k0pernikus
k0pernikus / validate_json
Created February 24, 2013 19:06
Validate JSON on command line via python
cat config.json | python -m simplejson.tool
#! /bin/sh
### BEGIN INIT INFO
# Provides: supervisord
# Required-Start: $remote_fs
# Required-Stop: $remote_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Example initscript
# Description: This file should be used to construct scripts to be
# placed in /etc/init.d.

Virtualenv's bin/activate is Doing It Wrong

I'm a Python programmer and frequently work with the excellent [virtualenv][] tool by Ian Bicking.

Virtualenv is a great tool on the whole but there is one glaring problem: the activate script that virtualenv provides as a convenience to enable its functionality requires you to source it with your shell to invoke it. The activate script sets some environment variables in your current environment and defines for you a deactivate shell function which will (attempt to) help you to undo those changes later.

This pattern is abhorrently wrong and un-unix-y. activate should instead do what ssh-agent does, and launch a sub-shell or sub-command with a modified environment.

Problems

@k0pernikus
k0pernikus / checkout-closest-branch.sh
Created December 17, 2015 18:45
checkout branch based upon lievensthein distance from the argument
#!/bin/bash
BRANCH=$1
BRANCHES=$(git branch | sed 's/^..//')
array=($BRANCHES)
function levenshtein {
if [ "$#" -ne "2" ]; then
echo "Usage: $0 word1 word2" >&2
elif [ "${#1}" -lt "${#2}" ]; then
levenshtein "$2" "$1"
@k0pernikus
k0pernikus / getCachedHtml.js
Created July 11, 2013 07:04
Cache $.get calls use Chrome Extension chrome.storage.local
jQuery.extend({
getCachedHTML: function (url, returnHtmlDataCallback) {
var cacheTimeInMs = 1209600000; // two weeks
var currentTimeInMs = new Date().getTime();
var cache = {
data:null,
timestamp:null
};
@k0pernikus
k0pernikus / DefaultKeyBinding.Dict
Created July 18, 2013 08:38
Key Mapping for Mac OS
/* ~/Library/KeyBindings/DefaultKeyBinding.Dict
This file remaps the key bindings of a single user on Mac OS X 10.5 to more closely
match default behavior on Windows systems. This particular mapping assumes
that you have also switched the Control and Command keys already.
This key mapping is more appropriate after switching Ctrl for Command in this menu:
Apple->System Preferences->Keyboard & Mouse->Keyboard->Modifier Keys...->
Change Control Key to Command
Change Command key to Control
This applies to OS X 10.5 and possibly other versions.