Skip to content

Instantly share code, notes, and snippets.

View MrJaba's full-sized avatar

Tom Crinson MrJaba

View GitHub Profile
@MrJaba
MrJaba / rubinius
Created December 14, 2010 10:04
Rubinius SHA1 issue
tcrins01@AM2201:~ $ rvm list rubies
rvm rubies
rbx-1.1.0-20100923 [ i386 ]
rbx-1.1.1-20101116 [ i386 ]
rbx-head [ i386 ]
ruby-1.8.7-p249 [ i386 ]
ruby-1.9.2-p0 [ i386 ]
@MrJaba
MrJaba / gist:771942
Created January 9, 2011 19:41
IO install issue
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
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 / counter.erl
Created January 31, 2011 09:50
Erlang Day 1 Exercises
-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;
@MrJaba
MrJaba / daytwo.erl
Created February 8, 2011 17:46
Erlang Day 2 Exercises
-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 / visualizer.rb
Created March 9, 2011 13:20
A Processing Music Visualizer
# 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 / signed_request.rb
Created May 5, 2011 15:02
Facebook signed_request verification
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 / golf.rb
Created July 10, 2011 09:31
Ruby Golf for IPRUG
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 / scenario_blueprints.rb
Created August 22, 2011 14:08
Scenario Blueprints
#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 / local_request.rb
Created September 20, 2011 13:35
Fixing Local Request
module ActionDispatch
class Request < Rack::Request
def local?
false
end
end
end