# This example does an AJAX lookup and is in CoffeeScript
$('.typeahead').typeahead(
# source can be a function
source: (typeahead, query) ->
# this function receives the typeahead object and the query string
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
<a href="javascript:(function(){var head=document.getElementsByTagName('head')[0];var e=document.createElement('script');e.src='//crypto-js.googlecode.com/svn/tags/3.0.2/build/rollups/sha256.js';head.appendChild(e);e=document.createElement('style');e.innerHTML='.picpass-active {background:#aaffaa !important;z-index:10000}';head.appendChild(e);e=document.createElement('script');e.src='//ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js';head.appendChild(e);var inter=setInterval(check,100);var runs=0;function check(){if(typeof jQuery!='undefined'){run();clearInterval(inter);}if(++runs>60){clearInterval(inter);}}function run(){var dropzone=$('input[type=password]');dropzone.css({'zIndex':10000});var dropped=null;var content=null;$('body').on('dragstart',function(e){if(e.srcElement.src){content=e.srcElement.src;}});dropzone.on('dragover',function(e){e.preventDefault();$(this).addClass('picpass-active');});dropzone.on('dragleave',function(e){e.preventDefault();$(this).removeClass('picpass-active');});dropzo |
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
function round(n) { | |
return Math.round(n*100) / 100; | |
} | |
// Represents an edge from source to sink with capacity | |
var Edge = function(source, sink, capacity) { | |
this.source = source; | |
this.sink = sink; | |
this.capacity = capacity; | |
}; |
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
/* | |
I've wrapped Makoto Matsumoto and Takuji Nishimura's code in a namespace | |
so it's better encapsulated. Now you can have multiple random number generators | |
and they won't stomp all over eachother's state. | |
If you want to use this as a substitute for Math.random(), use the random() | |
method like so: | |
var m = new MersenneTwister(); |
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 MersenneTwister = function(seed) { | |
// Holds the state of the register | |
this.state = [seed]; | |
this.index = 0; | |
for(var i=1;i<=623;i++) { | |
var s = this.state[i-1] ^ (this.state[i-1] >>> 30); | |
this.state[i] = (((((s & 0xffff0000) >>> 16) * 1812433253) << 16) + (s & 0x0000ffff) * 1812433253) + i; | |
this.state[i] >>>= 0; | |
} |
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
function Djikstra(graph, source) { | |
this.infinity = 1.7976931348623157E+10308; | |
this.dist = {}; | |
this.previous = {}; | |
this.queue = []; | |
// Get the smallest distance in the queue | |
this.findSmallest = function() { | |
var min = infinity; | |
var smallest = null; |
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 Graph = function() { | |
this.nodes = {}; | |
this.edges = {}; | |
this.addNode = function(id, data) { | |
this.nodes[id] = data; | |
}; | |
this.getNode = function(id) { | |
return this.nodes[id] || null; |
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 men = { | |
'Joe': ['Mary','Jane','Dorothy','Susan'], | |
'Tim': ['Jane','Dorothy','Mary','Susan'], | |
'Jack': ['Dorothy','Jane','Susan','Mary'], | |
'Matt': ['Mary','Jane','Susan','Dorothy'] | |
}; | |
var women = { | |
'Mary': ['Tim','Joe','Jack','Matt'], | |
'Jane': ['Matt','Jack','Joe','Tim'], |
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
String.prototype.replaceAt=function(index, char) { | |
return this.substr(0, index) + char + this.substr(index+char.length); | |
}; | |
var Point = function(x,y, parent) { | |
this.x = x; | |
this.y = y; | |
this.cost = 0; | |
this.moveCost = 0; | |
this.goalCost = 0; | |
this.parent = parent === undefined ? null : parent; |
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
function primes(from, to) { | |
var arr = []; | |
for(var i=from;i<=to;i++) arr.push(i); | |
for(var check=0;check<to/2;check++) { | |
for(var j=check+arr[check]; j<=to,j<=arr.length-1; j+=arr[check]) { | |
arr.splice(j--,1); | |
} | |
} | |
return arr; | |
} |