Skip to content

Instantly share code, notes, and snippets.

Avatar

Bouke Haarsma Bouke

View GitHub Profile
@Bouke
Bouke / gist:5187280
Created Mar 18, 2013
run all tests on pre-push
View gist:5187280
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 Dec 14, 2015
Random Password Generator Bookmarklet
View gist:5150181
javascript:(function() {
tmp = "";
for (var i=0; i<24; i++) {
tmp += String.fromCharCode((Math.random() * 94 | 0) + 33);
}
prompt("Your password", tmp);
})()
View fb.achievement.html
<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 Nov 19, 2012
OSX-like toolbar wxpython
View gist:4110867
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 Nov 12, 2012
OSX: wx, Grid, ChoiceEditor and empty cell -> render issue
View gist:4059634
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 Sep 16, 2012
fabric test: hosts/roles command line overrides
View fabfile.py
from fabric.api import *
## hosts
@task
@hosts('a')
def first():
execute(second)
@task
@Bouke
Bouke / settings.py
Created Sep 2, 2012
Django simple sqlite config
View settings.py
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 Nov 2, 2010
git branch styled in prompt
View .bashrc
# 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 Aug 27, 2010
Copy commit-id to clipboard in post-commit hook
View copy-last-commit-id-to-clipboard.sh
#!/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"
View snippet-singleton.php
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();
You can’t perform that action at this time.