Skip to content

Instantly share code, notes, and snippets.

# Author: Pieter Noordhuis
# Description: Simple demo to showcase Redis PubSub with EventMachine
#
# Requirements:
# - rubygems: eventmachine, thin, cramp, sinatra, yajl-ruby
# - a browser with WebSocket support
#
# Usage:
# ruby redis_pubsub_demo.rb
#
#!/usr/bin/ruby
#
# I deliberately didn't DRY /usr/local references into a variable as this
# script will not "just work" if you change the destination directory. However
# please feel free to fork it and make that possible.
#
# If you do fork, please ensure you add a comment here that explains what the
# changes are intended to do and how well you tested them.
#
# 14th March 2010:
let's get Neo4j setup ...
jruby -r java -e "puts java.lang.System.get_property('java.class.path')"
jruby -S jirb
> require 'rubygems' # don't seem to need to require 'lucene' anymore
> require 'neo4j/auto_tx' # 'neo4j' req's a transaction wrapping like
> NGINX Team,
>
> Is there a way to capture the User-Agent from an HTTP Header, then query a database for that User-Agent, then based on the result of the database query, transparently route the request to an appropriate server?
>
> Thanks,
> Sean
Sean-
bonsai
rdiscount
// one global css object
//
var css;
(function(){
css = function(){
// static data
//
this.data =
http_path = "/" # Root of project when deployed
css_dir = "public/stylesheets"
sass_dir = "public/stylesheets/sass"
images_dir = "images"
javascripts_dir = "javascripts"
relative_assets = true
var child_process = require('child_process'),
sys = require('sys'),
net = require('net'),
netBinding = process.binding('net');
var fd = netBinding.socket('tcp4');
netBinding.bind(fd, 8080);
netBinding.listen(fd, 128);
for (var i = 0; i < 4; i++) {
(:import
[java.net InetSocketAddress]
[java.util.concurrent Executors]
[org.jboss.netty.bootstrap ServerBootstrap]
[org.jboss.netty.channel Channels ChannelPipelineFactory]
[org.jboss.netty.channel.socket.nio NioServerSocketChannelFactory])