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 express = require('express') | |
, memoize = require('memoize') | |
, cache = require('chaos')('cache') | |
, Beatport = require('beatport') | |
memoize.set('debug', true) | |
var bp = memoize('beatport-mem', memoize('beatport', Beatport({ perPage: 10, sortBy: 'releaseDate desc' }), { | |
expire: 1000 * 60 * 60 * 24 | |
, store: cache |
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 readline = require('readline') | |
, rl = readline.createInterface(process.stdin, process.stdout) | |
function prompt (str, cb) { | |
rl.setPrompt(str) | |
rl.prompt() | |
rl.once('line', cb) | |
} | |
prompt('> ', function (str) { |
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 http = require('http') | |
, httpProxy = require('http-proxy'); | |
httpProxy.createServer(function (req, res, proxy) { | |
// | |
// Put your custom server logic here | |
// | |
proxy.proxyRequest(req, res, { | |
host: 'localhost', | |
port: 9000 |
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 dnode = require('dnode') | |
, express = require('express') | |
, app = express.createServer() | |
app.use(express.static(__dirname)) | |
app.listen(8080) | |
console.log('http://localhost:8080/') | |
var server = dnode(function(remote, conn) { | |
this.click = 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
$(function() { | |
var $body = $('body') | |
, $book = $('#book') | |
;(function animate_background() { | |
$body.animate({ backgroundColor: "#abcdef" }, 1000, function(){ | |
$body.animate({ backgroundColor: "#000" }, 1000, animate_background) | |
}) | |
}()) |
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
$(document).ready(function() { | |
var $book = $('#book') | |
// wrapping the function in a closure | |
;(function display_icon() { | |
$book.hide(1000, function() { | |
$book.show(1000, function() { | |
setTimeout(function() { | |
display_icon(); | |
}, 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
var express = require('express') | |
, app = express.createServer() | |
app.use(express.cookieParser()) | |
app.use(express.session({ secret: 'foo' })) | |
app.use(function(req, res, next) { | |
console.log(req.url, typeof req.session) | |
next() | |
}) |
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() { | |
var parse = JSON.parse | |
JSON.parse = function(s, f) { | |
var ISO = /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}(?:\.\d*)?)Z$/ | |
return parse(s, f ? f : function(key, value) { | |
return typeof value === 'string' | |
? ISO.exec(value) && new Date(value) || value | |
: value | |
}) | |
} |
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 dnode = require('dnode') | |
dnode({ | |
bar: function(cb) { | |
cb({ | |
foo: 'bar' | |
, date: new Date() | |
}) |
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 locals = {} | |
var err | |
do { | |
err = undefined | |
try { | |
with(locals) { | |
foo | |
bar |