Skip to content

Instantly share code, notes, and snippets.

View tansengming's full-sized avatar
🏠
Working from home

SengMing Tan tansengming

🏠
Working from home
View GitHub Profile
require 'activesupport';
cache = ActiveSupport::Cache::MemoryStore.new
cache.fetch(User.find(1)){User.find(1)}
def order_one_flows args = {}
height, width = (args[:height] || 100.0), (args[:width] || 100.0)
end
require 'rubygems'
require 'hpricot'
feed = 'data/input.feed'
h = Hpricot(File.read feed)
puts (h/'description')[1..-1].inner_html.map{|str| str.gsub('&lt;','<')}.map{|str| str.gsub('&gt;','>')}.map{|str| (Hpricot(str)/'img').map{|img| img.attributes['src']}.join("\n")}.join.gsub('"', '')
require 'rubygems'
require 'vendor/sinatra/lib/sinatra.rb'
root_dir = Dir.pwd
Sinatra::Application.set(
:run => false,
:environment => 'production'
)
require 'app'
@tansengming
tansengming / muttrc
Created March 31, 2009 13:20
muttrc
# User specific
set move = no
set delete=yes
set editor="vim"
set include=yes
set fast_reply=yes
set record='Archive'
set sort = 'threads'
set sort_aux = 'reverse-last-date-received'
@tansengming
tansengming / Rails gitignore
Created April 15, 2009 07:38
Rails gitignore
db/*.sqlite3
db/schema.rb
log/*log*
tmp/**/*
.DS_Store
doc/api
doc/app
*.tmproj
@tansengming
tansengming / Rails Console Actionmailer test.rb
Created April 24, 2009 15:14
Rails Console Actionmailer test
# Copy and paste this to the rails console to test your email settings
class MyMailer < ActionMailer::Base
def test_email
@recipients = "someone@somewhere.com"
@from = "must_be_same_as_smpt_account_login@gmail.com"
@subject = "test from the Rails Console"
@body = "This is a test email"
end
end
/path/to/log/*.log {
compress
copytruncate
daily
dateext
delaycompress
missingok
notifempty
rotate 30
sharedscripts
class Name
attr_read :first, :last
def initialize
load_data
end
private
def load_data
@first = 'SengMing'
@last = 'Tan'
class Name
def name
first + ' ' + last
end
def first
@first ||= 'SengMing'
end
def last