Skip to content

Instantly share code, notes, and snippets.

Tom Crinson MrJaba

Block or report user

Report or block MrJaba

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View bowling_scorer.scala
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 ){
@MrJaba
MrJaba / local_request.rb
Created Sep 20, 2011
Fixing Local Request
View local_request.rb
module ActionDispatch
class Request < Rack::Request
def local?
false
end
end
end
View scenario_blueprints.rb
#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
@MrJaba
MrJaba / golf.rb
Created Jul 10, 2011
Ruby Golf for IPRUG
View golf.rb
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,:*
@MrJaba
MrJaba / signed_request.rb
Created May 5, 2011
Facebook signed_request verification
View signed_request.rb
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(".")
@MrJaba
MrJaba / visualizer.rb
Created Mar 9, 2011
A Processing Music Visualizer
View visualizer.rb
# 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
@MrJaba
MrJaba / daytwo.erl
Created Feb 8, 2011
Erlang Day 2 Exercises
View daytwo.erl
-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).
@MrJaba
MrJaba / counter.erl
Created Jan 31, 2011
Erlang Day 1 Exercises
View counter.erl
-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;
View MongoidIssue.rb
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
@MrJaba
MrJaba / gist:771942
Created Jan 9, 2011
IO install issue
View gist:771942
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
You can’t perform that action at this time.