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
import scala.collection.mutable.ArrayBuffer | |
object BowlingScorer extends App { | |
val testFrame = "XXXXXXXXXXXX" | |
//val testFrame = "9-9-9-9-9-9-9-9-9-9-" | |
//val testFrame = "5/5/5/5/5/5/5/5/5/5/5" | |
val frames = new ArrayBuffer[Frame]() | |
var frameCount = 0 | |
for( roll <- testFrame ){ |
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 ActionDispatch | |
class Request < Rack::Request | |
def local? | |
false | |
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
#In test file | |
setup do | |
load_scenario("bookshop_a") | |
end | |
test "Franks has 5 books" do | |
assert_equal 5, @frank.books.count | |
end | |
#In test helper or some other such solution |
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 Golf | |
class << self | |
def hole1(r) | |
r.inject 1,:* | |
end | |
def hole2(s) | |
s.split.sort_by{|a| a[1]}.join " " | |
end | |
def hole3(n) | |
(1..n).inject 1,:* |
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 'openssl' | |
require 'base64' | |
def verify_facebook_request | |
signed_request = params[:signed_request] | |
raise ActionController::InvalidAuthenticityToken.new("Invalid Facebook Request") unless signed_request.present? && valid_facebook_signature?(signed_request) | |
end | |
def valid_facebook_signature?(signed_request) | |
signature, encoded_data = signed_request.split(".") |
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
# Visualizer | |
class Visualizer < Processing::App | |
load_library "minim" #Java sound library included with processing. load_library is provided by ruby-processing | |
import "ddf.minim" | |
import "ddf.minim.analysis" | |
def setup | |
smooth |
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(daytwo). | |
-export([find/2]). | |
-export([shopping/1]). | |
-export([ttt/1]). | |
%Given a list of tuples and a key return the value of the key | |
%[{thing, "thing value"}, {thing_two, "thing_two value"}] | |
find([], Term) -> []; | |
find([{Term,Value}|Tail], Term) -> Value; | |
find([Head|Tail], Term) -> find(Tail, Term). |
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(counter). | |
-export([count/1]). | |
-export([str_count/2]). | |
%count to 10 recursively | |
count(10) -> 10; | |
count(N) -> count(N+1). | |
%count the words in a string recursively | |
str_count([],N) -> 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
class Plan | |
include Mongoid::Document | |
embeds_many :monthly_plans | |
end | |
class MonthlyPlan | |
include Mongoid::Document | |
embeds_many :planning_options | |
embedded_in :plan, :inverse_of => :monthly_plans | |
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
cmake .. | |
-- The C compiler identification is GNU | |
-- The CXX compiler identification is GNU | |
-- Checking whether C compiler has -isysroot | |
-- Checking whether C compiler has -isysroot - yes | |
-- Checking whether C compiler supports OSX deployment target flag | |
-- Checking whether C compiler supports OSX deployment target flag - yes | |
-- Check for working C compiler: /usr/bin/gcc | |
-- Check for working C compiler: /usr/bin/gcc -- works | |
-- Detecting C compiler ABI info |