Skip to content

Instantly share code, notes, and snippets.

View anildigital's full-sized avatar

Anil Wadghule anildigital

  • Pune, India
  • 13:37 (UTC +05:30)
View GitHub Profile
@anildigital
anildigital / scaling.rb
Created December 20, 2008 05:03 — forked from lifo/scaling.rb
# Allow the metal piece to run in isolation
require(File.dirname(__FILE__) + "/../../config/environment") unless defined?(Rails)
class Scaling
def self.call(env)
if env["PATH_INFO"] =~ /^\/scaling/
[200, {"Content-Type" => "text/html"}, ["Hello, World!"]]
else
[404, {"Content-Type" => "text/html"}, ["Not Found"]]
end

Note to Self

Be Confident

Tests build confidence. Write 'em. They'll save your ass, and they'll let you take a chainsaw to your code without being afraid of unintended consequences.

Be Lazy

http://ozmm.org/posts/erb_eval.html
Because I always forget how to do it:
require 'erb'
name = 'bob'
template = 'whatever, <%= name %>'
puts ERB.new(template).result(binding)
# SUPER DARING APP TEMPLATE 1.0
# By Peter Cooper
# Link to local copy of edge rails
inside('vendor') { run 'ln -s ~/dev/rails/rails rails' }
# Delete unnecessary files
run "rm README"
run "rm public/index.html"
run "rm public/favicon.ico"
anil-wadghules-macbook:~ anildigital$ scp ~/.ssh/id_rsa.pub [email protected]:/home/anil
ssh: connect to host 67.207.133.219 port 22: Connection refused
lost connection
anil-wadghules-macbook:~ anildigital$ ssh -p 2222 [email protected]
ssh: connect to host 67.207.133.219 port 2222: Connection refused
[submodule "rinari"]
path = vendor/rinari
url = git://github.com/eschulte/rinari.git
[submodule "markdown-mode"]
path = vendor/markdown-mode
url = git://github.com/defunkt/markdown-mode.git
[submodule "twilight-emacs"]
path = vendor/twilight-emacs
url = git://github.com/crafterm/twilight-emacs.git
[submodule "vendor/fuzzy-find-in-project"]
Script started on Sun Dec 28 11:14:42 2008
bash-3.2$ exgit submodule init
bash-3.2$ git subcat .gitmodules
[submodule "rinari"]
path = vendor/rinari
url = git://github.com/eschulte/rinari.git
[submodule "markdown-mode"]
path = vendor/markdown-mode
url = git://github.com/defunkt/markdown-mode.git
[submodule "twilight-emacs"]
require 'rubygems'
require 'sinatra'
require 'cheat'
get "/" do
@cheats = ""
@cheats = (`cheat sheets`).split("\n")
puts @cheats.inspect
erb :index, :locals => { :cheats => @cheats}
end
<% cheats = (`cheat sheets`).split("\n") %>
<% cheat = (`cheat #{cheats[rand(cheats.size)]}`).split("\n") %>
<body>
<div id="cheat_block">
<div id="cheat_name">
<%= cheat[0] %>
</div>
<% cheat.shift %>
<div id="cheat_info">