This file contains 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
def foo([head | *something*]) when head * 2 < *last* do | |
some return value | |
end |
This file contains 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
# /home/bob/env | |
# USER=bob | |
# PASS=secret | |
docker run --env-file /home/bob/env -p 80:80 some/image | |
# Which is equivalent to: | |
docker run -e USER=bob -e PASS=secret /path/to/file -p 80:80 some/image |
This file contains 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
# Run DelayedJob | |
namespace :delayed_job do | |
def wait_for_process_to_end(process_name) | |
run "COUNT=1; until [ $COUNT -eq 0 ]; do COUNT=`ps -ef | grep -v 'ps -ef' | grep -v 'grep' | grep -i '#{process_name}'|wc -l` ; echo 'waiting for #{process_name} to end' ; sleep 2 ; done" | |
end | |
desc "Restart the delayed_job process" | |
task :restart, :roles => :app do | |
stop | |
wait_for_process_to_end('delayed_job') |
This file contains 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 Hello | |
def self.first | |
puts "Boo!" | |
end | |
private | |
def self.second | |
puts "Buh!" | |
end |
This file contains 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
In a mounted engine with | |
isolate_namespace Foo | |
A Foo::BarController#index action looks for it's template in app/views/foo/bar/index.html.erb | |
However if I'm in that index template and do | |
render :partial => 'bar/baz' |
This file contains 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
# Rails 2 routing | |
# | |
map.resource :city, :as => ":city" do |city| | |
city.login 'login', :controller => 'cities', :action => 'login' | |
city.resources :orders, :only => [ :show, :update ] | |
end | |
# city_login /:city/login {:controller=>"cities", :action=>"login"} | |
# | |
# city_order GET /:city/orders/:id(.:format) {:controller=>"orders", :action=>"show"} |
This file contains 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
>> d.wordpress_deal.merchant_value | |
=> 37.05 | |
>> d.wordpress_deal.merchant_value * 100 | |
=> 3705.0 | |
>> (d.wordpress_deal.merchant_value * 100).to_i | |
=> 3704 | |
>> |
This file contains 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
<p> | |
<span class="black-txt"><b>Programme Benefits</b></span><br /> | |
<span class="black-txt">• High conversion rate and average spend (£77) per customer</span><br /> | |
<span class="black-txt">• Fantastic widget feeds and creatives to display on your website</span><br /> | |
<span class="black-txt">• Comprehensive Affiliate management from 7thingsmedia</span><br /> | |
</p> | |
<p> | |
<span class="black-txt">• £2.50 fixed fee commission for first customer sales</span><br /> | |
<span class="black-txt">• 10% commission of sale value on first customer sales</span><br /> |
This file contains 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 InviteController < ApplicationController | |
helper :google_optimizer, :content, :competitions, :deals | |
include ContentHelper | |
skip_before_filter :invitation_or_login_required, :only => [ :index, :invite_deal, :invite_competition] | |
def index | |
######################################### | |
## Generic links |
This file contains 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 FbappController < ApplicationController | |
helper :google_optimizer | |
skip_before_filter :invitation_or_login_required, :only => [:index] | |
layout 'fb_app' | |
def index | |
if @user | |
return redirect_to '/fb_error' | |
end |
NewerOlder