Skip to content

Instantly share code, notes, and snippets.

View supaspoida's full-sized avatar

Lar Van Der Jagt supaspoida

View GitHub Profile
require 'test/unit'
class HelloWorldTest < Test::Unit::TestCase
def test_hello_world
object = HelloWorld.new
assert_equal "hello world", object.hello_world
end
end
Having some trouble using merb-parts to render a mailing list signup form. Tried with both Haml & Erb and can get the expected results.
Here is the source for the part I'm using:
class ContactFormPart < Merb::PartController
def new
@contact = Contact.new
@redirect_to = params[:redirect_to]
render
# Typical way of handling the email in the controller
class UsersController < ApplicationController
def create
@user = User.new params[:user]
UserMailer.deliver_welcome(@user) if @user.save
end
end
#!/usr/bin/env ruby
require 'fileutils'
def fail!(msg = "Failure!")
puts(msg)
exit(1)
end
REPOSITORY_URL = 'git://github.com/mxcl/homebrew.git'
PACKAGE_URL = 'http://github.com/mxcl/homebrew/tarball/master'
@supaspoida
supaspoida / resque_helper.rb
Created December 2, 2010 15:10
enable resque jobs in integration tests
module ResqueHelper
def with_resque
Resque.module_eval do
def self.enqueue(task, *args)
task.perform(*args)
end
end
yield
Resque.module_eval do
def self.enqueue(task, *args)
@supaspoida
supaspoida / gist:908159
Created April 7, 2011 16:38
bundle rails 3.0.6 stack overflow
Users/dev/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems/specification.rb:340:in `block in initialize'
/Users/dev/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems/specification.rb:333:in `each'
/Users/dev/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems/specification.rb:333:in `initialize'
/Users/dev/.rvm/gems/ruby-1.9.2-p180@loosecubes/gems/bundler-1.0.11/lib/bundler/remote_specification.rb:52:in `new'
/Users/dev/.rvm/gems/ruby-1.9.2-p180@loosecubes/gems/bundler-1.0.11/lib/bundler/remote_specification.rb:52:in `method_missing'
/Users/dev/.rvm/gems/ruby-1.9.2-p180@loosecubes/gems/bundler-1.0.11/lib/bundler/resolver.rb:101:in `block in __dependencies'
/Users/dev/.rvm/gems/ruby-1.9.2-p180@loosecubes/gems/bundler-1.0.11/lib/bundler/resolver.rb:98:in `each'
/Users/dev/.rvm/gems/ruby-1.9.2-p180@loosecubes/gems/bundler-1.0.11/lib/bundler/resolver.rb:98:in `__dependencies'
/Users/dev/.rvm/gems/ruby-1.9.2-p180@loosecubes/gems/bundler-1.0.11/lib/bundler/resolver.rb:68:in `activ
@supaspoida
supaspoida / regext.txt
Created August 23, 2011 20:57 — forked from jt/regext.txt
Regular expression notes
- any character you use it will literally match it except special characters
^ $ ? . / \ [ ] { } ( ) + * - all the special characters that will need escaping if you don't want them to be special
// - regexp ruby class
Common Patterns (I authored)
/[\w+\.~-]+@[\w~-]+.[\w\.]+/ - match emails, conforms to RFC 3986 section 3.3
/\+?(\d)?[-|\.|\s]?\(?(\d{3})\)?[-|\.|\s]?(\d{3})[-|\.|\s]?(\d{4})/ - match phone numbers, https://gist.github.com/1009331
Strategies
@supaspoida
supaspoida / .vimrc.local
Created September 3, 2011 21:07
Convert hashes to 1.9.2 style with vim
# Run :NotRocket to convert current buffer.
# Thanks to @tpope for the vim regex fu
command! -bar -range=% NotRocket :<line1>,<line2>s/:\(\w\+\)\s*=>/\1:/ge

Welcome to Drift!

Drift is an always-already versioned, cloud-backed text editor. You can use it to take notes, and save them in the GitHub cloud.

Your gists are always saved locally, and any changes you make will get pushed to GitHub's servers.

To name a gist, touch its name in the toolbar.

You can use the share button at the top-right to copy a link to one of your gists, or view it on the web in Safari.

@supaspoida
supaspoida / nav.html.haml
Created October 6, 2011 17:33
Navigation "DSL"
%ul{class: navigation.current_selector}
- navigation.items.each do |item|
%li{class: item.selector}= link_to item.text, item