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
Devise.setup do |config| | |
# ==> Mailer Configuration | |
# Configure the e-mail address which will be shown in DeviseMailer. | |
config.mailer_sender = '"John Smith" <[email protected]>' | |
# ... | |
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
gem install aws-ses | |
# in irb: | |
require 'aws/ses' | |
ses = AWS::SES::Base.new :access_key_id => "your-key", | |
:secret_access_key => "your-secret-key" | |
ses.addresses.list.result |
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
task :ensure_alive do | |
puts "GET #{find_servers.first}:" | |
system("curl -silent http://#{find_servers.first} > /dev/null") | |
end | |
after "deploy", "ensure_alive" |
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
openssl genrsa -out yoursite.key 1024 | |
openssl req -new -key yoursite.key -out yoursite.csr | |
openssl x509 -req -days 2000 -in yoursite.csr -signkey yoursite.key -out yoursite.crt | |
sudo cp yoursite.crt /etc/ssl/certs/ | |
sudo cp yoursite.key /etc/ssl/private/ | |
# Apache | |
a2enmod ssl headers |
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
SSL_PROTOCOL = 'http' |
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
require 'rubygems' | |
require 'wirble' | |
require 'hirb' | |
begin | |
IRB::Irb.class_eval do | |
def output_value | |
ap @context.last_value | |
end | |
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
has_attached_file :avatar, | |
:styles => { :medium => "100x100#", :thumb => "45x45#" } | |
:default_url => lambda { |a| "/images/avatar_:style_#{a.instance.default_image_number}.png" } | |
def default_image_number | |
id.to_s.last | |
end | |
# this example allows you to have 10 random default avatars: | |
# avatar_thumb_0.png, avatar_thumb_1.png, etc. |
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
Loading development environment (Rails 3.0.7) | |
ruby-1.9.2-p180 :001 > s = Time.now.to_s | |
=> "2011-05-05 17:11:19 -0600" | |
ruby-1.9.2-p180 :002 > s.to_time | |
=> 2011-05-05 17:11:19 UTC <----- wrong | |
ruby-1.9.2-p180 :003 > s.to_time :local | |
=> 2011-05-05 17:11:19 -0600 <----- better, sort of | |
ruby-1.9.2-p180 :004 > Time.parse s | |
=> 2011-05-05 17:11:19 -0600 <----- plain ruby wins |
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 some reason active record doesn't include a simple way to serialize to | |
# cache. this simple trick will take you far | |
# | |
# usage: | |
# | |
# user = User.find(id) | |
# | |
# key = user.to_cache | |
# | |
# user = User.from_cache(key) |
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
module Rails | |
class << self | |
# retrieve keyed item from cache | |
# store block results if not in cache | |
# | |
# usage: | |
# cash('user-first-10') { User.limit(10) } | |
def cash(key, options=nil) | |
object = cache.read(key) |