Skip to content

Instantly share code, notes, and snippets.

View danielevans's full-sized avatar

Daniel Evans danielevans

  • Anfract
  • Portland, OR
View GitHub Profile
$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(&:+)
"The quick brown fox jumps over the lazy dog. But the dog totally deserved it."
becomes "Tqbfjotld Btdtdi "
source 'https://rubygems.org'
gem 'activeadmin'
gem 'airbrake'
gem 'app'
gem 'ar_after_transaction'
gem 'cancan'
gem 'fog'
gem 'foreman'
gem 'gibbon'
bool isThreeQuarters(double value)
{
return value == 75.00;
}
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
}
respond_with(@user) do |format|
format.json { render :json => { :message => "User created" } }
end
# simple sinatra auth
use Rack::Auth::Basic, "Restricted Area" do |username, password|
{
"admin1" => "password1",
"admin2" => "password2"
}[username] == password
end
get_subclasses = lambda { |c|
c.subclasses.append(c.subclasses.map(&get_subclasses)).flatten
}
pp get_subclasses.call(ActionController::Base)
#TODO use Faker
FactoryGirl.define do
factory :user do
account
sequence :email do |n|
"user_#{n}@example.com"
end
first_name 'John'
@danielevans
danielevans / application.html.erb
Created November 26, 2012 18:19
Adding a javascript stub file to cucumber
<% if Rails.env.test? %>
<%= javascript_include_tag "stubs" %>
<% end %>