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
--type-add=ruby=.haml | |
--type-add=css=.sass | |
--type-add=css=.scss | |
--type-add=css=.less | |
--type-set | |
coffeescript=.coffee | |
--ignore-dir=node_modules |
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 TicketsController < ApplicationController | |
def index | |
@order = Order.paid.find_by_permalink!(params[:user_order_id]) | |
ticket_report = TicketReport.new | |
ticket_report.order = @order | |
respond_to do |format| | |
format.pdf do |
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
# excute the given block, retying only when one of the given exceptions is raised | |
module RetryOnFailure | |
def retry_on_failure(*exception_list) | |
retry_count = 5 | |
begin | |
yield | |
rescue *exception_list => e | |
if retry_count > 0 | |
retry_count -= 1 | |
puts "Exception, trying again #{retry_count} more times" |
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
it "normalize swedish cell phone number" do | |
user = Factory.build(:user, :cell_phone => "0707-293274") | |
described_class.new(:recipient => user).recipient_normalized_cell_phone.should == "0046707293274" | |
user = Factory.build(:user, :cell_phone => "+46707-293274") | |
described_class.new(:recipient => user).recipient_normalized_cell_phone.should == "0046707293274" | |
user = Factory.build(:user, :cell_phone => "0046707293274") | |
described_class.new(:recipient => user).recipient_normalized_cell_phone.should == "0046707293274" | |
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
# Bit.ly API implementation - thanks to Richard Johansso http://gist.github.com/112191 | |
require 'httparty' | |
class Api::Bitly | |
include HTTParty | |
base_uri 'api.bit.ly' | |
format :json | |
# Usage: Bitly.shorten("http://example.com") | |
def self.shorten(url) |
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
Surround these with : e.g. :calling: | |
+1 | |
-1 | |
bulb | |
calling | |
clap | |
cop | |
feet |
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
config.action_mailer.delivery_method = :smtp | |
config.action_mailer.smtp_settings = { | |
:address => "smtp.gmail.com", | |
:port => 587, | |
:domain => "konferensen", | |
:authentication => "plain", | |
:user_name => "[email protected]", | |
:password => "password", | |
:enable_starttls_auto => 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
require 'rubygems' | |
require 'madmimi' | |
mimi = MadMimi.new("email", "key") | |
options = { | |
"promotion_name" => "Test Promotion", | |
"recipients" => "", | |
"from" => "", |
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
# http://avdi.org/devblog/2011/01/14/activerecord-golf | |
require 'active_record' | |
class Monster < ActiveRecord::Base | |
establish_connection :adapter => 'sqlite3', | |
:database => ':memory:' | |
connection.create_table( :monsters ) { |t| t.string :name } | |
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
after "deploy:stop", "delayed_job:stop" | |
after "deploy:start", "delayed_job:start" | |
after "deploy:restart", "delayed_job:restart" | |
namespace :delayed_job do | |
desc "Stop the delayed_job process" | |
task :stop, :roles => :app do | |
run "cd #{current_path}; script/delayed_job -e #{rails_env} stop" | |
end | |