Skip to content

Instantly share code, notes, and snippets.

View marcdel's full-sized avatar

Marc Delagrammatikas marcdel

View GitHub Profile
require 'spec_helper'
module Codebreaker
describe Game do
describe '#start' do
let(:output) { double('output').as_null_object }
let(:game) { Game.new(output) }
it 'sends a welcome message' do
output.should_receive(:puts).with('Welcome to Codebreaker!')
game.start
[42] pry(main)> (1..5).each { |i| puts i.object_id }
3
5
7
9
11
=> 1..5
[43] pry(main)> (1..5).each { |i| puts (i.object_id - 1) / 2 }
1
2
@marcdel
marcdel / p_is_for_inspect.rb
Created March 23, 2013 20:46
'object.inspect' is equivalent to 'p object'
[15] pry(main)> a.inspect
=> "[1, 2, 3, 4, 5]"
[16] pry(main)> p a
[1, 2, 3, 4, 5]
=> [1, 2, 3, 4, 5]
[17] pry(main)> b.inspect
=> "{:some=>\"thing\"}"
[18] pry(main)> p b
{:some=>"thing"}
=> {:some=>"thing"}
@marcdel
marcdel / woah.rb
Created March 23, 2013 20:59
lol head assplode
[1] pry(main)> "".class
=> String
[2] pry(main)> "".class.superclass
=> Object
[3] pry(main)> "".class.superclass.superclass
=> BasicObject
[4] pry(main)> "".class.superclass.superclass.superclass
=> nil
[5] pry(main)> nil.class
=> NilClass
@marcdel
marcdel / rails_4_routes.rb
Created March 24, 2013 23:54
Two new ways to write routes in rails 4.
post '/home', to: 'home#index'
get '/home', to: 'home#index'
match '/home', to: 'home#index', via: :post
match '/home', to: 'home#index', via: :all
@marcdel
marcdel / rails_env.rb
Created March 25, 2013 06:10
why are all these different whyyyyyyy
# Enter console in test environment
$ rails console test
Loading test environment
>> Rails.env
=> "test"
>> Rails.env.test?
=> true
# Start the server in test environment
$ rails server --environment test
git push heroku
heroku pg:reset DATABASE
heroku run rake db:migrate
heroku run rake db:populate
Creating Sessions
tmux new - new unnamed session
tmux new -s session_name - new named session
tmux new -s session_name -n window_name - new named session with named window
tmux ls - list all running sessions
tmux attach -t session_name - reattaches to named session
tmux kill-session -t session_name - kills a named session
Ctrl+a d - detaches from current session
Ctrl+a : - command mode
set = []
array.each do |item|
set.push item
if item % 4 == 0
puts set.inspect
set = []
end
end