This file contains hidden or 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 program is free software. It comes without any warranty, to | |
// the extent permitted by applicable law. You can redistribute it | |
// and/or modify it under the terms of the Do What The Fuck You Want | |
// To Public License, Version 2, as published by Sam Hocevar. See | |
// http://sam.zoy.org/wtfpl/COPYING for more details. | |
var sys = require('sys') | |
, opts = require('opts') | |
, ws = require('websocket-server') | |
, redis = require('redis') |
This file contains hidden or 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 program is free software. It comes without any warranty, to | |
# the extent permitted by applicable law. You can redistribute it | |
# and/or modify it under the terms of the Do What The Fuck You Want | |
# To Public License, Version 2, as published by Sam Hocevar. See | |
# http://sam.zoy.org/wtfpl/COPYING for more details. | |
sys = require 'sys' | |
opts = require 'opts' | |
ws = require 'websocket-server' | |
redis = require 'redis' | |
server = ws.createServer() |
This file contains hidden or 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 sys = require('sys'); | |
var Sequelize = require('sequelize'); | |
var sequelize = new Sequelize('sequelize_test', 'root', 'password'); | |
var Article = sequelize.define('Article', { | |
title: Sequelize.STRING, | |
body: Sequelize.TEXT | |
}); | |
Article.sync(); |
This file contains hidden or 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
set :shared_children, %w(log pids sock node_modules) | |
set :node_path, "/usr/local/bin" | |
set :node_app, "app.js" | |
namespace :deploy do | |
task :finalize_update, :except => { :no_release => true } do | |
run "chmod -R g+w #{latest_release}" if fetch(:group_writable, true) | |
run "rm -rf #{latest_release}/log #{latest_release}/node_modules #{latest_release}/tmp" | |
run "mkdir -p #{latest_release}/tmp" |
This file contains hidden or 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 Dictionary = function() { | |
this.keys = {}; | |
this.length = 0; | |
this.defaultValue = null; | |
}; | |
Dictionary.prototype.store = function(key, value) { | |
this.keys[key] = value; | |
this.length++; | |
}; |
This file contains hidden or 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 vows = require('vows'); | |
var assert = require('assert'); | |
var events = require('events'); | |
var WebSocketClient = require('websocket').client; | |
vows.describe('WebSocket-Node Client Connection Test').addBatch({ | |
'HTTP': { | |
topic: function() { | |
var promise = new (events.EventEmitter); |
This file contains hidden or 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
vows = require('vows') | |
assert = require('assert') | |
events = require('events') | |
Hoge = require('hoge') | |
vows | |
.describe('Hoge') | |
.addBatch | |
'when using foo method': |
This file contains hidden or 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
= form_for @user do |f| | |
= f.fields_for :profile, @user.profile || Profile.new do |p| | |
.field | |
= p.label :nickname | |
= p.text_field :nickname |
This file contains hidden or 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
item1 = {} | |
item2 = {} | |
item3 = {} | |
array = [item1, item2, item3] | |
array.splice array.indexOf(item2), 1 |
This file contains hidden or 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
Array.prototype.__defineGetter__('first', function() { | |
return this[0]; | |
}); | |
Array.prototype.__defineGetter__('last', function() { | |
return this[this.length - 1]; | |
}); | |
Array.prototype.__defineSetter__('first', function(val) { | |
this[0] = val; |