Skip to content

Instantly share code, notes, and snippets.

@gthomas
gthomas / gist:3452673
Created August 24, 2012 16:37
Python HMAC md5
#!/usr/bin/env python
from hashlib import md5
trans_5C = "".join(chr(x ^ 0x5c) for x in xrange(256))
trans_36 = "".join(chr(x ^ 0x36) for x in xrange(256))
blocksize = md5().block_size
def hmac_md5(key, msg):
if len(key) > blocksize:
key = md5(key).digest()
key += chr(0) * (blocksize - len(key))
$(function () {
forge.logging.log("binding");
$(".take-photo").bind("touchend", photo_button_click);
});
function photo_button_click() {
forge.file.getImage({}, function(file){
forge.file.URL(file,
function(url){
$("#image").html("<img src='"+url+"'></img>")
@gthomas
gthomas / gist:3152230
Created July 20, 2012 17:52
WEb apps with Erlang and Cowboy

Efficient Web Applications with Erlang and Cowboy

The Web Yesterday

Ugly, static, non-interactive.

Today

Tons of dynamic content, messaging, real time API and content for the user.

@gthomas
gthomas / gist:3152195
Created July 20, 2012 17:47
Django Doesn't Scale

Django doesn't scale and what you can do about it

Django doesn't scale Frameworks don't scale -- they're general purpose.

Development speed

Frameworks remove initial learning curve -- can get an application started in a day but you don't know what's going on. Productivity falls, and ramps back up.

Storm: Distributed and Fault-toleration realtime computing

https://github.com/nathanmarz/storm/

Seems like far more flexible, reliable solution than Celery and the ilk Define topologies that manage jobs, their assignment to workers, aggregation of return values. Highly parallel, reliable etc..

  • Motivation behind storm
  • Intro to Storm
@gthomas
gthomas / mbahc.md
Created July 20, 2012 17:37
Mind blowing apps in HTML5 and Canvas

Mind Blowing Apps in HTML5 and Canvas

-Overview of the Canvas API -Demos

Canvas API

Canvas

{
"objects": [
{
"url": "http:\/\/www.sugarmedia.com\/nyccookbook\/pizza.html"
}
],
"action_link": {
"type": "nyccookbook:save"
},
"actions": [
@gthomas
gthomas / gist:2654567
Created May 10, 2012 17:23
Post to Tumblr
from tumblr import Api as Tumblr
#your tumblr credentials go here
BLOG = 'sweetpictures.tumblr.com'
#email address or username should work here
USER = '[email protected]'
PASSWORD = 'mysecurepassword'
#basically, log in to Tumblr
api = Tumblr(BLOG, USER, PASSWORD)
@gthomas
gthomas / gist:2152752
Created March 21, 2012 20:52
eager chords
diff --git a/celery/app/registry.py b/celery/app/registry.py
index 43d65f6..2789547 100644
--- a/celery/app/registry.py
+++ b/celery/app/registry.py
@@ -61,7 +61,7 @@ class TaskRegistry(dict):
def filter_types(self, type):
return dict((name, task) for name, task in self.iteritems()
- if task.type == type)
+ if getattr(task, 'type', "regular") == type)
(ns shouter.views.layout
(:use [hiccup.core :only [html]]
[hiccup.page-helpers :only [doctype include-css]]))
(defn common [title & body]
(html
(doctype :html5)
[:head
[:meta {:charset "utf-8"}]
[:meta {:http-equiv "X-UA-Compatible" :content "IE=edge,chrome=1"}]