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
# From: http://github.com/andrewvc/dripdrop/blob/master/lib/dripdrop/node.rb | |
# Defines a new route. Routes are the recommended way to instantiate | |
# handlers. For example: | |
# | |
# route :stats_pub, :zmq_publish, 'tcp://127.0.0.1:2200', :bind | |
# route :stats_sub, :zmq_subscribe, stats_pub.address, :connect | |
def route(name,handler_type,*handler_args) | |
handler = self.send(handler_type, *handler_args) | |
@routing[name] = handler |
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
for (var logLevel in this.levelList) { | |
this[logLevel] = (function(logLevel) { | |
return function (message,callback) { | |
this.logAtLevel(message, this.levelList[logLevel], callback); | |
} | |
})(logLevel); | |
} | |
}); |
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 'rubygems' | |
require 'ffi-rzmq' | |
ctx = ZMQ::Context.new 1 | |
sock = ctx.socket(ZMQ::SUB) | |
sock.setsockopt(ZMQ::SUBSCRIBE, '') | |
pub = ctx.socket(ZMQ::PUB) | |
pub.connect 'tcp://127.0.0.1:2200' |
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
# Rails.root/config.ru | |
require "config/environment" | |
require 'resque/server' | |
use Rails::Rack::LogTailer | |
use Rails::Rack::Static | |
# Set the AUTH env variable to your basic auth password to protect Resque. | |
AUTH_PASSWORD = ENV['AUTH'] | |
if AUTH_PASSWORD |
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
#!/usr/bin/env ruby | |
exec *(%w(bundle exec unicorn config.ru -p 3000) + ARGV) | |
#Yeah, I know, I should probably use /bin/sh, but I don't need that extra 10ms in speed... |
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
server { | |
listen 80; | |
server_name dev.cocodot.com; | |
access_log /var/log/dev.cocodot.com | |
location ~* ^/(stylesheets|javascripts|images)/.*$ { | |
root /vagrant/public; | |
} | |
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 'rubygems' | |
require 'ffi-rzmq' | |
require 'eventmachine' | |
module EM::ZMQ | |
def initialize(socket) | |
@socket = socket |
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
//In public/javascripts/bike_shed.js | |
function($) { | |
function adjustHandlerbar() { //Private function | |
}; | |
//coco is the global namespace, all functions should reside in a camel cased version of the JS filename | |
coco.bikeShed = { | |
cleanBike: function() { //Public 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
#See which number the fork(2) system call actually is | |
$ grep fork /usr/include/asm/unistd_64.h | |
#define __NR_fork 57 | |
__SYSCALL(__NR_fork, stub_fork) | |
#define __NR_vfork 58 | |
__SYSCALL(__NR_vfork, stub_vfork) | |
#strace shows us that fork is indeed not seen anywhere, just as man 2 fork said | |
$ strace -f ruby -e 'fork' 2>&1 | egrep -A1 '^(fork|clone)' | |
clone(Process 4281 attached |
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
--------------------------------------------------------- | |
| Client(Browser) | | |
--------------------------------------------------------- | |
| | | |
websocket control raw tcp stream(EM::bind_connect) | |
| | | |
---------------------------------------------------------- | |
| ClientManager(DripDrop) | | |
---------------------------------------------------------- |