Skip to content

Instantly share code, notes, and snippets.

View mikegehard's full-sized avatar

Mike Gehard mikegehard

  • Chattanooga, TN
  • 21:55 (UTC -04:00)
View GitHub Profile
@mikegehard
mikegehard / sketch.rb
Created July 5, 2012 00:02 — forked from mattwynne/sketch.rb
Responders implemented using a block instead of another class
class Organization
def to_param
"42"
end
def saved?
rand > 0.5
end
end
@mikegehard
mikegehard / config.ru
Created March 5, 2012 20:05
Rails Lightweight Stack. Most of this is detailed on Crafting Rails Applications - http://pragprog.com/book/jvrails/crafting-rails-applications
# Run this file with `RAILS_ENV=production rackup -p 3000 -s thin`
# Be sure to have rails and thin installed.
require "rubygems"
# We are not loading Active Record, nor the Assets Pipeline, etc.
# This could also be in your Gemfile.
gem "actionpack", "~> 3.2"
gem "railties", "~> 3.2"
# The following lines should come as no surprise. Except by
@mikegehard
mikegehard / gist:983110
Created May 20, 2011 15:08
Javascript Pattern for Namespacing javascript
// This is a good pattern to namespace javascript.
// Passing in jQuery assures that $ in our functions always refers to jquery
// Also a good pattern to pass in event to handers as that is the default for jQuery
// in a handler the "this" refers to the DOM element that caused the element.
window.Hello = {};
(function($, namespace){
namespace.Bar = {};
// Use jQuery to add your methods.
$.extend(namespace.Bar, {
@mikegehard
mikegehard / 0_README.md
Created May 5, 2011 02:39 — forked from netzpirat/0_README.md
Continuous CoffeeScript testing with Guard and Jasmine

Continuous CoffeeScript testing with Guard and Jasmine

This Gist shows how to set up a Rails project to practice BDD with CoffeeScript, Guard and Jasmine. You can see this setup in action on Vimeo

  • Install Gems with Bundler with bundle install
  • Define your guards with mate Guardfile
  • Initialize Jasmine with bundle exec jasmine init
  • Configure Jasmine with mate spec/support/yasmine.ym
  • Start Guard with bundle exec guard
@mikegehard
mikegehard / gist:954537
Created May 4, 2011 00:35
Waiting until all jquery ajax calls are done
//Useful if you have a slow CI server...
When /^I wait until all Ajax requests are complete$/ do
wait_until do
page.evaluate_script('$.active') == 0
end
end
@mikegehard
mikegehard / gist:853253
Created March 3, 2011 18:41
Testing OmniAuth login via cucumber...
Before('@omniauth_test') do
OmniAuth.config.test_mode = true
# the symbol passed to mock_auth is the same as the name of the provider set up in the initializer
OmniAuth.config.mock_auth[:google] = {
"provider"=>"google",
"uid"=>"http://xxxx.com/openid?id=118181138998978630963",
"user_info"=>{"email"=>"test@xxxx.com", "first_name"=>"Test", "last_name"=>"User", "name"=>"Test User"}
}
end
@mikegehard
mikegehard / Almond milk recipe
Created February 13, 2011 17:07
Almond Milk Recipe
Almond Milk Recipe from Rawsome! by Brigette Mars
1 cup almonds, soaked overnight, then rinsed
1 quart water
Honey (or anything else you care to add) to taste
Combine all ingredients in a blender and liquify.
Strain through a nut milk bag or sprout bag. I had a hard time finding either in Boulder (go figure) so I just used an old, clean pantyhose.
Store in the refrigerator. Lasts about a week.
@mikegehard
mikegehard / gist:600110
Created September 27, 2010 23:48
List of interesting gems
VCR (recording and playing back web service calls)
http://github.com/myronmarston/vcr
Pusher (WebSockets made easy)
http://www.pusherapp.com/
http://www.rubyinside.com/pusher-websocket-service-3246.html
@mikegehard
mikegehard / Webdriver
Created September 17, 2010 20:17
Using firebug with cucumber/webdriver
Use capybara-firebug
@mikegehard
mikegehard / Stack trace for Cucumber features
Created September 16, 2010 12:47
Stack trace for failing Cucumber features in factory_girl_rails
[@1.9.2@factory_girl_rails ][msgehard@localhost:factory_girl_rails(master)]$ rake --trace
(in /Users/msgehard/Documents/Development/rubyDevelopment/gems_source/factory_girl_rails)
** Invoke default (first_time)
** Invoke cucumber (first_time)
** Execute cucumber
bundle exec /Users/msgehard/.rvm/rubies/ruby-1.9.2-p0/bin/ruby -I "/Users/msgehard/.rvm/gems/ruby-1.9.2-p0@factory_girl_rails/gems/cucumber-0.8.5/lib:lib" "/Users/msgehard/.rvm/gems/ruby-1.9.2-p0@factory_girl_rails/gems/cucumber-0.8.5/bin/cucumber" --format progress
Using the default profile...
$ /Users/msgehard/.rvm/rubies/ruby-1.9.2-p0/bin/ruby -S rails new test_app