Skip to content

Instantly share code, notes, and snippets.

# Rails 3 application template
# Usage: rails new app -JOT -m http://gist.github.com/460217.txt
# where J=no Prototype, O=no ActiveRecord, T=no TestUnit
# see http://mongoid.org/docs/installation/
# see also http://asciicasts.com/episodes/201-bundler
# see also http://github.com/josevalim/inherited_resources
# see also http://github.com/plataformatec/devise
# see also http://github.com/indirect/rails3-generators
mongo = yes? "Run MongoDB?"
@jtomson
jtomson / gist:771828
Created January 9, 2011 17:21 — forked from shripadk/gist:652819
some coffeescript-node-redis boilerplate
###
Module dependencies
###
require.paths.unshift "#{__dirname}/lib/support/express-csrf/"
require.paths.unshift "#{__dirname}/lib/support/node_hash/lib/"
express = require 'express'
app = module.exports = express.createServer()
RedisStore = require 'connect-redis'
@sheremetyev
sheremetyev / philosophers.js
Created February 20, 2011 23:34
Dining Philosophers in JavaScript
// Dining Philosophers problem
function Phil(me, left, right) {
var run = function() {
sequential([
500, // pause
function() { console.log(me + ' sits'); },
left, // channel
function() { console.log(me + ' picked left fork'); },
500,
@mrrooijen
mrrooijen / deploy.rb
Created June 26, 2011 02:37
Capistrano with Foreman Capfile
# encoding: utf-8
$:.unshift(File.expand_path('./lib', ENV['rvm_path']))
require 'rvm/capistrano'
set :application, "hirefireapp"
set :repository, "git@codeplane.com:meskyanichi/myapp.git"
set :branch, "develop"
set :rvm_ruby_string, "1.9.2"
@benolee
benolee / howto_pow_ubuntu.txt
Created July 1, 2011 03:32
HowTo Ubuntu pow-like setup
$ sudo aptitude install apache2 dnsmasq
$ sudo vim /etc/dnsmasq.conf
# ...
address=/dev/127.0.0.1
listen-address=127.0.0.1
$ sudo vim /etc/dhcp3/dhclient.conf
# uncomment line 20:
@shimondoodkin
shimondoodkin / APPNAME
Created July 2, 2011 17:33 — forked from peterhost/node_debian_init.sh
init.d script for node.js for debian
#! /bin/sh
# ------------------------------------------------------------------------------
# SOME INFOS : fairly standard (debian) init script.
# Note that node doesn't create a PID file (hence --make-pidfile)
# has to be run in the background (hence --background)
# and NOT as root (hence --chuid)
#
# MORE INFOS : INIT SCRIPT http://www.debian.org/doc/debian-policy/ch-opersys.html#s-sysvinit
# INIT-INFO RULES http://wiki.debian.org/LSBInitScripts
# INSTALL/REMOVE http://www.debian-administration.org/articles/28

Thin vs Puma

Run these two servers using the commands given in their source. Benchmark using:

ab -n 1000 -c 1000 http://localhost:8000/

I found thin can handle these requests without a problem. puma drops connections and causes ab to exit early.

With 200 threads, puma can handle 200 requests but does not respond promptly:

@al6x
al6x / 1_collection_spec.rb
Created January 10, 2012 09:54
Ruby vs NodeJS vs NodeJS + Async vs NodeJS + Fibers
require 'driver/spec_helper'
describe "Collection" do
with_mongo
it "should by default update all matched by criteria (not first as default in mongo)" do
db.units.save name: 'Probe', race: 'Protoss', status: 'alive'
db.units.save name: 'Zealot', race: 'Protoss', status: 'alive'
# Update.
@nulltask
nulltask / .gitignore
Created February 24, 2012 18:28
cluster-io
.DS_Store
._*
node_modules/
@eerohele
eerohele / ringbuffer.rb
Last active October 29, 2018 12:00
A simple ring buffer for Ruby.
class RingBuffer < Array
attr_reader :max_size
def initialize(max_size, enum = nil)
@max_size = max_size
enum.each { |e| self << e } if enum
end
def <<(el)
if self.size < @max_size || @max_size.nil?