Discover gists
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
it "should have acts_as_list functionality" do | |
@sec1 = sections(:teaching) | |
@sec2 = sections(:scholarship) | |
@sec1.should be_in_list | |
@sec2.should be_in_list | |
(@sec1.position < @sec2.position).should be_true | |
@sec2.move_higher | |
(@sec1.position > @sec2.position).should be_true | |
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 PragDave: | |
# http://pragdave.blogs.pragprog.com/pragdave/2008/04/babydoc.html | |
require 'ripper' | |
# This class handles parser events, extracting | |
# comments and attaching them to class definitions | |
class BabyRDoc < Ripper::Filter | |
def initialize(*) | |
super |
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
#!/usr/bin/env ruby | |
## Will add a new rails host for the specified directory. | |
## Usage: sudo board-train directory domain | |
if ARGV[0].nil? || ARGV[1].nil? | |
puts "Usage: #{__FILE__} directory domain" | |
exit | |
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
#!/usr/bin/env ruby | |
## Will add a new rails host for the specified directory. | |
## Usage: sudo board-train directory domain | |
if ARGV[0].nil? || ARGV[1].nil? | |
puts "Usage: #{__FILE__} directory domain" | |
exit | |
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
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" name="flash" width="500" height="495" align="middle" id="flashmo_058_mp3_player_xml"> | |
<param name="allowScriptAccess" value="sameDomain" /> | |
<param name="movie" value="/swf/player.swf" /> | |
<param name="quality" value="high" /> | |
<param name="menu" value="false" /> | |
<param name="bgcolor" value="#EEEEEE" /> | |
<param name="flashvars" value="playlist=/play_lists/index?user_id=61&cp=http://demo.urbmob.com/&server_date=<%= Time.now.strftime("%Y-%m-%d") %>&user_id=<%= current_user.id if logged_in? %>" /> | |
<embed src="/swf/player.swf" quality="high" menu="false" flashvars="playlist=/play_lists/index?user_id=61&cp=http://demo.urbmob.com/&server_date=<%= Time.now.strftime("%Y-%m-%d") %>&user_id=<%= current_user.id if logged_in? %>" bgcolor="#EEEEEE" width="500" height="495" name="flash" align="middl |
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
;; Issac Trotts' demonstration of pattern matching in Nu | |
(function people-to-string (people) | |
(match people | |
(() "no people") | |
((p1) "one person: #{p1}") | |
((p1 p2) "two people: #{p1} and #{p2}") | |
(else "too many people: #{(people length)}"))) | |
(assert_equal "no people" |
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
#!/usr/bin/ruby | |
# fortunebot.rb - simple fortune / twitter bot | |
# non-copyright (c) 2008 rodrigo franco <caffo@imap.cc> | |
# | |
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | |
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
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
# Marcel Molina's REST/CRUD conventions | |
# http://project.ioni.st/post/2283#snippet_2283 | |
class ApplicationController < ActionController::Base | |
def self.set_resource(resource, &custom_setter) | |
filter_name = :"set_#{resource}" | |
before_filter filter_name, :only => [:show, :edit, :update, :destroy] | |
if custom_setter | |
define_method(filter_name) do |
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
try | |
{ | |
beginAt(atUrl); | |
} | |
catch (RuntimeException re) | |
{ | |
// If we get here, it's possible that we are running on java 1.5 + | |
// and the server is websphere. in this combination (and only this | |
// one AFAIK) the HttpUnit client receives a null from | |
// HttpUrlConnection.getErrorStream() which, according to the JDK javadoc |