Skip to content

Instantly share code, notes, and snippets.

View cmhobbs's full-sized avatar
🍩
Waiting between the walls.

Hobbs cmhobbs

🍩
Waiting between the walls.
View GitHub Profile
ruby-1.9.2-p0 > def greeter name
ruby-1.9.2-p0 ?> print "hello, #{name}"
ruby-1.9.2-p0 ?> end
=> nil
ruby-1.9.2-p0 > greeter "hooobs"
hello, hooobs => nil
ruby-1.9.2-p0 > greeterhash = { "greet" => greeter }
ArgumentError: wrong number of arguments (0 for 1)
from (irb):2:in `greeter'
from (irb):6
@cmhobbs
cmhobbs / gist:999880
Created May 31, 2011 04:46
rubinius install fails with rvm, only available ruby is 1.9.2
[2011-05-30 23:43:25] /usr/local/rvm/wrappers/rbx-head/ruby ./configure --prefix=/usr/local/rvm/rubies/rbx-head --skip-system
You are attempting to build using the instance of Rubinius that you are building.
To resolve this issue:
* Remove '/usr/local/rvm/rubies/rbx-head/bin' from your PATH.
* Use a Ruby executable other than '/usr/local/rvm/rubies/rbx-head/bin/rbx' to build.
'configure' has failed. Please check configure.log for more details.
@cmhobbs
cmhobbs / gist:1001747
Created June 1, 2011 03:32
playing with nested and subclasses
ruby-1.9.2-p180 :046 > Class Foo
NameError: uninitialized constant Object::Foo
from (irb):46
from /home/christopher/.rvm/rubies/ruby-1.9.2-p180/bin/irb:16:in `<main>'
ruby-1.9.2-p180 :047 > class Foo
ruby-1.9.2-p180 :048?> class Bar
ruby-1.9.2-p180 :049?> end
ruby-1.9.2-p180 :050?> end
=> nil
ruby-1.9.2-p180 :051 > Foo.new
!!!
%html
%head
%meta{'http-equiv' => 'Content-Type', :content => 'text/html; charset=UTF-8'}/
%body
%p== Yo #{@user.first_name},
%p== We heard you like testing mailers, so we put a mailer in your spec so you could test while you mail!
%p
= link_to "Click this here link!", swanky_meme_url
%p
@cmhobbs
cmhobbs / notifier.rb
Created August 16, 2011 21:22
Resque multiple failure notifier via postmark
# this goes in lib/resque/failure/notifier.rb
require 'resque/failure/multiple'
require 'resque/failure/redis'
require 'postmark'
require 'mail'
module Resque
module Failure
class Notifier < Base
@cmhobbs
cmhobbs / post.rb
Created September 3, 2011 19:30
Building a custom Resque::Failure backend for resque-retry
# fancy code here for the post model
extend Resque::Plugins::Retry
@queue = :posts
# set to 120 limit at 30 delay (one post every 30sec for 1hr)
@retry_limit = 120
@retry_delay = 30
# more fancy post model code here as well
@cmhobbs
cmhobbs / watchers.rb
Created October 22, 2011 23:59
execute_watchers from redis-health
def execute_watches
self.class.watchers.collect do |watcher_array|
label, watcher_hash = watcher_array
triggered_times[label] ||= 0
matcher_result = self.instance_eval(&watcher_hash[:matcher])#.call(@redis)
triggered = matcher_result[:triggered]
value = matcher_result[:value]
notice = append_label_value(label, value, triggered)
times_was = triggered_times[label]
require 'rubygems'
require 'sinatra'
require 'redis'
# To use, simply start your Redis server and boot this
# example app with:
# ruby example_note_keeping_app.rb
#
# Point your browser to http://localhost:4567 and enjoy!
#
source 'http://rubygems.org'
gem 'scamp'
gem 'slop'
gem 'minitest'
[22:40][christopher@hbp:~]$ rvm install rbx -- --default-version=1.9
rbx-head installing #dependencies
Pulling from origin head
ERROR: Error running 'git reset --hard HEAD ; git pull --rebase origin head', please read /Users/christopher/.rvm/log/rbx-head/rbx.repo.log
Copying from repo to source...
rbx-head - #configuring
ERROR: Error running '/Users/christopher/.rvm/wrappers/ruby-1.8.7-p334/ruby ./configure --prefix=/Users/christopher/.rvm/rubies/rbx-head --skip-system --default-version=1.9', please read /Users/christopher/.rvm/log/rbx-head/configure.log
ERROR: There has been an error while running '/Users/christopher/.rvm/wrappers/ruby-1.8.7-p334/ruby ./configure --prefix=/Users/christopher/.rvm/rubies/rbx-head --skip-system --default-version=1.9'.
Halting the installation.