Skip to content

Instantly share code, notes, and snippets.

View keithnorm's full-sized avatar

Keith Norman keithnorm

View GitHub Profile
import math
import itertools
def length(x, y):
dx = x[0] - y[0]
dy = x[1] - y[1]
return math.sqrt(dx*dx + dy*dy)
def solve_tsp_dynamic(points):
#calc all lengths
@keithnorm
keithnorm / anonymous.js
Created February 28, 2012 23:56 — forked from maml/anonymous.js
jquery anonymous pattern?
(function() {
var ghost = 'face';
function blah() {};
$(function() {
blah();
});
}).call(this);
@keithnorm
keithnorm / backbone.model.es5properties.js
Created October 17, 2011 06:53 — forked from dandean/backbone.model.es5properties.js
Monkey patch `Backbone.Model.extend()` with ES5 getters/setters for each attribute defined in the defaults.
/**
* Monkey patch `Backbone.Model.extend()` with ES5 getters/setters for each
* attribute defined in the defaults. Gives you the added bonus of being
* to pass your backbone models directly to your Mustache.js views.
*
* Example:
*
* var User = Backbone.Model.extend({
* defaults: {
* username: undefined,