Skip to content

Instantly share code, notes, and snippets.

View jmervine's full-sized avatar

Joshua Mervine jmervine

View GitHub Profile
@futuremill-ltd
futuremill-ltd / gist:2318876
Created April 6, 2012 11:00
Building Ruby 1.9.3 package for Debian Squeeze
# From a fresh install of squeeze
apt-get install ruby rubygems # Need ruby to use fpm
gem1.8 install fpm --no-ri --no-rdoc
apt-get install build-essential openssl libreadline6 libreadline6-dev zlib1g zlib1g-dev libssl-dev ncurses-dev libyaml-dev
wget ftp://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p125.tar.gz
tar -zxvf ruby-1.9.3-p125.tar.gz
cd ruby-1.9.3-p125
rm -rf /tmp/ruby193
@jmervine
jmervine / gist:2052509
Created March 16, 2012 20:37
Ruby: dynamically generated object with accessors
class Item
def initialize item
raise "expected Hash param" unless item.kind_of? Hash
item.each do |key,value|
instance_variable_set(clean_key(key), value)
define_singleton_method(key.to_s) { instance_variable_get( clean_key(key) ) }
define_singleton_method("#{key.to_s}=") { |val| instance_variable_set( clean_key(key), val ) }
end
end
@jmervine
jmervine / gist:2052468
Created March 16, 2012 20:30
Rails: Dynamic Model from JSON sans DB
require 'net/http'
class Item
#replaced with dynamic initialization below
#attr_reader :id, :user, :state
#
#
# Sample JSON
#
# [{ "id":1, "user":"john", "state":"active" },
# { "id":2, "user":"jane", "state":"inactive" },
#!/usr/bin/env roundup
describe "redis-cli(1)"
# Start the redis server on port 9999
port=9999
printf "PORT $port\n" | ./redis-server - &
redis_pid=$!
# Give redis time to start listening