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
class ApplicationController | |
protected | |
def iphone? | |
request.class.to_s.include?("CgiRequest") && request.user_agent.include?('iPhone') | |
end | |
end | |
class ApplicationHelper | |
def iphone? |
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
[3] <enki> [10:51 PM] ~>irb | |
>> x.blank? | |
NameError: undefined local variable or method `x' for main:Object | |
from (irb):1 | |
>> | |
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
def foo(a=Time.now.utc) | |
puts a | |
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
foo(nil) #=> nil | |
foo #=> Tue Jan 13 03:22:44 -0800 2009 |
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
begin | |
user = User.find(:frist) #=> Bill Frist? | |
user.update_attribute(:alive_or_dead) #=> Care to be more specific? | |
rescue => e | |
logger.error "Something bad happened" #=> Yeah, but what? | |
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
begin | |
a = Account.find(8675309) #=> Sadly, Jenny's not a user. | |
rescue | |
# I'm so cool I don't need to do anything here. | |
end | |
# If I ever find that Tommy... | |
a.update_attribute(:location, "bathroom wall") |
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
User.find(params[:id]) rescue nil #=> Don't even get me started. |
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
>> class Session < ActiveRecord::Base; end # So we can access the sessions table directly | |
=> nil | |
>> s = Session.first | |
=> #<Session id: 1, session_id: "bd0568033d143fafaa1f9752c43b61d7", data: "BAh7BiIKZmxhc2hJQzonQWN0aW9uQ29udHJvbGxlcjo6Rmxhc2g...", created_at: "2008-12-10 15:50:58", updated_at: "2008-12-10 17:50:47"> | |
>> session_data = Marshal.load(Base64::decode64(s.data)) | |
=> {"flash" => {}} | |
>> Rails.cache.write("rack:session:#{s.session_id}", session_data) | |
=> 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
for repo in * | |
do | |
[ ! -d $repo ] && continue | |
[ ! -d $repo/.git ] && continue | |
cd $repo; | |
echo $repo; | |
git pull; | |
cd - > /dev/null | |
done |
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
# Note that I have Rails 2.3.4 installed on this machine already. | |
[12] <ci> [01:17 PM] /opt/app>sudo gem install awesome_nested_set | |
Successfully installed activesupport-2.3.5 | |
Successfully installed activerecord-2.3.5 | |
Successfully installed awesome_nested_set-1.4.3 | |
3 gems installed | |
Installing ri documentation for activesupport-2.3.5... | |
Installing ri documentation for activerecord-2.3.5... | |
Installing ri documentation for awesome_nested_set-1.4.3... |
OlderNewer