This file contains hidden or 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
// The Template Loader. Used to asynchronously load templates located in separate .html files | |
window.templateLoader = { | |
load: function(views, callback) { | |
var deferreds = []; | |
$.each(views, function(index, view) { | |
if (window[view]) { | |
deferreds.push($.get('tpl/' + view + '.html', function(data) { |
This file contains hidden or 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
// paste into console and get a list of the amazon | |
var urls = {}; | |
[].slice.apply($$('a')).map(function(a) { | |
return a.href | |
}).filter(function(u) { | |
return /amazon.com/.test(u) | |
}).map(function(u) { | |
return u.split('?')[0] | |
}).forEach(function(u) { |
This file contains hidden or 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 shuffle = function(v){ | |
for(var j, x, i = v.length; i; j = parseInt(Math.random() * i), x = v[--i], v[i] = v[j], v[j] = x); | |
return v; | |
}; |
This file contains hidden or 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
/// RECURSIVE | |
var fib = function (n) { | |
return n < 2 ? n : fib(n-1) + fib(n-2); | |
} | |
/// MEMOIZED | |
var memo = [0,1]; | |
var fib = function(n) { |
This file contains hidden or 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
#!/bin/sh | |
echo "MySQL User:"; | |
read MYSQLUSER; | |
echo "MySQL Pass:"; | |
read MYSQLPASS; | |
for I in $(mysql -h localhost -u $MYSQLUSER --password=$MYSQLPASS -e 'show databases' -s --skip-column-names); | |
do mysqldump -u $MYSQLUSER -h localhost --password=$MYSQLPASS $I | gzip > "$I.sql.gz"; | |
done |
This file contains hidden or 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
//extend native. bad? | |
Function.prototype.curry = function () { | |
var aslice = [].slice, _method = this, args = aslice.call(arguments); | |
if (!args.length) return _method; | |
return function () { | |
var a = args.concat(aslice.call(arguments)); | |
return _method.apply(this, a); | |
} |
This file contains hidden or 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 timeTil(date) { | |
var t = [ | |
[60 * 60 * 24 * 7 * 4 * 12, 'year'], | |
[60 * 60 * 24 * 7 * 4, 'month'], | |
[60 * 60 * 24 * 7, 'week'], | |
[60 * 60 * 24, 'day'], | |
[60 * 60, 'hour'], | |
[60, 'minute'], | |
[1, 'second'] | |
], |
This file contains hidden or 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
_=(typeof{});$=[];__=(typeof+$);alert((''+!!+$)[+$]+(''+$[+!+$])[+$]+__[+$]+_[+!+$+!+$+!+$+!+$]+_[+!+$+!+$+!+$+!+$+!+$]+(typeof'')[+!+$+!+$+!+$]+_[+$]+__[+$]) |
This file contains hidden or 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 Class = function () { | |
this.a = 'abc'; | |
this.b = 666; | |
this.c = function () { | |
return 3 * 3; | |
}; | |
} | |
Class.prototype.d = function () { | |
return 2 + 2; |
This file contains hidden or 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
memo = [0, 1] | |
def memofib(n): | |
if n >= len(memo): | |
i = len(memo) | |
while i <= n: | |
memo.append(memo[i-1] + memo[i-2]) | |
i += 1 | |
return memo[n] |
OlderNewer