Skip to content

Instantly share code, notes, and snippets.

View k0pernikus's full-sized avatar

Philipp Kretzschmar k0pernikus

View GitHub Profile
@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 / getCachedJSON.js
Created October 8, 2012 15:14 — forked from kpuputti/gist:1040118
jQuery.getJSON abstraction to cache data to localStorage with invalidation option based time
jQuery.extend({
getCachedJSON: function (url, callback) {
var cacheTimeInMs = 3600000;
var currentTimeInMs = new Date().getTime();
var cache = {
data:null,
timestamp:null
};
@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 / 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.
Sub PasswordBreaker()
'Breaks worksheet password protection.
Dim i As Integer, j As Integer, k As Integer
Dim l As Integer, m As Integer, n As Integer
Dim i1 As Integer, i2 As Integer, i3 As Integer
Dim i4 As Integer, i5 As Integer, i6 As Integer
On Error Resume Next
For i = 65 To 66: For j = 65 To 66: For k = 65 To 66
For l = 65 To 66: For m = 65 To 66: For i1 = 65 To 66
For i2 = 65 To 66: For i3 = 65 To 66: For i4 = 65 To 66
$ 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