Skip to content

Instantly share code, notes, and snippets.

// DocumentCloud workspace hotkeys. To tell if a key is currently being pressed,
// just ask: `dc.app.hotkeys.control`
dc.app.hotkeys = {
KEYS: {
'16': 'shift',
'17': 'control',
'91': 'command',
'93': 'command',
'224': 'command'
@ericflo
ericflo / redis_sessions.py
Created November 9, 2010 06:41
A Redis-based Django session store.
import simplejson
from django.contrib.sessions.backends.base import SessionBase, CreateError
from django_ext.redis_helper import get_redis
class SessionStore(SessionBase):
"""
A Redis-based session store.
// Main controller for the journalist workspace. Orchestrates subviews.
dc.controllers.Workspace = Backbone.Controller.extend({
routes : {
'help/:page': 'help',
'help': 'help'
},
// Initializes the workspace, binding it to <body>.
initialize : function() {
// Provide top-level namespaces for our javascript.
(function() {
window.dc = {};
dc.controllers = {};
dc.model = {};
dc.app = {};
dc.ui = {};
})();
@creationix
creationix / chatServer.js
Created November 19, 2010 20:47
A simple TCP based chat server written in node.js
// Load the TCP Library
net = require('net');
// Keep track of the chat clients
var clients = [];
// Start a TCP Server
net.createServer(function (socket) {
// Identify this client
@klipstein
klipstein / b64field.py
Created November 22, 2010 12:25
Base64 file handling for django-tastypie
import base64
import os
from tastypie.fields import FileField
from django.core.files.uploadedfile import SimpleUploadedFile
class Base64FileField(FileField):
"""
A django-tastypie field for handling file-uploads through raw post data.
It uses base64 for en-/decoding the contents of the file.
Usage:
.
|____.DS_Store
|____admin
| |____accounts.js
| |____admin.js
|____app
| |____downloader.js
| |____editor.js
| |____hotkeys.js
| |____preferences.js
@cowboy
cowboy / delegate-refactor.js
Created April 1, 2011 11:26
jQuery: e.type + binding to multiple events at the same time FTW
// BEFORE
// http://jsfiddle.net/markcoleman/ffBcU/11/
var currentColor = "white";
var hold = false;
$(".canvas")
.delegate(".pixel", "mouseover", function() {
$(this).css("background-color", currentColor);
})
@schacon
schacon / .gitconfig
Created April 11, 2011 21:43
insteadOf example
[url "https://github.com/"]
insteadOf = "gh:"
@aseemk
aseemk / app.js
Created April 19, 2011 11:12
Express sample app using Eco templating engine.
var express = require('express');
var app = express.createServer();
app.configure(function () {
app.use(app.router);
});
app.set('views', __dirname + '/views');
app.set('view engine', 'html');
app.register('.html', require('eco'));