Skip to content

Instantly share code, notes, and snippets.

tmzt

Block or report user

Report or block tmzt

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@tmzt
tmzt / console-dir.js
Created Sep 12, 2012 — forked from ongaeshi/console-dir.js
console.dir の Add-on SDK実装
View console-dir.js
// @file console-dir.js
// @brief
// @author ongaeshi
// @date 2011/06/02
//
// --------------------------------------
// console.dir({a: 1, b: 2, c: 3});
// =>
// info:
// a: 1
@tmzt
tmzt / game.js
Created Jul 29, 2011
part of node_modules/game.js
View game.js
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);
View .js
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;
@tmzt
tmzt / gist:974100
Created May 16, 2011
sendevents.js
View gist:974100
/* polling */
app.get('/apis/v0/events.json', getevents);
var clients = {};
var queues = {};
var shorturlsessionid = {};
function getevents(req, res) {
View jsonPathWrite.js
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];
View gist:906150
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) {
View gist:889096
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) {
View gist:851925
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)
View app.js
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 */
View app.js
require.paths.unshift(__dirname + '/lib');
/* ... */
var base60 = require('NewBase60/NewBase60.js');
You can’t perform that action at this time.