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
// @file console-dir.js | |
// @brief | |
// @author ongaeshi | |
// @date 2011/06/02 | |
// | |
// -------------------------------------- | |
// console.dir({a: 1, b: 2, c: 3}); | |
// => | |
// info: | |
// a: 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 WebsocketObserver = function(options) { _.extend(this,options); this.initialize(); }; | |
_.extend(WebsocketObserver.prototype, { | |
initialize: function() { | |
var observer = this; | |
if (observer.socket != null && observer.game != null) { | |
var game = observer.game; | |
game.websocketObserver = observer; | |
if (game.buildOrderObserver != null) { | |
var buildOrderObserver = game.buildOrderObserver; | |
console.log('watching buildOrderObserver: ', buildOrderObserver); |
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 server = ws.createServer(); | |
server.on('connection', function(conn) { | |
conn.on('message', function(msg) { | |
console.log('client msg: ', msg); | |
try { | |
var data = JSON.parse(msg); | |
} catch(ex) { var data = null; }; | |
if (data != null) { | |
var sessionID = data.sessionID; | |
var user_id = data.user_id; |
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
/* polling */ | |
app.get('/apis/v0/events.json', getevents); | |
var clients = {}; | |
var queues = {}; | |
var shorturlsessionid = {}; | |
function getevents(req, res) { |
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 createPath(data, path) { | |
var object = data; | |
var existing = findExisting(data, path); | |
console.log('existing: ', existing); | |
if (existing != '') { | |
object = data; | |
var value = jsonPath(data, existing); | |
if (typeof(value) != 'boolean') { | |
if (typeof(value.length) != 'undefined') value = value[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
app.get('/apis/v0/sectiondata/:id.json', function(req, res) { | |
var idx = parseInt(req.params.id); | |
var user_id = req.session.user_id || null; | |
getprivate(req, res, function(profile) { | |
if (profile != null) user_id = profile._id; | |
if (user_id != null) { | |
SectionData.findOne({ownerid: user_id, idx: idx}, function(err, doc) { | |
console.log('doc: ', doc); | |
if (err == 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
Seq() | |
.seq(function() { | |
QRCode.toDataURL(clans['mutagens'].code, function(error, datauri) { | |
console.log(datauri); | |
clans['mutagens'].qrdatauri = (!error) ? datauri : ''; | |
this(); | |
}); | |
}) | |
.seq(function() { | |
QRCode.toDataURL(clans['normals'].code, function(error, datauri) { |
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
127.0.0.1 - - [Wed, 02 Mar 2011 22:33:18 GMT] "GET /timothy HTTP/1.0" 500 - "" "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.10) Gecko/20100922 Ubuntu/10.10 (maverick) Firefox/3.6.10" | |
Error: Can't use mutable header APIs after sent. | |
at ServerResponse.getHeader (http.js:521:11) | |
at ServerResponse.header (/srv/home/jobitr/development/node_modules/express/lib/response.js:224:17) | |
at ServerResponse.send (/srv/home/jobitr/development/node_modules/express/lib/response.js:64:17) | |
at ServerResponse.render (/srv/home/jobitr/development/node_modules/express/lib/view.js:299:10) | |
at ServerResponse.render (/srv/home/jobitr/development/node_modules/express/lib/view.js:293:10) | |
at /srv/home/jobitr/development/app.js:560:10 | |
at /srv/home/jobitr/development/lib/UserProvider.js:32:10 | |
at [object Object].<anonymous> (/srv/home/jobitr/development/node_modules/mongodb/lib/mongodb/collection.js:447:35) |
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
module.exports = function(path, callback) { | |
/* ... */ | |
models = require('models'); | |
//models.UnreadClippings.count = models.UnreadClippings.count.bind(models.UnreadClippings); | |
models.UnreadClippings.incr = models.UnreadClippings.incr.bind(models.UnreadClippings); | |
/* express routes */ |
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
require.paths.unshift(__dirname + '/lib'); | |
/* ... */ | |
var base60 = require('NewBase60/NewBase60.js'); | |
NewerOlder