Skip to content

Instantly share code, notes, and snippets.

View wrburgess's full-sized avatar
:shipit:
Shippin'

Randy Burgess wrburgess

:shipit:
Shippin'
View GitHub Profile
@wrburgess
wrburgess / gist:2439800
Created April 21, 2012 21:42
CodeSchool - Rails Testing for Zombies Notes #test #testunit #rails

CodeSchool Rails Testing for Zombies Notes

Test::Unit Assertions

assert_respond_to [object], :[method] #does object method exist? ex. assert_respond_to "string", :lowercase
assert_equal [string, [method] #is first string equal to results of second method?
assert_match [regex], [method] #is first regex equal to second string?
assert_nil
assert_not_nil [method] #is method nil?  

assert_raise(RuntimeError), [method]

@wrburgess
wrburgess / gist:2440276
Created April 21, 2012 23:37
Ruby Notes

Modules

Modules in ruby are similar to classes, except:

  • A module can have no instances.
  • A module can have no subclasses.
  • A module is defined by module ... end.
@wrburgess
wrburgess / gist:2483094
Created April 24, 2012 19:49
Inserting Main Menu and Secondary Menus in templates on Drupal 7
@wrburgess
wrburgess / gist:2483916
Created April 24, 2012 21:22
Drupal 7 Snippets

Find the path (or alias) of a node from its Node ID:

drupal_lookup_path('alias',"node/".$node->nid)

@wrburgess
wrburgess / gist:2491381
Created April 25, 2012 17:12
Drupal 7: Create user-login page theme suggestion
// Insert into your theme > template.php file
<?php
function hook_theme($existing, $type, $theme, $path){
return array(
'user_login' => array(
'render element' => 'form',
'template' => 'user-login',
),
@wrburgess
wrburgess / gist:2494338
Created April 25, 2012 23:16
Block comments in Ruby
=begin
This is a line of code or comments
This is another line of code or comments
=end
@wrburgess
wrburgess / gist:2504316
Created April 27, 2012 00:05
Ruby dev questions

Where should module files go?

When should modules be used vs classes?

What's the difference between modules and mixins?

@wrburgess
wrburgess / gist:2521308
Created April 28, 2012 18:57
Notes on Installing PostgreSQL from RailsCasts
@wrburgess
wrburgess / gist:2522067
Created April 28, 2012 21:12
Setting up Ruby on a Mac OSX Lion

check the ruby version:

ruby -v

install the newest ruby version:

rvm install 1.9.3

instruct rvm to use the latest ruby:

@wrburgess
wrburgess / gist:2522380
Created April 28, 2012 22:07
Ruby Class Example
class Movie
attr_reader :title, :rank
attr_writer :title, :rank
# or attr_accessor :title, :rank
def initialize(title, rank = 0)
@title = title
@rank = rank
end