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 'rubygems' rescue nil | |
require 'gosu' | |
require 'chipmunk' | |
class Array | |
# e.g. [1,2,3].each_link yields [1,2], [2,3] | |
def each_link | |
prev = first | |
self[1, size].each do |item| | |
yield prev, item |
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
# What is it with you people and your singletons? | |
class Hash | |
def self.from_block(&block) | |
Hash[*BlockBuilder.new(&block).collected] | |
end | |
class BlockBuilder | |
attr_reader :collected |
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
# Is there a preferred way to do it? A lot of people I see use inject, but it makes my eyes bleed. | |
x = [[1, 2], [3, 4]] | |
p x.inject({}) { |h, r| h[r[0]] = r[1]; h } | |
# {1=>2, 3=>4} | |
p Hash[*x.flatten] | |
# {1=>2, 3=>4} |
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
describe 'rsync' do | |
it 'should keep the latest version of a file' do | |
system("mkdir -p d1 d2") | |
begin | |
system("echo 'This is the first version' > d1/file.txt") | |
sleep 1 # ensure timestamps are different | |
system("echo 'This is the second version' > d2/file.txt") | |
system("rsync -ru d2/ dest/") | |
system("rsync -ru d1/ dest/") | |
File.read('dest/file.txt').should include('second version') |
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
:javascript | |
Shining.config({...}) | |
#first | |
%h1 Hi there world | |
%p Yes this is a slide | |
%p.step with a step | |
:javascript | |
// stuff for the first slide | |
:css |
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
create_table "line_items", :force => true do |t| | |
t.integer "cost" | |
t.boolean "paid" | |
t.integer "order_id" | |
end | |
create_table "orders", :force => true do |t| | |
end | |
# ----- |
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
gem 'haml-rails', '~> 0.3' | |
gem 'rails', '~> 3.1' | |
group :assets do | |
gem 'compass', '~> 0.11' | |
gem 'sass-rails', '~> 3.1' | |
gem 'coffee-rails', '~> 3.1' | |
gem 'uglifier', '~> 1.0' | |
end |
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
1.9.3-p125 :001 > 1.week | |
=> 7 days | |
1.9.3-p125 :002 > Rails.version | |
=> "3.2.2" | |
1.9.3-p125 :003 > |
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
#/usr/bin/env ruby | |
COLORS = [ | |
RED = "\e[01;31m", | |
GREEN = "\e[01;32m", | |
YELLOW = "\e[01;33m", | |
BLUE = "\e[01;34m", | |
PINK = "\e[01;35m", | |
CYAN = "\e[0;36m", | |
GRAY = "\e[01;30m", |
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
#/usr/bin/env ruby | |
COLORS = [ | |
RED = "\e[01;31m", | |
GREEN = "\e[01;32m", | |
YELLOW = "\e[01;33m", | |
BLUE = "\e[01;34m", | |
PINK = "\e[01;35m", | |
CYAN = "\e[0;36m", | |
GRAY = "\e[01;30m", |
OlderNewer