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
"GET /heroku/resources/id": | |
'renders 404 when the project is not found': -> | |
@response = new mocks.Response() | |
@response.render = (params...) -> | |
@rendered = true | |
assert.equal params[0], '404' | |
ProjectsController.show(new mocks.Request(app_id: 1), @response) |
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
module Tandem | |
class Config | |
def self.current_user(&block) | |
SomeController.send(:define_method, :current_user, block) | |
end | |
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
require 'mathn' | |
n = 600851475143 | |
Prime.each do |x| | |
while n % x == 0 | |
n = n/x | |
end | |
break if x > n/2 | |
end | |
puts n |
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
ans = 0 | |
for i in 100..999 | |
for j in (100..999).to_a.reverse | |
x = i*j | |
if x == (x).to_s.reverse.to_i | |
ans = x | |
break | |
elsif x < ans | |
break | |
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
# This file should contain all the record creation needed to seed the database with its default values. | |
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup). | |
# | |
# Examples: | |
# | |
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }]) | |
# Mayor.create(name: 'Emanuel', city: cities.first) | |
Interview.delete_all | |
User.delete_all |
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
self.class.find_by_sql(["SELECT users.* FROM users | |
INNER JOIN connections AS second_degree_connections | |
ON second_degree_connections.target_id = users.id | |
INNER JOIN connections AS first_degree_connections | |
ON first_degree_connections.target_id = second_degree_connections.owner_id | |
WHERE first_degree_connections.owner_id = ?", self.id]) |
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 'savon' | |
client = Savon.client('https://dev.tch.com/richapp/Wsdl.action?wsdl=/axis2/services/CardManagementWS') | |
client.http.auth.ssl.verify_mode = :none | |
client.wsdl.soap_actions |
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 Car | |
def initialize(instruments) | |
@instruments = instruments | |
end | |
def mileage | |
@_mileage ||= @instruments.select(:odometer).calculate_value | |
end | |
end |