Skip to content

Instantly share code, notes, and snippets.

@cantin
cantin / gist:3936965
Created October 23, 2012 05:43 — forked from zernel/gist:3749856
Logger
file = File.join(Rails.root, 'log/markdown.log')
File.new(file, 'w+') unless File.exist?(file)
logger = Logger.new(file)
logger.info("#{Time.now}: Share##{_id}'s price is from #{latest_price} to #{new_price}")
logger.close
@cantin
cantin / gist:3891279
Created October 15, 2012 07:54
vim search and replace in multi files
args **/*.txt
argsdo %s/oldword/newword/gc
/oldword/newword/# to disable the ignorecase options
namespace :book_item do
task :free_all_if_due => :environment do
Book.free_book_items_if_due
puts 'Free the due book_item successfully'
end
end
@cantin
cantin / deploy for delayed_job_mongoid
Created August 17, 2012 02:22
delayed_job_mongoid cap/deploy
namespace :delayed_job do
task :setup do
puts capture %Q(cd #{deploy_to}/current/ && RAILS_ENV=production script/rails runner 'Delayed::Backend::Mongoid::Job.create_indexes')
end
task :start do
puts capture %Q(cd #{deploy_to}/current/ && RAILS_ENV=production script/delayed_job start)
end
task :stop do