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
YUI('lang', function (Y) { | |
YAP.toQueryString = function (obj, name) { | |
switch (Y.Lang.type(obj)) { | |
case 'undefined': | |
case 'null': | |
return name ? encodeURIComponent(name) + '=' : ''; | |
case 'boolean': obj = +obj; // intentional fallthrough | |
case 'number': | |
case '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
<!DOCTYPE html> | |
<html> | |
<head> | |
<script> | |
// 238! | |
function L(U,C){var d=document,f='firstChild',r='readyState',h=d.documentElement[f],s=d.createElement('script'),m=s[r]?'onreadystatechange':0;s.src=U;s[m||'onload']=function(){if(!m||/ded|te/.test(s[r]))s[m]=0,C()}h.insertBefore(s,h[f])} | |
// async loading of javascript files, starting asap. | |
L("http://example.com/example.js",function () { | |
doSomething(); |
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
// more lines, ever-so-slightly faster search, though. | |
function checkValidMove (xo, pos, state) { | |
// invalid move. | |
if (state[pos[0]][pos[1]] !== '') return false; | |
state[pos[0]][pos[1]] = xo; | |
// check row | |
for (var i = 0, col = 0; i < 3; i ++) if (state[pos[0]][i] === xo) col ++; | |
if (col === 3) return "a winner is you"; |
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
# Node Package Manager | |
npm [npm-options] command [command options] | |
install <package> | |
[-b (stable, edge, nightly) | --branch] | |
[-f | --force] | |
[-v | --version] | |
remove <package> | |
[-f | --force] |
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
this.names = { | |
user: "x" | |
,host: "x" | |
,server: "x" | |
,real: "x" | |
}; | |
// fuck IE | |
this.names = { | |
user: "x", |
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 acquireaDependency () { | |
acquire('aDependency').addCallback(function(){ | |
p.emitSuccess() | |
}); | |
return p; | |
}; | |
function acquireanotherDependency () { | |
var p = new Promise; | |
acquireaDependency().addCallback(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
multipart.parse(req).addCallback(function(parts) { | |
debug.log('multipart'); | |
resp.sendHeader(200, { | |
'Content-Type' : 'text/html', | |
'Set-Cookie' : session.setCookieHeader() | |
}); | |
resp.sendBody(html); | |
resp.finish(); | |
}); |
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
/(B)--------------- | |
--(A)--* /(D)--| \ | |
\(C)---* --(G)--(H) | |
\(E)--(F)--/ | |
chain | |
(A) | |
(route | |
("/B", B) // single link, then fallthrough, don't need a chain | |
("/C", chain |
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
// EXAMPLE 1: async response | |
// PSGI equivalent | |
var app = function(env) { | |
return function(respond) { | |
// do some event stuff | |
setTimeout(function() { | |
respond({ status : code, headers : headers, body : body }); | |
}, 1000); | |
} |
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
Get(/^\/myroute/, function(request) { | |
... | |
}); | |
Post(/^\/myroute/, function(request) { | |
... | |
}); | |
Head(/^\/myroute/, function(request) { | |
... |
OlderNewer