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
# mongo_template.rb | |
# fork of Ben Scofield's Rails MongoMapper Template (http://gist.github.com/181842) | |
# | |
# To use: | |
# rails project_name -m http://gist.github.com/gists/219223.txt | |
# remove unneeded defaults | |
run "rm public/index.html" | |
run "rm public/images/rails.png" | |
run "rm public/javascripts/controls.js" |
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
require "test/unit" | |
require "rubygems" | |
require "shikashi" | |
class SystemCalls < Test::Unit::TestCase | |
def test_backtick_call_should_raise_error | |
priv = Shikashi::Privileges.new | |
assert_raise SecurityError do | |
Shikashi::Sandbox.new.run("`ls`", priv) |
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
require "test/unit" | |
require "rubygems" | |
require "mongoid" | |
Mongoid.configure do |config| | |
name = "embed_hash_test" | |
host = "localhost" | |
config.master = Mongo::Connection.new.db(name) | |
config.persist_in_safe_mode = false | |
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
require 'rubygems' | |
require 'rspec' | |
def split(original) | |
original.split("/").inject([]) do |result, element| | |
result + [(result.last||[]) + [element]] | |
end.reverse.map{ |variation| variation.join("/") } | |
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
class RolloverIndex | |
attr_accessor :max, :count | |
def initialize max, start = 0 | |
self.max = max | |
self.count = start | |
end | |
def inc | |
if (self.count + 1) == max |
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
# -*- encoding : utf-8 -*- | |
class Object | |
def scott_trace | |
now = Time.now | |
$last_scott_trace ||= now | |
diff = now - $last_scott_trace | |
notify = diff > 1 ? "!!!!!!!!!!!!!!" : "" | |
puts "#{notify} RAM USAGE: #{`ps -o rss= -p #{$$}`.to_f / 1000.0} MB TIME:#{now - $last_scott_trace}, CALLER: #{CallChain.caller_info.inspect}" | |
$last_scott_trace = now |
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 | |
require 'rubygems' | |
dir = ARGV.first | |
unless dir | |
puts "must supply a directory" unless dir | |
puts "USAGE:" | |
puts "music_convert directory" |
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 ETL #:nodoc: | |
module Transform #:nodoc: | |
# Transform which looks up the value and replaces it with another previously seen in the pipline | |
class PipelineLookupTransform < ETL::Transform::Transform | |
class DuplicateKeyError < ETLError #:nodoc: | |
end | |
# The resolver to use if the foreign key is not found in the collection | |
attr_accessor :resolver | |
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
Apr 26, 2012 4:54:28 PM org.apache.catalina.core.StandardServer await | |
INFO: A valid shutdown command was received via the shutdown port. Stopping the Server instance. | |
Apr 26, 2012 4:54:28 PM org.apache.coyote.AbstractProtocol pause | |
INFO: Pausing ProtocolHandler ["http-bio-8080"] | |
Apr 26, 2012 4:54:28 PM org.apache.coyote.AbstractProtocol pause | |
INFO: Pausing ProtocolHandler ["ajp-bio-8009"] |
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
require 'rspec' | |
require 'rails' | |
require 'shoulda-matchers' | |
CORRECT_ARRAY = %w(one two three) | |
WRONG_ARRAY = %w(wrong array) | |
class Nothing |
OlderNewer