I hereby claim:
- I am jasondew on github.
- I am jasondew (https://keybase.io/jasondew) on keybase.
- I have a public key whose fingerprint is D4FD 83C6 D891 37EC 3045 8745 3581 0583 7D91 64D9
To claim this, I am signing this object:
n=(0..3);g=[!1]*4;b=[g,g,[!1]+[1]*3,g] | |
4.times{b=n.map{|x|n.map{|y|l=[x-1,x+1,x].product([y-1,y+1,y])[0..7].select{|f,g|(r=b[f])&&r[g]}.size | |
l==3||b[x][y]&&l==2}} | |
b.map{|r|puts r.map{|c|c ??#:?.}*""}} |
Luhn Checksum | |
http://en.wikipedia.org/wiki/Luhn_algorithm | |
Implement a Ruby program that outputs the validity of a number by applying the Luhn Checksum. | |
Input: | |
The program should accept a single number to validate. | |
Output: |
class Courier < ActionMailer::Base | |
CIPHER = ActiveSupport::MessageEncryptor.new("redacted", "aes-256-cbc") | |
module ClassMethods | |
delegate :encrypt, :to => :"Courier::CIPHER" | |
def valid_email_address? email_address | |
(not email_address.blank?) and email_address.include?("@") | |
end |
POSSCON = Conference.create(:awesome => true) do | |
starts_on "2010-04-15" | |
ends_on "2010-04-17" | |
speakers %w(Obie Yehuda Wanstrath) | |
end | |
POSSCON.include?(self) or fail |
class CreditCard < ActiveRecord::Base | |
belongs_to :order | |
has_one :billing_address, :as => :addressable, :class_name => "Address", :dependent => :destroy | |
accepts_nested_attributes_for :billing_address | |
before_validation :clean_number |
@client.diagnoses.include? Diagnosis.get(:hiv) |
module Algebra | |
class MaximumIterationsReached < Exception | |
end | |
class NewtonsMethod | |
def self.calculate(function, x) | |
x - function.evaluated_at(x) / function.derivative_at(x) | |
end |
require 'algebra' | |
class IRR | |
def self.calculate(profits) | |
begin | |
function(profits).zero | |
rescue Algebra::MaximumIterationsReached => mir | |
nil | |
end |
update : Action -> Model -> ( Model, Effects Action ) | |
update action model = | |
case action of | |
HandleResponse result -> | |
case result of | |
Ok movies -> | |
( { model | movies = movies }, Effects.none ) | |
Err error -> | |
let |
I hereby claim:
To claim this, I am signing this object: