If one was inclined to use the acts_as_yaffle pattern, they would probably use the second one, rather than the heavily cargo-culted first one.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'action_controller' | |
| Router = ActionDispatch::Routing::RouteSet.new | |
| Router.draw do | |
| root :to => 'site#index' | |
| end | |
| class SiteController < ActionController::Metal | |
| def index | |
| self.response_body = "waddup son" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'rubygems' | |
| require 'mechanize' | |
| require 'httparty' | |
| # Ugly code, for an ugly hack. | |
| # Hey, if Lighthouse didn't suck then none of this would happen. | |
| # It's been lotsa fun coding it though, so I suppose I should be thankful for the "opportunity" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'rubygems' | |
| require 'rack' | |
| class Object | |
| def webapp | |
| class << self | |
| define_method :call do |env| | |
| func, *attrs = env['PATH_INFO'].split('/').reject(&:empty?) | |
| [200, {}, send(func, *attrs)] | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| THIS DOCUMENT MOVED TO http://chneukirchen.github.com/rps/ | |
| AND http://github.com/chneukirchen/rps | |
| = Ruby Packaging Standard | |
| The aim of this document is two-fold. First, to specify a common | |
| structure of how a Ruby package distributed as source (that is, but | |
| not limited to, development directories, version-controlled | |
| repositories, .tar.gz, Gems, ...) should conform to. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module Matz | |
| def self.included(*) | |
| puts <<-MATZ | |
| Simplicity is NOT a Goal | |
| ------------------------ | |
| Things too simple are difficult | |
| Things too complex are difficult |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env ruby | |
| ## Usage: memrate.rb [-l <lib>] [-i <num>] [-t <threshold>] [-k <size>] [<host>] | |
| ## Measure memcached server read time. | |
| ## | |
| ## Options | |
| ## -l, --library=<lib> Memcached client library to use. memcache-client by | |
| ## default. memcached also supported. | |
| ## -i, --iterations=<num> Number of times to read the value. If not set, read | |
| ## until interrupted. | |
| ## -t, --threshold=<time> Report iterations that take longer than <time> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # unicorn_rails -c /data/github/current/config/unicorn.rb -E production -D | |
| rails_env = ENV['RAILS_ENV'] || 'production' | |
| # 16 workers and 1 master | |
| worker_processes (rails_env == 'production' ? 16 : 4) | |
| # Load rails+github.git into the master before forking workers | |
| # for super-fast worker spawn times | |
| preload_app true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $ cat script/test.rb | |
| require File.expand_path('../../config/environment.rb', __FILE__) | |
| 5000.times{ print 'a' } | |
| $ RAILS_ENV=production strace -e trace=write ruby script/test.rb > /dev/null | |
| write(1, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"..., 4096) = 4096 | |
| write(1, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"..., 904) = 904 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # this: | |
| builder = Rack::Builder.new do | |
| use Rack::ContentLength | |
| use Rack::ETag | |
| run app | |
| end | |
| app = builder.to_app | |
| # is the same as: |