Skip to content

Instantly share code, notes, and snippets.

Chad Whitacre chadwhitacre

Block or report user

Report or block chadwhitacre

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:4961656
main_loop = true;
^L
stuff = "blah";
finished();
^L
{{ stuff }}
View gist:4772970
var q = require('q'),
vm = require('vm'),
ctx = vm.createContext(),
script = vm.createScript("now = 1;");
script.runInContext(ctx);
console.log(ctx.now);
View async-context.js
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);
View funds-sample.json
[
{
"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": [
View hammer.py
#!/usr/bin/env python -u
import commands
import os
import random
import sys
import time
restart = '-s' in sys.argv
if restart:
View gist:4236798
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
View gist:4236689
set showtabline=2
nmap <C-S-tab> :tabprevious<cr>
nmap <C-tab> :tabnext<cr>
nmap <C-t> :tabnew<cr>
nmap <C-w> :tabclose<cr>
View gist:4150750
# === 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 ===
@chadwhitacre
chadwhitacre / gist:4150456
Created Nov 26, 2012
configure-aspen.py for current aspen auth
View gist:4150456
from aspen import auth
class MyUser(auth.BaseUser):
pass
auth.User = MyUser
@chadwhitacre
chadwhitacre / tt.py
Created Nov 1, 2012
Time tracking script.
View tt.py
#!/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
You can’t perform that action at this time.