View gist:7c7c8e340e4ec69abf90
Failure/Error: post :notification, { "communication_id" => "666", "content" => {"id_sale" => 123} }
Real HTTP connections are disabled. Unregistered request: POST with body '{"id_sale":"123"}' with headers {'Authorization'=>'Basic ZGV0b21hc3RhaDpodTJzd2U0ag==', 'Connection'=>'close', 'Content-Type'=>'application/json', 'Host'=>'', 'User-Agent'=>'RubyHTTPGem/0.8.4'}
You can stub this request with the following snippet:
stub_request(:post, "").
with(:body => "{\"id_sale\":\"123\"}",
:headers => {'Authorization'=>'Basic ZGV0b21hc3RhaDpodTJzd2U0ag==', 'Connection'=>'close', 'Content-Type'=>'application/json', 'Host'=>'', 'User-Agent'=>'RubyHTTPGem/0.8.4'}).
to_return(:status => 200, :body => "", :headers => {})
View Joke
So a guy walks into a bar one day and he can't believe his eyes. There, in the corner, there's this one-foot-tall man, in a little tuxedo, playing a tiny grand piano.
So the guy asks the bartender, "Where'd he come from?"
And the bartender's, like, "There's a genie in the men's room who grants wishes."
So the guy runs into the men's room and, sure enough, there's this genie. And the genie's, like, "Your wish is my command." So the guy's, like, "O.K., I wish for world peace." And there's this big cloud of smoke—and then the room fills up with geese.
So the guy walks out of the men's room and he's, like, "Hey, bartender, I think your genie might be hard of hearing."
And the bartender's, like, "No kidding. You think I wished for a twelve-inch pianist?"
So the guy processes this. And he's, like, "Does that mean you wished for a twelve-inch penis?"
And the bartender's, like, "Yeah. Why, what did you wish for?"
And the guy's, like, "World peace."
So the bartender is understandably ashamed.
View gist:8470959
<% if @recruitment.tandc %>
<% content_for :title, "Education Partner Checklist 2013/14" %>
<p>Before you start running the Apps for Good course you need to attend a Train The Trainer session, so that you feel confident in delivering the course to your students.</p>
<h3 style="margin-top:1em;">Please register to attend to one of the Train The Trainer sessions listed below.</h3>
<!-- <p>The Education Partner checklist provides you with the training, resources and expert guidance to successfully deliver the Apps for Good course.</p> -->
# TODO: EventBrite API
View Adjust areas of expertise
ActiveRecord::Base.transaction do
ExpertiseArea.find_by_name!("Development / programming").update_attribute(:name, "Technical & data feasibility")
ExpertiseArea.find_by_name!("Market research / customer development").update_attribute(:name, "User & market insight")
ExpertiseArea.find_by_name!("Marketing / customer acquisition").update_attribute(:name, "Marketing")
ExpertiseArea.find_by_name!("User experience / Design").update_attribute(:name, "User experience")
ExpertiseArea.create!(:name => "Idea screening")
ExpertiseArea.create!(:name => "Web development (HTML, CSS, Javascript)")
ExpertiseArea.create!(:name => "Social app development (Facebook)")
View gist:5161314
class Girl
def initialize(secret_name)
class Ala < Girl
def name
View gist:5030848
import sys
arr = [a for a in range(1,129)]
arr2 = [a for a in range(1001,1129)]
for a in xrange(0, int(sys.argv[1])):
for b in xrange(0,128):
if arr[b] % 2 == 0:
arr[b] += arr2[b]
arr2[b] *= arr[b]
View gist:5030383
arr = (1..129).map{|a| a}
arr2 = (1001..1129).map{|a| a}
(0..ARGV[0].to_i).each do |a|
(0..128).each do |b|
if arr[b] % 2 == 0
arr[b] += arr2[b]
arr2[b] *= arr[b]
View gist:4985534
ActiveRecord::Base.transaction do
orders_to_fix = Order.joins(:billing_address).where("orders.billing_address_id = AND addresses.addressable_type = 'User'")
orders_to_fix.each do |order|
billing_address = order.build_billing_address order.billing_address.attributes_for_clone
billing_address.addressable = order => false)
ActiveRecord::Base.connection.execute("UPDATE orders SET billing_address_id = #{} WHERE id = #{}")
View gist:4555335
# encoding: utf-8
Feature: Product cross selling
In order to maximize customer satisfaction (and our profit :])
As a potential customer
I want to see items related to product I am currently looking
Scenario: Product page should show cross sell items
Given the following products exists
| product | name | gross_price | available_amount | number | manufacturer_product_number |
| camera | Kamera | 1199 | 22 | HK029737 | 01G-P3-1556-KR |
View gist:4345898
ActiveRecord::Base.transaction do
Category.all.each do |c|
ordered_configs = c.search_attribute_configs.
ordered_configs.each_with_index do |sa_config, index|
sa_config = SearchAttribute::Config.find(
sa_config.update_attribute(:position, index + 1)