Skip to content

Instantly share code, notes, and snippets.

View singingwolfboy's full-sized avatar
Available for contract work

David Baumgold singingwolfboy

Available for contract work
View GitHub Profile
@singingwolfboy
singingwolfboy / merge.py
Created July 11, 2011 22:40
Merging two sorted lists
def merge(lst1, lst2):
sorted = []
iter1 = iter(lst1)
iter2 = iter(lst2)
l1_done = False
l2_done = False
val1 = lst1.next()
val2 = lst2.next()
while True:
if val1 < val2 or l2_done:
@singingwolfboy
singingwolfboy / gist:2712918
Created May 16, 2012 18:41
Update the "Default" plugin in ST2 to allow "Trim Trailing Whitespace" as a text command
--- Default/trim_trailing_white_space.py.bak 2012-04-13 11:18:23.000000000 -0400
+++ Default/trim_trailing_white_space.py 2012-04-13 11:49:48.000000000 -0400
@@ -1,19 +1,37 @@
-import sublime, sublime_plugin
+import sublime_plugin
-class TrimTrailingWhiteSpace(sublime_plugin.EventListener):
+
+class TrimTrailingWhiteSpace(sublime_plugin.TextCommand):
+ def run(self, *args):
DROP TABLE IF EXISTS "user";
CREATE TABLE "user" (
id serial PRIMARY KEY,
username varchar(256) NOT NULL,
email varchar(256) NOT NULL,
email_verified boolean DEFAULT FALSE,
created_on timestamp DEFAULT now(),
admin boolean DEFAULT FALSE
);
CREATE FUNCTION apply_hunks(content text[], page_id int,
min_revision int, max_revision int, reverse boolean DEFAULT FALSE)
RETURNS text[] as $$
declare
hunk record;
revision int := null;
offset int := 0;
start int;
length int;
content_line text;
autoload -U compinit promptinit colors
compinit
promptinit
colors
autoload -Uz vcs_info
vcs_info
setopt prompt_subst
# vim-style keybindings
bindkey -v
$ git clone eczarny/spectacle
Cloning into 'spectacle'...
remote: Counting objects: 1634, done.
remote: Compressing objects: 100% (567/567), done.
remote: Total 1634 (delta 1033), reused 1511 (delta 923)
Receiving objects: 100% (1634/1634), 3.08 MiB | 817 KiB/s, done.
Resolving deltas: 100% (1033/1033), done.
$ cd spectacle
$ git submodule init
Submodule 'Frameworks/Sparkle' (git://github.com/andymatuschak/Sparkle.git) registered for path 'Frameworks/Sparkle'
@singingwolfboy
singingwolfboy / saltstack.patch
Last active October 13, 2015 04:28
set salt config and log dir to live under Homebrew
diff --git a/salt/client.py b/salt/client.py
index cd8aacf..38f8857 100644
--- a/salt/client.py
+++ b/salt/client.py
@@ -69,7 +69,7 @@ class LocalClient(object):
'''
Connect to the salt master via the local server and via root
'''
- def __init__(self, c_path='/etc/salt/master', mopts=None):
+ def __init__(self, c_path='HOMEBREW_PREFIX/etc/salt/master', mopts=None):
@singingwolfboy
singingwolfboy / models.py
Created January 26, 2013 22:51
A complex data model. Users vote on bands, and on associations between bands and genres. (For example: User "Alice" thinks that "Screaming Orgasm" is a "Metal" band.) The `BandGenre` class isn't actually necessary: you can get the set of all `Genre` objects associated with a specific `Band` just by doing a join on `BandGenreVote` and grouping by…
from flask.ext.sqlalchemy import SQLAlchemy
from sqlalchemy.sql import select, func
from sqlalchemy.ext.hybrid import hybrid_property
from datetime import datetime
__all__ = ['User', 'Band', 'Genre', 'BandVote', 'BandGenre', 'BandGenreVote']
db = SQLAlchemy()
class User(db.Model):
# Author: Andreas Christian Mueller <amueller@ais.uni-bonn.de>
# (c) 2012
#
# License: MIT
import os
import sys
import random
from PIL import Image
from PIL import ImageDraw