This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Build a line from unsorted points, | |
// in a way that the length of the line is minimal. | |
var pointsToLine = (function() { | |
// distance between two points | |
function dist(p1, p2) { | |
return Math.sqrt(Math.pow(p1[0] - p2[0], 2) + Math.pow(p1[1] - p2[1], 2)); | |
} | |
// find insertion index | |
function findIdx(line, point) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"_id": "_design/myapp", | |
"rewrites": <%= read 'rewrites.json' %>, | |
"updates": { | |
"nash": <%=h read 'updates/entry.js' %> | |
}, | |
"validate_doc_update": <%=h read 'validate.js' %>, | |
"views": { | |
"nashs": { | |
"map": <%=h read 'couchdb-views/entries/map.js' %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var oldSet = Backbone.Model.prototype.set; | |
_.extend(Backbone.Model.prototype, { | |
set: function(attrs, options) { | |
if ('_id' in attrs) this.id = attrs._id; | |
oldSet.apply(this, [attrs, options]); | |
return this; | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html lang=en> | |
<head> | |
<meta charset=utf-8> | |
<title>Backbone Event Delegation Tests</title> | |
<script src="http://documentcloud.github.com/backbone/test/vendor/jquery-1.4.2.js"></script> | |
<script> | |
$(function() { | |
var main = $('#main'), | |
el = $('<p>Welcome <a href="#">Please click me</a></p>'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html lang=en> | |
<head> | |
<meta charset=utf-8> | |
<title>Backbone Event Delegation Tests</title> | |
<script src="http://documentcloud.github.com/backbone/test/vendor/jquery-1.4.2.js"></script> | |
<script src="http://documentcloud.github.com/backbone/test/vendor/underscore-1.1.3.js"></script> | |
<script src="http://documentcloud.github.com/backbone/backbone.js"></script> | |
<script> | |
$(function() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Domain < ActiveRecord::Base | |
validates :name, :presence => true, :uniqueness => true | |
validates :routable, :presence => true | |
belongs_to :routable, :polymorphic => true | |
end |
NewerOlder