Skip to content

Instantly share code, notes, and snippets.

@nicobrevin
nicobrevin / gist:460263
Created July 1, 2010 17:26
jsvc-daemon
#! /bin/sh
# Generic script for running ruby scripts as daemons using
# jsvc and a java class to control the daemon.
#
# Contains common parameters and start/stop
# Things you'll need to set on a per script/daemon basis:
# SCRIPT_NAME
#
# Things you can set:
public class JRubyDaemon implements Daemon {
private Ruby runtime;
private Thread thread;
private RubyModule appModule;
private boolean debug;
private RubyModule daemon;
public void init(DaemonContext arguments) throws Exception {
@nstielau
nstielau / set_environment.rb
Created May 9, 2011 00:04
A Knife plugin to set node environment
## Knife plugin to set node environment
# See http://wiki.opscode.com/display/chef/Environments
#
## Install
# Place in .chef/plugins/knife/set_environment.rb
#
## Usage
# Nick-Stielaus-MacBook-Pro:chef-repo nstielau$ knife node set_environment mynode.net my_env
# Looking for mynode.net
# Setting environment to my_env
@grantr
grantr / gist:1105416
Created July 25, 2011 22:31
Chef mysql master/slave recipes
## mysql::master
ruby_block "store_mysql_master_status" do
block do
node.set[:mysql][:master] = true
m = Mysql.new("localhost", "root", node[:mysql][:server_root_password])
m.query("show master status") do |row|
row.each_hash do |h|
node.set[:mysql][:master_file] = h['File']
node.set[:mysql][:master_position] = h['Position']
end
@henrygarner
henrygarner / gist:1123179
Created August 3, 2011 17:14 — forked from timcowlishaw/gist:1123148
Resources for setting up RVM and Passenger on Chef
http://www.agileweboperations.com/chef-rvm-ruby-enterprise-edition-as-default-ruby
http://www.christophersamuelson.com/2010/10/22/chef-rvm-capistrano-bundler/
http://blog.ninjahideout.com/posts/a-guide-to-a-nginx-passenger-and-rvm-server
http://brandontilley.com/2011/01/29/serving-rails-apps-with-rvm-nginx-unicorn-and-upstart.html
http://brandontilley.com/2011/01/29/rvm-unicorn-and-upstart.html
Chef workflow
# Install cookbook from opscode community site. (Automatically commits to local repo)
knife cookbook site install <COOKBOOK_NAME>
@lusis
lusis / fun-with-celluloid.rb
Created August 11, 2011 03:18
Just mucking about with a POC Celluloid worker pool
require 'celluloid'
require 'logger'
require 'uuid'
require 'sinatra/base'
# This is just a simple demo of a possible Pool implementation for Celluloid
# The sinatra interface exists just to do some testing of crashing workers and the like
# TODO
# Create a busy worker registry of some kind
@lusis
lusis / celluloid-pool.rb
Created August 13, 2011 01:35
Playing around with a fairly naive worker pool implementation in Celluloid
require 'celluloid'
require 'logger'
require 'uuid'
require 'sinatra/base'
# This is just a simple demo of a possible Pool implementation for Celluloid
# The sinatra interface exists just to do some testing of crashing workers and the like
# TODO
# Create a busy worker registry of some kind
@yoojinl
yoojinl / actors.rb
Created October 29, 2011 20:19
Actors shmactors.
require 'thread'
require 'celluloid'
$q = Queue.new
class A
include Celluloid
def add
loop do
@tarcieri
tarcieri / charlie_and_ashton.rb
Created November 2, 2011 02:13
An example of circular calls in Celluloid
require 'rubygems'
require 'celluloid'
class Charlie
include Celluloid
def initialize(friend)
@nemesis = friend
end
@joemiller
joemiller / celluoid-pool-2.rb
Created March 21, 2012 15:05
modified version of @lusis' celluloid pool test using the new celluloid::pool class in 0.9.0
# NOTE: original gist that this is based on is available here: https://gist.github.com/1143369
require 'celluloid'
require 'logger'
require 'uuid'
require 'sinatra/base'
# This is just a simple demo of a possible Pool implementation for Celluloid
# The sinatra interface exists just to do some testing of crashing workers and the like