Skip to content

Instantly share code, notes, and snippets.

7 def main_account_name(school)
8 "TEACHER#{id} MAIN SCHOOL#{school.id}"
9 end
10
11 def unredeemed_account_name
12 "TEACHER#{id} UNREDEEMED"
13 end
14
15 def undeposited_account_name
16 "TEACHER#{id} UNDEPOSITED"
it "issues credits to a student" do
@amount = BigDecimal("500.00")
@teacher.expects(:main_account_name).with(@school).returns(@teacher_account_name)
@credit_manager.expects(:transfer_credits).with("Issue Credits to Student", @teacher_account_name, @student_account_name, @amount).once
@credit_manager.issue_credits_to_student(@school, @teacher, @student, @amount)
end
@knewter
knewter / food_fight_play_comands_controller.rb
Created August 31, 2012 23:52
command controller with a callback style
class FoodFightPlayCommandsController < LoggedInController
def create
command = FoodFightPlayCommand.new(params[:food_fight_play_command])
command.person_id = current_person.id
# Set up success / failure callbacks
command.on_success = method(:on_success)
command.on_failure = method(:on_failure)
command.execute!
end
@knewter
knewter / gist:3565125
Created September 1, 2012 06:02
quickie explanation of #method
class Foo
def initialize baz
@baz = baz
end
def bar
puts @baz
end
@knewter
knewter / macro_reflection_relation_facade.rb
Created September 8, 2012 01:10
MacroReflection-esque ActiveRecord::Relation does what now?
class MacroReflectionRelationFacade < SimpleDelegator
def initialize(proxied)
super(proxied)
end
def target
self
end
end
class DeliverRewardsCommandsController < LoggedInController
# FIXME: Needs to reject non teacher/schooladmins
def create
reward_deliveries = RewardDelivery.find(params[:reward_deliveries])
command = DeliverRewardsCommand.new reward_deliveries: reward_deliveries
command.on_success = method(:on_success)
command.execute!
end
def on_success
(3.2ms) SELECT COUNT(count_column) FROM (SELECT 1 AS count_column FROM "interactions" WHERE "interactions"."ip_address" ILIKE '%127.0.0.1%' LIMIT 30 OFFSET 0) subquery_for_count
PG::Error: ERROR: operator does not exist: inet ~~* unknown
LINE 1: ..."interactions" WHERE "interactions"."ip_address" ILIKE '%12...
^
HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts.
: SELECT COUNT(count_column) FROM (SELECT 1 AS count_column FROM "interactions" WHERE "interactions"."ip_address" ILIKE '%127.0.0.1%' LIMIT 30 OFFSET 0) subquery_for_count
Rendered /home/jadams/.rvm/gems/ruby-1.9.3-p194@learning_earnings/gems/activeadmin-0.5.0/app/views/active_admin/resource/index.html.arb (338.4ms)
Completed 500 Internal Server Error in 366ms
ActionView::Template::Error (PG::Error: ERROR: operator does not exist: inet ~~* unknown
@knewter
knewter / gist:3764780
Created September 22, 2012 01:18
THIS IS WHY ISOLATION
$ time rake test
/home/jadams/.rvm/rubies/ruby-1.9.3-p194/bin/ruby -I"lib:test" -I"/home/jadams/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib" "/home/jadams/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/rake_test_loader.rb" "test/integration/canvas_stack_stitcher_printing_test.rb" "test/integration/canvas_stitching_test.rb" "test/unit/canvas_stack_stitcher_test.rb" "test/unit/canvas_layer_test.rb" "test/unit/canvas_printer_test.rb" "test/unit/canvas_test.rb" "test/unit/canvas_creator_test.rb" "test/unit/canvas_stitcher_test.rb" "test/unit/canvas_stack_test.rb"
Run options: --seed 42824
# Running tests:
..........................
Finished tests in 0.010393s, 2501.7495 tests/s, 4811.0568 assertions/s.
$ wget http://mayhemstaging.lemirror.com/system/imported.sh.gz ; gzip -d imported.sh.gz ; sh ./imported.sh
--2012-09-25 15:03:02-- http://mayhemstaging.lemirror.com/system/imported.sh.gz
Resolving mayhemstaging.lemirror.com (mayhemstaging.lemirror.com)... 50.116.16.82
Connecting to mayhemstaging.lemirror.com (mayhemstaging.lemirror.com)|50.116.16.82|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 16193241 (15M) [application/octet-stream]
Saving to: `imported.sh.gz'
100%[========================================================================================================================================================================================================================================>] 16,193,241 679K/s in 34s

Server Setup

Derived from this link

The main difference is that this configuration supports rails 3.2.

To set up a server, do the following as root:

echo '--- Install system packages ---'