Skip to content

Instantly share code, notes, and snippets.

source "http://rubygems.org"
gem "rake"
gem "eventmachine"
gem "haml"
gem "sinatra", "0.9.4"
gem "rack"
gem "thin"
gem "rerun"
gem "json"
class JsonHax
def initialize(app)
@app = app
end
def call(env)
if env['CONTENT_TYPE'] == 'application/json'
env['CONTENT_TYPE'] = 'application/xml'
env['REQUEST_URI'].gsub!(/\.json/, '.xml')
In response to all the responses to:
http://twitter.com/rtomayko/status/1155906157
You should never do this in a source file included with your library,
app, or tests:
require 'rubygems'
The system I use to manage my $LOAD_PATH is not your library/app/tests
require 'rubygems'
require 'eventmachine'
require 'redis'
require 'hash_ring'
class RedisProcz < EventMachine::Connection
def initialize
@ring = HashRing.new
end
@martincik
martincik / debug.rb
Created October 16, 2009 12:14 — forked from tmm1/debug.rb
# collect information about a running process
# ruby debug.rb <pid>
begin
raise ArgumentError unless pid = ARGV[0]
pid = pid.to_i
Process.kill(0,pid)
rescue TypeError, ArgumentError
raise 'pid required'
rescue Errno::ESRCH
require 'rubygems'
require 'eventmachine'
require 'evma_httpserver'
require 'cgi'
class Room < EM::Channel
end
$room = Room.new
$welcome_html = DATA.read
# This method is heavily adapted from the Rails method of determining the subdomain.
require 'rubygems'
require 'sinatra'
require 'rack/request'
# We re-open the request class to add the subdomains method
module Rack
class Request
def subdomains(tld_len=1) # we set tld_len to 1, use 2 for co.uk or similar
>> require 'rufus/mnemo'
>> s = Rufus::Mnemo::from_integer rand(8**5)
=> "bisoshi"
sudo haproxy -f /etc/haproxy/haproxy.conf -p /var/run/haproxy.pid -sf $(</var/run/haproxy.pid)