Skip to content

Instantly share code, notes, and snippets.

View czottmann's full-sized avatar
💭
Sure.

Carlo Zottmann czottmann

💭
Sure.
View GitHub Profile
(.)(.)
class User < ActiveRecord::Base
validates_uniqueness_of :email, :case_sensitive => false
validate :valid_email?
private
def valid_email?
address = EmailVeracity::Address.new(email)
config.gem "heycarsten-email-veracity", :lib => "email_veracity"
begin
retryable( :tries => 2 ) do
Timeout::timeout(5) do |t|
xml_string = open( my_url, "User-Agent" => "Firefox/2.0" ).read
end
end
rescue Timeout::Error
LOG.error("Timeout error: #{$!} (#{my_url})")
God.watch do |w|
# ...
# Setting ENV variables for your script.
w.env = { "WORKER_ID" => "12" }
# Allow STDOUT and capture it to a log file.
w.log = "path/to/stdout/log/file.log"
# ...
[http://feeds.feedburner.com/Flickrblog]
name = Flickr Blog
face = flickr.gif
facewidth = 106
faceheight = 35
[http://blog.360.yahoo.com/rss-1qCkw2Ehaak.hdNZkEAzDrpa4Q--?cq=1]
name = Y! 360 US Blog
face = y_360.gif
facewidth = 195
def show
@xyz = Xyz.find( params[:id] )
if @xyz
# render page
else
# render error template or redirect to error page
end
end
class SomeModel < ActiveRecord::Base
serialize :data
xss_terminate :except => [:data]
end
class CreateRelationships < ActiveRecord::Migration
def self.up
create_table :relationships do |t|
t.integer :user_id
t.integer :following_id
t.timestamps
end
add_index( :relationships, [ :user_id, :following_id ], :unique => true )
class UserSession < Authlogic::Session::Base
last_request_at_threshold 43200
end