Skip to content

Instantly share code, notes, and snippets.

View anthonycrumley's full-sized avatar

Anthony Crumley anthonycrumley

View GitHub Profile
@anthonycrumley
anthonycrumley / view_dsl.textile
Created May 7, 2009 18:09
Rails view DSL notes

Rails needs to support the creation of view DSLs. This could be called by the plugin on initialization or by the app in the environment.rb.

ActionView::Dsl.load Gridzilla::Base ActionView::Dsl.unload Gridzilla::Base

Instance level sub-DSLs that would be used in the higher level DSL.

self.load_dsl Gridzilla::Rows self.load_dsl Gridzill::Rows
@anthonycrumley
anthonycrumley / lighter.rb
Created June 17, 2009 16:05 — forked from macournoyer/lighter.rb
Added Growl
# Lighter -- Campfire from the command line
# usage: ruby lighter.rb subdomain "Main Room" macournoyer@gmail
require "rubygems"
require "tinder"
require "readline"
require "highline/import"
require "growl"
class Lighter
def initialize(room)
module RubyTransport
class Evaller
def self.eval_it
((Kernel.methods + methods) - ['eval']).each{|m| eval("def self.#{m}; end")}
(Module.constants - ['Date', 'Time', 'DateTime']).sort.each{|c| eval("module #{c} end")}
x = nil
#eval("x=ActiveRecord::Base.connection.adapter_name")
#eval("x=Migration.connection.adapter_name")
#eval("exec 'echo *'")
module RubyTransport
class Evaller
((Kernel.methods + methods) - ['eval']).each{|m| eval("def self.#{m}; end")}
(Module.constants - ['Date', 'Time', 'DateTime']).sort.each{|c| eval("module #{c} end")}
def self.eval_it
x = nil
#eval("x=ActiveRecord::Base.connection.adapter_name")
#eval("x=Migration.connection.adapter_name")
#eval("exec 'echo *'")
class Tool < Thor
desc "up", "Makes our customer support folks happy."
method_options %w( dry_run -d ) => false
def up
# do something useful...
end
end
#!/bin/sh
set -ex
# Snow Leopard Samba Fix
echo "[default]" > ~/Library/Preferences/nsmb.conf
echo "streams=no" >> ~/Library/Preferences/nsmb.conf
# Remove system gems
sudo rm -r /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8
@anthonycrumley
anthonycrumley / have_sent_email.rb
Created July 18, 2013 14:27
Issues with Shoulda and domain model unit tests.
require 'test_helper'
class GF::Appointments::FooTest < ActiveSupport::TestCase
# In non-ActiveRecord classes that use Shoulda a subject must be
# defined to use the should dsl method. Otherwise it will try to
# instantiate a class based on the class name of the test, in this
# case it tries to instantiate GF::Appointments::Foo. This instantiation
# fails if the initializer has required parameters and may have other
# undesirable side effects.
subject { Object.new }
require File.dirname(__FILE__) + '/../test_helper'
class RangeTest < Test::Unit::TestCase
test <<-TEST do
Range#coinsides_with?
|
|
TEST
range = Time.zone.now..Time.zone.now
require File.dirname(__FILE__) + '/../test_helper'
class RangeTest < ActiveSupport::TestCase
test "Range#coinsides_with?" do
range_1 = Time.zone.now..Time.zone.now
range_2 = range_1
assert (range_1).coinsides_with?(range_2), <<-MESSAGE
Ranges should coincide but don't!
1 |
2 |
require 'haml'
def line_counter(node)
decendants = node.children.map{|n| line_counter(n)}
if node.type == :filter && %w{ javascript erb plain }.include?(node.value[:name])
me = node.value[:text].split("\n").length
else
me = 0
end
sum(decendants) + me