Skip to content

Instantly share code, notes, and snippets.

@theorm
theorm / gist:119878
Created May 29, 2009 10:08
LDOCE online ubiquity command
const ENTRY_TEMPLATE = "<div style=\"clear: both;\"><b><u><a href=\"${link}\">${word} (${type})</a></u></b><br/>" +"</div><br/>";
var $j = jQuery;
CmdUtils.CreateCommand({
name: "ldoce",
icon: "http://www.ldoceonline.com/favicon.ico",
homepage: "http://www.ldoceonline.com/",
author: {name: "Roman Kalyakin", email: "roman.kalyakin@gmail.com"},
@theorm
theorm / gist:1897339
Created February 24, 2012 04:00
Generate colours in tone of the original.
<!DOCTYPE html>
<head>
</head>
<body>
<ul id="colours">
</ul>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script type="text/javascript">
// generate colours related to the 'mix' colour.
@theorm
theorm / list_modification_tests.py
Created April 28, 2012 03:25
Measuring time taken to modify and filter a list of numbers using different methods in python.
# measure time taken to modify and filter a list of numbers using different methods.
# http://stackoverflow.com/questions/1685221/accurately-measure-time-python-function-takes
from __future__ import with_statement
import time
from collections import defaultdict
class Timer(object):
def __enter__(self):
self.__start = time.time()
@theorm
theorm / fabfile.py
Created May 14, 2012 01:55
fabfile with tasks to deploy app on google appengine
from fabric.api import *
from fabric.colors import green, red
import os, sys
packages_dir = 'packages'
tmp_dir = 'tmp'
dependencies_filename = 'dependencies.zip'
def check_requirement(command,install_text):
failed = False
@theorm
theorm / gist:2699598
Created May 15, 2012 06:36
My OSX 1.6 fails to provide correct architecture and it confuses GCC. Here are the flags to use
sudo ARCHFLAGS="-arch i386 -arch x86_64" pip install --force-reinstall -I http_parser
@theorm
theorm / debug.js
Created October 8, 2012 06:51
StopWatch time measurement class for profiling javascript apps.
/*
StopWatch. A time profiler.
Use:
var stopwatch = StopWatch("My Stop Watch");
// ... do something here
stopwatch.lap("step1");
// ... do something more
stopwatch.lap("step2").print();
// Console log at this point:
// [SW "My Stop Watch"]: step1 = 12 ms, step2 = 20 ms
class Location(Document):
structure = {
"ll" : validate_coordinates,
"street" : ...
...
}
class Venue(Document):
structure = {
"location" : Location.validate,
from mongokit import *
class MyDoc(Document):
structure = {
"bla" : {
"foo" : unicode,
"bar" : int,
},
"spam" : [],
}

Installing a Gem on Heroku from a Private GitHub Repo

Sometimes you want to use a gem on Heroku that is in a private repository on GitHub.

Using git over http you can authenticate to GitHub using basic authentication. However, we don't want to embed usernames and passwords in Gemfiles. Instead, we can use authentication tokens.

  1. Get an OAuth Token from GitHub

First you will need to get an OAuth Token from GitHub using your own username and "note"

{
'metrics' : {
'2012' : {
'm' : {
'01' : {
'd' : {
'01' : {
'h' : {
'00' : {
'm1' : 1,