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
>> form_authenticity_token | |
=> "OBVOzqfizcWJ+d6GrYFO8NvZQMKlOji5vu28iwwED68=" | |
>> params[:authenticity_token] | |
=> "OBVOzqfizcWJ d6GrYFO8NvZQMKlOji5vu28iwwED68=" |
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
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: |
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
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 ??#:?.}*""}} |
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
foo.rb:1: syntax error, unexpected tINTEGER, expecting tSTRING_CONTENT or tSTRING_DBEG or tSTRING_DVAR or tSTRING_END | |
foo.rb:1: syntax error, unexpected tI... | |
^ |
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
x_bar = xs.sum / xs.length.to_f | |
y_bar = ys.sum / ys.length.to_f | |
normalized_xs = xs.map {|x| x - x_bar } | |
normalized_ys = ys.map {|y| y - y_bar } | |
beta_hat = normalized_xs.zip(normalized_ys).map {|x, y| x*y }.sum / normalized_xs.inject(0) {|sum, x| sum + x*x } | |
alpha_hat = y_bar - beta_hat * x_bar | |
[[0, alpha_hat], [xs.last, (alpha_hat + xs.last * beta_hat)]] |
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 "quine" | |
this.that.and.something_else |
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
puts 'require "quine"' | |
module Kernel | |
def method_missing name, *args | |
print name | |
metaclass = class << (o = Object.new); self; end | |
metaclass.send(:define_method, :method_missing) do |name, *args| | |
print ".#{name}" | |
self | |
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 Controller < ApplicationController | |
def show | |
@transaction_record = TransactionRecord.find(...) | |
respond_to do |wants| | |
wants.html | |
wants.pdf { send_data @transaction_record.pdf } | |
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
= edit f, [[:name , "Name"], | |
[:fein , "FEIN"], | |
[:fein_suffix , "FEIN suffix"], | |
[:state_id , "State"], | |
[:category_id , "Category"] |
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
extend CodedOptions | |
coded_options :state => ["Active", "Under Appeal", "Terminated"], | |
:category => ["Private, Non-profit", "Private, For-profit", "Publicly Sponsored", "Church Sponsored", "Head Start Organization", "Public School 4K", "Military Prog | |
:type => ["Center Child Care", "Accredited Center", "Group Day Care", "Family Day Care", "Exemption"], | |
:authorization_type => %w(License Approval Military Exempt DDSN), | |
:county => %w(Abbeville Aiken Allendale Anderson Bamberg Barnwell Beaufort Berkeley Calhoun Charleston Cherokee Chester Chesterfield Clarendon Colleton Darlingto | |
:time => %w(closed 1:00AM 1:15AM 1:30AM 1:45AM 2:00AM 2:15AM 2:30AM 2:45AM 3:00AM 3:15AM 3:30AM 3:45AM 4:00AM 4:15AM 4:30AM 4:45AM 5:00AM 5:15AM 5:30AM 5:45AM | |
:status => %w(Open Closed Partial/Exception) |