Skip to content

Instantly share code, notes, and snippets.

View ddonahue99's full-sized avatar

Dave Donahue ddonahue99

  • AllTrails
  • Seattle, WA
View GitHub Profile
{
"name": "main",
"common": {
"container": {
"environment": {
"NODE_ENV": "development",
"MONGO_URI": "mongodb://mongo:27017",
"REDIS_URI": "redis",
"EVENT_SERVER": "nats://nats-streaming:4222",
"RUN_MIGRATIONS_UP": "true",
@ddonahue99
ddonahue99 / token_input_helpers.rb
Last active December 20, 2015 10:31 — forked from jtanium/token_input_helpers.rb
jquery.tokeninput.js cucumber helper, updated with capybara 2.1 and theme support
module TokenInputHelpers
THEME = '' # set to 'facebook' or 'mac' if using themes
def token_input(locator, options)
raise "Must pass a hash containing 'with'" unless options.is_a?(Hash) && options.has_key?(:with)
theme = THEME.present? ? "-#{THEME}" : ""
field = _find_fillable_field(locator) # find the field that will ultimately be sent to the server, the one the user intends to fill in
@ddonahue99
ddonahue99 / gist:3098825
Created July 12, 2012 15:20
rake db:remove_orphans - detects orphans based on belongs_to relations and prompts to remove
namespace :db do
desc "Remove orphans"
task :remove_orphans => :environment do
Dir[Rails.root + "app/models/**/*.rb"].each do |path|
require path
end
ActiveRecord::Base.send(:descendants).each do |model|
model.reflections.each do |association_name, reflection|
if reflection.macro == :belongs_to
delete_all_like_this = false
@ddonahue99
ddonahue99 / gist:1201564
Created September 7, 2011 20:00
Backbone example
(function($){
var Project = Backbone.Model.extend({
url: function() {
return '/heroku/resources/' + this.id + '.json';
},
display: function() {
this.fetch({
success: function(model, response) {
$('#git_url').val(model.get('git_url'));
@ddonahue99
ddonahue99 / gist:1200789
Created September 7, 2011 14:55
Controller spec with expectation
'renders 404 when the project is not found': (controller) ->
@response = new mocks.Response()
@response.render = (params...) ->
@correct = (params[0] == '404')
controller.show(new mocks.Request(app_id: 1), @response)
assert.ok @response.correct
@ddonahue99
ddonahue99 / gist:970901
Created May 13, 2011 17:05
NetHTTP seg fault in Ruby 1.9.2 with ActiveMerchant/Authorize.net
ruby-1.9.2-p180 :024 > response = gateway.purchase(1000, credit_card, options)
/Users/ddonahue/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/net/http.rb:678: [BUG] Segmentation fault
ruby 1.9.2p180 (2011-02-18 revision 30909) [x86_64-darwin10.7.0]
-- control frame ----------
c:0047 p:---- s:0218 b:0218 l:000217 d:000217 CFUNC :connect
c:0046 p:0011 s:0215 b:0215 l:000bd0 d:000214 BLOCK /Users/ddonahue/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/net/http.rb:678
c:0045 p:0109 s:0213 b:0213 l:0001e0 d:0001e0 METHOD /Users/ddonahue/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/timeout.rb:57
c:0044 p:0026 s:0201 b:0201 l:000200 d:000200 METHOD /Users/ddonahue/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/timeout.rb:87
c:0043 p:0444 s:0195 b:0195 l:000bd0 d:000bd0 METHOD /Users/ddonahue/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/net/http.rb:678