Skip to content

Instantly share code, notes, and snippets.

@hetsch
hetsch / router.js
Created March 14, 2012 09:20
Backbone named parameter routing
Components.Router = Backbone.Router.extend({
// @todo also support unnamed params
// 'page/edit/(?<language>[a-z]{2})/(?<entityId>[a-z0-9]{24})/(.*)'
route: function(route, name, callback) {
Backbone.history || (Backbone.history = new Backbone.History);
if (!XRegExp.isRegExp(route)) route = this._routeToRegExp(route);
if (!callback) callback = this[name];
Backbone.history.route(route, _.bind(function(fragment) {
var routeParams = XRegExp.exec(fragment, route),
@hetsch
hetsch / multilingual.py
Created January 11, 2012 09:51
Multilingual model for appengine ndb
import functools
import unittest2
import os
from google.appengine.api import datastore_errors
from google.appengine.ext.ndb import model
from google.appengine.ext.ndb import tasklets
from google.appengine.ext import testbed
#---------------------------------------