Skip to content

Instantly share code, notes, and snippets.

@chadwhitacre
chadwhitacre / gist:3902155
Created October 16, 2012 21:27
Testing with context managers
from gittip import testing
def test_inserting_inserts():
with testing.load() as context:
context.db.execute("INSERT INTO participants VALUES ('foo')")
actual = context.diff(compact=True)
@chadwhitacre
chadwhitacre / gist:3940639
Created October 23, 2012 18:37
diff -ru master-02899 master-a805
diff -ru master-02899/.git/HEAD master-a805/.git/HEAD
--- master-02899/.git/HEAD 2012-10-23 14:35:41.000000000 -0400
+++ master-a805/.git/HEAD 2012-10-23 14:35:14.000000000 -0400
@@ -1 +1 @@
-02899c45e4eef039318c641bc70e477478b23740
+a805db2e43d8da3017b2da4c2e0db981b10c748c
Binary files master-02899/.git/index and master-a805/.git/index differ
diff -ru master-02899/.git/logs/HEAD master-a805/.git/logs/HEAD
--- master-02899/.git/logs/HEAD 2012-10-23 14:35:41.000000000 -0400
+++ master-a805/.git/logs/HEAD 2012-10-23 14:35:14.000000000 -0400
@chadwhitacre
chadwhitacre / tt.py
Created November 1, 2012 16:36
Time tracking script.
#!/usr/bin/env python
"""This script prints time tracking reports to stdout.
The program takes its configuration from ~/.ttrc, which is in INI format
with one section and two keys:
[main]
timesheet=~/.timesheet
timezone=US/Eastern
@chadwhitacre
chadwhitacre / gist:4150456
Created November 26, 2012 20:36
configure-aspen.py for current aspen auth
from aspen import auth
class MyUser(auth.BaseUser):
pass
auth.User = MyUser
# === configure-aspen.py ===
website.security.timeout = 86400
website.security.httpbasic.enabled = True
website.security.httpdigest.enabled = True
website.security.cookieauth.enabled = True
website.security.cookieauth.timeout = 86400 * 7
# === login / logout ===
set showtabline=2
nmap <C-S-tab> :tabprevious<cr>
nmap <C-tab> :tabnext<cr>
nmap <C-t> :tabnew<cr>
nmap <C-w> :tabclose<cr>
SETUP_NEW_TIPS_TO = """
INSERT INTO tips (ctime, tipper, tippee, amount)
SELECT DISTINCT ON (tipper)
min(ctime), tipper, %s AS tippee, sum(amount)
FROM tips
WHERE tippee=%s OR tippee=%s
GROUP BY tipper, mtime
ORDER BY t
#!/usr/bin/env python -u
import commands
import os
import random
import sys
import time
restart = '-s' in sys.argv
if restart:
[
{
"id": "GitTip.com/UserL33T/PubFund1",
"link": { "rel": "self", "type": "application/atom+xml", "href": "http://gittip.com/UserL33T/PubFund1" },
"updated": "20120930T180453Z",
"author": {"name": "UserL33T"},
"title": "UserL33T's First Published Fund",
"description": "UserL33T's First Published Fund is a Project",
"units_type": "USD",
"entries": [
var q = require('q'),
vm = require('vm'),
ctx = vm.createContext({setTimeout: setTimeout, console: console, end: q.defer()}),
script = vm.createScript("now = 1; setTimeout(function() { now = 2; console.log('Inside the VM: ' + now); end.resolve() }, 1000);");
script.runInContext(ctx);
ctx.end.promise.then(function () {
console.log("Now process template with " + ctx.now);
}, 500);