This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def login_required | |
authorized? || access_denied | |
end | |
def access_denied | |
respond_to do |format| | |
format.html do | |
store_location | |
redirect_to new_session_path | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def login_required | |
authorized? || access_denied | |
end | |
def access_denied | |
respond_to do |format| | |
format.html do | |
store_location | |
redirect_to new_session_path | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def to_html | |
rows = data.map{|row| " <tr>#{row.map{|d| "<td>#{d}</td>"}.join}</tr>"} | |
"<table>\n#{rows.join("\n")}\n</table>" | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>> phrases = ["Mr. Gregory Browne", "Mr. Gregory Brown is cool", | |
"Gregory Brown is cool", "Gregory Brown"] | |
>> phrases.grep /\AGregory Brown\b/ | |
=> ["Gregory Brown is cool", "Gregory Brown"] | |
>> phrases.grep /\bGregory Brown\b/ | |
=> ["Mr. Gregory Brown is cool", "Gregory Brown is cool", "Gregory Brown"] | |
>> phrases.grep /\AGregory Brown\z/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def set_my_ivar | |
@my_ivar = 'set' | |
end | |
class A | |
attr_reader :my_ivar | |
def test_the_setting | |
set_my_ivar | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From 99a2d34571a039bef903eeb1354000b459b6f85c Mon Sep 17 00:00:00 2001 | |
From: Brad Ediger <brad.ediger@madriska.com> | |
Date: Wed, 25 Mar 2009 13:39:54 -0500 | |
Subject: [PATCH] Follow symlinks, if any, in gems/gems path | |
--- | |
lib/rubygems/installer.rb | 5 ++++- | |
1 files changed, 4 insertions(+), 1 deletions(-) | |
diff --git a/lib/rubygems/installer.rb b/lib/rubygems/installer.rb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def Service(name) | |
Class.new(ActiveResource::Base) do | |
self.site = ServiceLocator[name] | |
self.user = 'api' | |
self.password = 'ooga-booga' | |
def self.-@ | |
self | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Madriska | |
module Prawn | |
module ColumnLayout | |
def columns(column_spec) | |
@columns = distribute_columns(column_spec, bounds.width) | |
@column_x = 0 | |
@column_lowest_y = @y | |
yield | |
@columns = nil |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
shaver_triton=# select a.state, a.name, st_distance(a.the_geom, il.the_geom) from states_provinces a, states_provinces il where a.state != il.state and il.name = 'Illinois' order by st_distance(a.the_geom, il.the_geom) asc; | |
state | name | st_distance | |
-------+----------------------+------------------- | |
21 | Kentucky | 0 | |
19 | Iowa | 0 | |
55 | Wisconsin | 0 | |
18 | Indiana | 0 | |
29 | Missouri | 0 | |
47 | Tennessee | 0.465497409498616 | |
26 | Michigan | 0.700251907865309 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class FancyString < String | |
attr_accessor :bling | |
end | |
blingful_string = FancyString.new | |
blingful_string.bling = true | |
h = { blingful_string => 1 } | |
puts h.keys.first.bling.inspect # => nil |