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
$stdin.read.lines.each do |line| | |
number = line.strip | |
luhn = line.strip.chars.to_a.reverse.each_with_index.map do |v,i| | |
val = v.to_i | |
if (i - 1) % 2 == 0 | |
(val * 2).to_s.each_char.reduce(0) { |memo,n| memo + n.to_i } | |
else | |
val | |
end | |
end.reduce(&:+) |
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
"The quick brown fox jumps over the lazy dog. But the dog totally deserved it." | |
becomes "Tqbfjotld Btdtdi " |
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
source 'https://rubygems.org' | |
gem 'activeadmin' | |
gem 'airbrake' | |
gem 'app' | |
gem 'ar_after_transaction' | |
gem 'cancan' | |
gem 'fog' | |
gem 'foreman' | |
gem 'gibbon' |
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
bool isThreeQuarters(double value) | |
{ | |
return value == 75.00; | |
} |
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
describe "_clip.html.erb" do | |
let(:context) { | |
o = Object.new | |
o.class_eval do | |
def erb_binding # bypass the fact that binding is private and send(:binding) seems to have wierd side-effects | |
binding | |
end | |
end | |
o | |
} |
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
respond_with(@user) do |format| | |
format.json { render :json => { :message => "User created" } } | |
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
# simple sinatra auth | |
use Rack::Auth::Basic, "Restricted Area" do |username, password| | |
{ | |
"admin1" => "password1", | |
"admin2" => "password2" | |
}[username] == password | |
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
get_subclasses = lambda { |c| | |
c.subclasses.append(c.subclasses.map(&get_subclasses)).flatten | |
} | |
pp get_subclasses.call(ActionController::Base) |
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
#TODO use Faker | |
FactoryGirl.define do | |
factory :user do | |
account | |
sequence :email do |n| | |
"user_#{n}@example.com" | |
end | |
first_name 'John' |
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
<% if Rails.env.test? %> | |
<%= javascript_include_tag "stubs" %> | |
<% end %> |