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
# -*- mode: ruby -*- | |
# vi: set ft=ruby : | |
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing! | |
VAGRANTFILE_API_VERSION = "2" | |
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| | |
config.vm.box = "precise64" | |
config.vm.box_url = "http://files.vagrantup.com/precise64.box" | |
config.vm.network :private_network, ip: "192.168.33.21" |
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 Animal | |
def run | |
puts 'running' | |
end | |
end | |
Animal.new.run #=> running | |
class Wolf < Animal | |
def follow_pack |
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
=Navigating= | |
visit('/projects') | |
visit(post_comments_path(post)) | |
=Clicking links and buttons= | |
click_link('id-of-link') | |
click_link('Link Text') | |
click_button('Save') | |
click('Link Text') # Click either a link or a button | |
click('Button Value') |
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
require 'net/http' | |
require 'json' | |
require 'uri' | |
@token = '' | |
def list_files | |
ts_to = (Time.now - 30 * 24 * 60 * 60).to_i # 30 days ago | |
params = { | |
token: @token, |
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
FactoryGirl.define do | |
factory :student do | |
first_name "Doctor" | |
last_name "Who" | |
story "Doctor Who is a British science-fiction television programme produced by the BBC since 1963." | |
end | |
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
class DonationsController < ApplicationController | |
def create | |
@customer = Customer.find_or_create_by_email(params[:stripeEmail], params[:stripeToken], params[:stripeName]) | |
new_payment | |
if @payment.save && @payment.charge | |
@payment.delay_until(1.minutes.from_now).email_payer | |
redirect_to page_path('thanks') | |
end | |
rescue Stripe::CardError => e | |
flash[:error] = e.message |
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 Salesforce | |
include Singleton | |
def restforce | |
@client ||= \ | |
Restforce.new :oauth_token => ENV['SALESFORCE_OAUTH'], | |
:refresh_token => ENV['SALESFORCE_REFRESH_TOKEN'], | |
:instance_url => ENV['SALESFORCE_INSTANCE_URL'], | |
:client_id => ENV['SALESFORCE_CLIENT_ID'], | |
:client_secret => ENV['SALESFORCE_SECRET'] |
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
<%= link_to page_path('page_name') do %> | |
<i class="fa fa-home"></i> Home | |
<% 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
# correct | |
describe User do | |
let (:user) { User.new } | |
context "when name is empty" do | |
it "should not be valid" do | |
expect(user.valid?).to be_false | |
end | |
it "should not save" do |
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 localize(colors,measurements,motions,sensor_right,p_move): | |
# initializes p to a uniform distribution over a grid of the same dimensions as colors | |
def sense(p, colors, measurement): | |
aux = [[ 0.0 for row in range(len(p[0]))] for col in range(len(p))] | |
s = 0.0 | |
for i in range(len(p)): | |
for j in range(len(p[i])): |
OlderNewer