This file contains 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
run "rm public/index.html" | |
file '.gitignore', <<-IGNORE | |
log/*.log | |
tmp/**/* | |
.DS_Store | |
doc/api | |
doc/app | |
db/*.sqlite3 | |
IGNORE | |
run "touch log/.gitignore" |
This file contains 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
class Wadus < ActiveRecord::Base | |
named_scope :limited, lambda {|n| { :limit => n }} | |
named_scope :low_id, :conditions => "id < 500" | |
end | |
Wadus.low_id.limited(5) | |
# SELECT * FROM "wadus" WHERE (id < 500) LIMIT 5 |
This file contains 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
input = "foo bar wadus wadus" | |
File.open("path/to/input.txt", "w") do |f| | |
f.puts input | |
end | |
system("path/to/wadus.exe") | |
output = File.read("path/to/output.txt") |
This file contains 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
ActionController::Routing::Routes.draw do |map| | |
map.root :controller => 'posts' | |
end | |
$ rake routes | |
root / {:controller=>"posts", :action=>"index"} | |
This file contains 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 'yaml' | |
def yacss(data) | |
YAML.load(data).map do |item| | |
item.map do |selector, properties| | |
"#{selector} {\n" + | |
properties.map do |property, value| | |
" #{property}: #{value};\n" | |
end.join + | |
"}\n" |
This file contains 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
Toronto List | |
============ | |
Clothes | |
------- | |
* 10 camisetas | |
* 10 calzoncillos | |
* 10 pares de calcetines | |
* 1 camisa |
This file contains 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
# paste into .irbrc | |
require 'benchmark' | |
def time(&block) | |
result = nil | |
Benchmark.bm do |bm| | |
bm.report { result = yield } | |
end | |
result |
This file contains 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
user system total real | |
slow 9.350000 0.140000 9.490000 ( 11.120732) | |
fast 0.780000 0.010000 0.790000 ( 0.912680) |
This file contains 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
// ==UserScript== | |
// @name More Diversion | |
// @namespace http://github.com/porras | |
// @description Fixes some Diversion bugs client-side ;-) | |
// @include http://diversion.r09.railsrumble.com/* | |
// ==/UserScript== | |
$ = unsafeWindow.jQuery | |
$(document).ready(function() { |
This file contains 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
def calculate_range_start_of_months | |
#Catacrocker obscurism | |
[current = range.begin.beginning_of_month].tap { |result| result << current while (current += 1.month) <= range.end } | |
end |
OlderNewer