Skip to content

Instantly share code, notes, and snippets.

View clutchski's full-sized avatar

Matt Perpick clutchski

View GitHub Profile
@clutchski
clutchski / 20091114132332_example_caribou_migration.py
Created November 14, 2009 18:08
an example of a caribou migration
"""
an example of a caribou migration
"""
def upgrade(connection):
sql = """
create table animals
( name TEXT
, status TEXT
) """
"""
an example illustrating how to run a caribou migration
"""
import caribou
db_path = '/path/to/db.sqlite3'
migrations_path = '/path/to/migrations/dir'
version = '20091114132332'
"""
A Caribou migration demonstrating an interface for database agnostic migrations
that doesn't force how you connect to the database.
"""
def upgrade(connector):
# a connector can give you a plain old db api connection
conn = connector.connect()
conn.execute("create table my_table ...")
"""
This module demonstrates the functionality
of the fileutils library.
http://github.com/clutchski/fileutils
"""
import fileutils
#
@clutchski
clutchski / tokenize
Created December 12, 2011 01:38
print coffee script tokens with metadata
#!/usr/bin/env node
var fs = require('fs');
var path = require('path');
var CoffeeScript = require('coffee-script');
var file = process.argv[2];
var source = fs.readFileSync(file).toString()
var tokens = CoffeeScript.tokens(source);
var totals = _.reduce(results, function (memo, result) {
var curScore = memo[result.measure] || 0;
curScore += result.score;
memo[result.measure] = curScore;
return memo;
}, {});
$(document).ready ->
onHoverStart = ->
$(this).animate({backgroundColor:'#7c9344'},'fast')
onHoverEnd = ->
$(this).animate({backgroundColor:'#7c9344'},'fast')
$('#menu li a').hover(onHoverStart, onHoverEnd)
@clutchski
clutchski / gist:1760428
Created February 7, 2012 16:06
compiled if expressions
# This CoffeeScript compiles to ...
x = if 'a' in [1, 2, 3, 4]
1
else if 'b' in [1, 2, 3, 4, 5]
2
else if 'c' > 'd'
3
else
from random import random
from dogapi import dog_stats_api
dog_stats_api.start(statsd=True,
statsd_host='localhost',
statsd_port=8125)
while True:
dog_stats_api.gauge('test.udp.gauge', 1000)
@clutchski
clutchski / transcode.rb
Created September 22, 2012 21:47
A small script to transcode a directory tree of media files with ffmpeg.
#!/usr/bin/env ruby
#
# This is a small script to transcode a directory of media files
# with ffmpeg.
require 'fileutils'
# These are config values are for my project. Swap in your own.
input_dir="/Volumes/severn.5/video"
output_dir="/Volumes/severn.4/video/transcoded"