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
// Load the Facebook API | |
window.fbAsyncInit = function() { | |
FB.init({ | |
appId : 'YOUR_APP_ID', | |
status : true, // check login status | |
cookie : true, // enable cookies to allow the server to access the session | |
xfbml : true // parse XFBML | |
}); | |
// Browser-specific hacks to make FB Connect more reliable |
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 clientIP(req) | |
{ | |
if (config.using_proxy) { | |
var forwardedFor = req.headers['x-forwarded-for']; | |
return forwardedFor ? forwardedFor : req.connection.remoteAddress; | |
} | |
return req.connection.remoteAddress; | |
} |
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 status = res ? res.statusCode : (err && err.length === 3) ? err : '-1'; |
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
app.configure(function() { | |
// Setup a socket error handler for all requests | |
app.use(socketErrorHandler); | |
// Catch any attempts to call res.send multiple times for the same client | |
app.use(onlyOneResponse); | |
}); | |
function socketErrorHandler(req, res, next) { | |
// Check if this socket is being reused and already has an error handler | |
if (!req.socket.listeners('error').length) { |
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
/* | |
* base64.js: An extremely simple implementation of base64 encoding / decoding using node.js Buffers | |
* | |
* (C) 2010, Nodejitsu Inc. | |
* (C) 2011, Cull TV, Inc. | |
* | |
*/ | |
var base64 = exports; |
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
LockedStore = function() { }; | |
LockedStore.prototype = { | |
table: [], | |
/** | |
* index - Index of the value to check out. | |
* callback(value, fn) - Fired when a lock is acquired on the requested value. First | |
* parameter is the requested value, second parameter is a callback that must be | |
* fired to check the value back in and expects the new value as a single parameter. |
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
/* Add this somewhere after FB.init() and before any calls to FB.getLoginStatus() */ | |
// Add a timeout to FB.getLoginStatus() | |
var FB_STATUS_TIMEOUT = 1000 * 30; | |
var origGetLoginStatus = FB.getLoginStatus; | |
FB.getLoginStatus = function(callback, force) { | |
// Start a timer | |
var timedOut = false; | |
var timeout = setTimeout(function() { | |
timedOut = true; |
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
Cache = function(cleanupIntervalMS) { | |
if (typeof cleanupIntervalMS === 'undefined') | |
cleanupIntervalMS = 1000 * 60 * 5; // 5 minute default interval | |
if (cleanupIntervalMS) | |
this.cleanupTimer = setInterval(this.cleanup, cleanupIntervalMS); | |
}; | |
Cache.prototype = { | |
store: {}, |
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 fs = require('fs'); | |
var input = fs.createReadStream('input.txt'); | |
var output = fs.createWriteStream('output.txt'); | |
var buffer = ''; | |
input.on('data', function(data) { | |
buffer += data; | |
var index = buffer.indexOf('\n'); | |
while (index > -1) { |
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 spawn = require('child_process').spawn; | |
exports.getPcmData = function(filename, sampleCallback, endCallback) { | |
var outputStr = ''; | |
var oddByte = null; | |
var channel = 0; | |
var gotData = false; | |
// Extract signed 16-bit little endian PCM data with ffmpeg and pipe to STDOUT | |
var ffmpeg = spawn('ffmpeg', ['-i',filename,'-f','s16le','-ac','2', |
OlderNewer