Skip to content

Instantly share code, notes, and snippets.

var options = {
"gender": "#{search_params['gender']}",
"age": "#{current_user.age}",
"language": "#{search_params['language']}",
class NilObject
def initialize(klass=nil)
@klass=klass
end
def method_missing(name, *args)
return self unless @klass
klass.new.respond_to? name ? self : super
end
end
class Duck < ActiveRecord::Base
def awake?
status == 'awake'
end
def quack
puts quack_style
end
end
@stephenaument
stephenaument / split.rb
Created February 11, 2013 21:55
Ruby script to split a 60 minute mp3 file into two minute segments with a five second overlap.
#! /usr/bin/ruby
# Split the given mp3 file into 2:05 minute pieces
file_name = ARGV[0]
# file_length = ARGV[1]
dir_name = file_name.split('.').first
`mkdir #{dir_name}`
@stephenaument
stephenaument / bwi-base.rb
Created October 12, 2012 15:15
bwi_respond_with method
module ActionController #:nodoc:
class Base
def bwi_respond_with(*resources, &block)
options = {}
methods = [:pkid]
options = resources.pop if resources.size > 1 && resources.last.is_a?(Hash)
if options[:methods]
if options[:methods].is_a?(Array)