Skip to content

Instantly share code, notes, and snippets.

@Bouke
Bouke / gist:5187280
Created March 18, 2013 13:53
run all tests on pre-push
remote="$1"
url="$2"
while read local_ref local_sha remote_ref remote_sha
do
if [ "$remote_ref" == "refs/heads/master" ]; then
# echo "Pushing to refs/heads/master, running test cases"
if [ "$local_ref" == "HEAD" ]; then
[virtualenv's]python manage.py test --failfast
exit $?
@Bouke
Bouke / gist:5150181
Last active December 14, 2015 21:19
Random Password Generator Bookmarklet
javascript:(function() {
tmp = "";
for (var i=0; i<24; i++) {
tmp += String.fromCharCode((Math.random() * 94 | 0) + 33);
}
prompt("Your password", tmp);
})()
<html>
<head prefix="og: http://ogp.me/ns# fb: http://ogp.me/ns/fb# je-eigen-ronde: http://ogp.me/ns/fb/je-eigen-ronde#">
<title>OG Sample Object - Sample Track</title>
<meta property="og:type" content="game.achievement" />
<meta property="og:title" content="Completed All Tracks!" />
<meta property="fb:app_id" content="121286284698132" />
<meta property="og:image" content="https://fbstatic-a.akamaihd.net/images/devsite/attachment_blank.png" />
<meta property="og:url" content="https://gist.github.com/raw/4446602/fb.achievement.html" />
<meta property="og:description" content="Marvelous achievement" />
<meta property="game:points" content="50" />
@Bouke
Bouke / gist:4110867
Created November 19, 2012 14:15
OSX-like toolbar wxpython
import wx
class DemoFrame(wx.Frame):
def __init__(self):
wx.Frame.__init__(self, None, wx.ID_ANY, "Somewhat Native OSX Toolbar", size=(700,400))
self.toolbar = self.CreateToolBar(wx.TB_FLAT | wx.TB_TEXT)
self.toolbar.AddLabelTool(wx.ID_NEW, 'Label', wx.Bitmap('wrench.png'))
self.toolbar.AddCheckLabelTool(wx.ID_NEW, 'Check', wx.Bitmap('wrench.png'))
self.toolbar.AddRadioLabelTool(wx.ID_NEW, 'Radio 1', wx.Bitmap('wrench.png'))
@Bouke
Bouke / gist:4059634
Created November 12, 2012 14:15
OSX: wx, Grid, ChoiceEditor and empty cell -> render issue
import wx
import wx.grid
class Frame1(wx.Frame):
def __init__(self, parent):
wx.Frame.__init__(self, id=-1, name='', parent=None,
pos=wx.Point(100, 100), size=wx.Size(480, 250),
style=wx.DEFAULT_FRAME_STYLE, title='Spam & Eggs')
self.SetClientSize(wx.Size(400, 250))
@Bouke
Bouke / fabfile.py
Created September 16, 2012 12:47
fabric test: hosts/roles command line overrides
from fabric.api import *
## hosts
@task
@hosts('a')
def first():
execute(second)
@task
@Bouke
Bouke / settings.py
Created September 2, 2012 13:22
Django simple sqlite config
import os
# Define PROJECT_PATH as the project's root directory, according to new 1.4 layout:
#
# root
# |-- manage.py
# |-- project
# |-- settings.py
PROJECT_PATH = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
@Bouke
Bouke / .bashrc
Created November 2, 2010 23:55
git branch styled in prompt
# if GIT_PS1_SHOWDIRTYSTATE is set to a nonempty value,
# unstaged (*) and staged (+) changes will be shown next to the branch name
export GIT_PS1_SHOWDIRTYSTATE=1
# if GIT_PS1_SHOWSTASHSTATE is set to a nonempty value,
# a ‘$’ will be shown next to the branch name if something is stashed
export GIT_PS1_SHOWSTASHSTATE=1
# if GIT_PS1_SHOWUNTRACKEDFILES is set to a nonempty value,
# a ‘%’ will be shown next to the branch name if there’re untracked files
@Bouke
Bouke / copy-last-commit-id-to-clipboard.sh
Created August 27, 2010 12:23
Copy commit-id to clipboard in post-commit hook
#!/bin/sh
# Use this per example as a post-commit hook
git log -n 1 --pretty=%H | tr -d '\n' | xclip -sel clip
echo "\033[32mCopied commit-id to clipboard\033[0m"
@Bouke
Bouke / snippet-singleton.php
Created August 16, 2010 09:39
Singleton Snippet
class ${ClassName} {
protected static $instance;
/**
* Returns an instance of this Singleton
* @return ${ClassName}
*/
public static function getInstance() {
if(!isset(self::$instance)) {
self::$instance = new self();