Skip to content

Instantly share code, notes, and snippets.

View darrenboyd's full-sized avatar

Darren Boyd darrenboyd

View GitHub Profile
@darrenboyd
darrenboyd / gist:15403
Created October 7, 2008 22:25
Adding the asset information to the Channel
def to_xml(options={})
options[:procs] ||= []
options[:procs] << Proc.new() do |options|
options[:builder].tag!('big-image-url', "http://#{EMAIL_DOMAIN_NAME}#{big_image.uri_path}")
end
super
end
<<EOF
That code produces...
#!/usr/bin/ruby
xml_str = %Q{<peon>
<id>96586</id>
<stdout><![CDATA[This is STDOUT]]></stdout>
<stderr><![CDATA[This is STDERR]]></stderr>
</peon>}
require 'rubygems'
# gem 'hpricot', '0.6'
require 'timeout'
def test_timeout(timeout_timeout, count, &block)
pass = timeout = error = 0
count.times do |i|
begin
Timeout::timeout(timeout_timeout, &block)
pass += 1
rescue Timeout::Error => e
timeout += 1
namespace :deploy do
namespace :gate do
task :default do
if "#{stage}" == "production"
stg = CLI.ui.ask "Which environment are you deploying to again? "
unless stg == "#{stage}"
puts "I am not convinced, sorry."
exit(1)
end
# I found I had to do this in my Gemfile to get Bundler to load Rails 2.3.5
gem 'rails', '2.3.5', :require => nil
gem 'builder', '2.1.2'
gem 'tzinfo', '0.3.16'
gem 'i18n', '0.3.3'
gem 'tmail', '1.2.6'
[user]
# email = ...
# name = ...
# [color]
# branch = auto
# diff = auto
# status = auto
# [color "branch"]
# current = yellow reverse
--type-add=objc=.pch
--type-set=xcode=.pbxproj,.pbxuser,.perspectivev3
--type-set=ragel=.rl
--type-set=nib=.xib
--type-set=plist=.plist
--type-set=tmstuff=.tmproj,.tm_build_errors
--nonib
--notmstuff
--noxcode
@darrenboyd
darrenboyd / class_var_confusion.rb
Created September 30, 2011 19:21
Class Variable Confusion in Ruby
class A
@@a = 1
def val
@@a += 1
end
end
class B < A
@@a = 2
def val
@darrenboyd
darrenboyd / example_rdoc.rb
Created November 2, 2011 18:57
Example of using @method
module Stuff
def create_dynamic_method
end
end
class Foo
extend Stuff
# Tells you what is static
#
@darrenboyd
darrenboyd / api_responder.rb
Created April 4, 2012 19:37
A Rails Responder for mrss
class ApiResponder < ActionController::Responder
# MRSS is not a 'real' type.
# The Media RSS specification builds on top of the RSS
# specification. We want to use the following formats
# in our application...
# - xml
# - json
# - rss
# - mrss