Skip to content

Instantly share code, notes, and snippets.

View caleywoods's full-sized avatar

Caley Woods caleywoods

View GitHub Profile
@caleywoods
caleywoods / hello_ruby.rb
Created January 14, 2011 08:03
signup task for #p2pu intro to rails
# Put your name (or username/alias) between the quotes
name = "Caley"
# Put your favorite fruit between the quotes
favorite_fruit = "Braeburn Apples"
puts "Hi! My name is #{name} and my favorite fruit is #{favorite_fruit}"
@caleywoods
caleywoods / gist:789111
Created January 21, 2011 01:50
tinyMCE ASP.NET MVC
<script type="text/javascript" src="<%=Url.Content("~/path/to/tiny_mce.js") %>"</script>
def test_you_dont_get_null_pointer_errors_when_calling_methods_on_nil
begin
nil.some_method_nil_doesnt_know_about
rescue Exception => ex
puts ex.class
end
def test_strings_are_unique_objects
a = "a string"
b = "a string"
assert_equal __, a == b
assert_equal __, a.object_id == b.object_id
end
def test_method_names_become_symbols
symbols_as_strings = Symbol.all_symbols.map { |x| x.to_s }
assert_equal true, symbols_as_strings.include?("test_method_names_become_symbols")
end
# THINK ABOUT IT:
#
# Why do we convert the list of symbols to strings and then compare
# against the string value rather than against symbols?
111 def test_slash_b_anchors_to_a_word_boundary
112 assert_equal "vines", "bovine vines"[/\bvine./]
113 assert_equal "super dooper", "super dooper pooper scooper"[/\bsuper\s\S+/]
114 end
def test_calling_global_methods_without_parentheses
result = my_global_method 2, 3
assert_equal 5, result
end
def text(a,b)
a + b
end
lm = lambda { |n| n.upcase }
def upcase(text):
upper = text.upper()
return upper
@upcase
def regular_text(a,b)
a + b
end
require 'spec_helper'
describe PagesController do
render_views
describe "GET 'home'" do
it "should be successful" do
get 'home'
response.should be_success
end