Skip to content

Instantly share code, notes, and snippets.

View jherdman's full-sized avatar

James Herdman jherdman

View GitHub Profile
@jherdman
jherdman / controllers.application.js
Created April 25, 2018 15:06 — forked from samselikoff/controllers.application.js
Mirage: create with polymorphic
import Ember from 'ember';
export default Ember.Controller.extend({
});
# parses out the current branch you're on. See: http://www.harukizaemon.com/2008/05/deploying-branches-with-capistrano.html
current_branch = `git branch`.match(/\* (\S+)\s/m)[1]
# use the branch specified as a param, then use the current branch. If all fails use master branch
set :branch, ENV['branch'] || current_branch || "master" # you can use the 'branch' parameter on deployment to specify the branch you wish to deploy
@jherdman
jherdman / README.md
Last active January 11, 2022 05:49 — forked from ankane/README.md
A Gem loading benchmark script

Benchmark Bundler

Because loading gems can take longer than you think

$ curl -fsSL https://gist.github.com/jherdman/5025684/raw/a3ccd4b5308723245706b4ae315845fe951b4473/benchmark.rb | ruby
............................................................[DONE]

Gem                            Time(sec)     Pct %
--------------------------------------------------
@jherdman
jherdman / delegate_matcher.rb
Created September 6, 2011 13:58 — forked from txus/delegate_matcher.rb
RSpec matcher for delegations
# RSpec matcher to spec delegations.
#
# Usage:
#
# describe Post do
# it { should delegate(:name).to(:author).with_prefix } # post.author_name
# it { should delegate(:month).to(:created_at) }
# it { should delegate(:year).to(:created_at) }
# end
Feature: Pricing
In order to purchase two items from the store
As a Store user
I should be able to add two items and checkout with the right price displayed
Scenario: Successful checkout
Given the user adds the "Unique Ability" product to the cart
And then adds "Strategy Circle Software" product to the cart
When the user views the cart, it should have 2 items totalling "$130"
Then the user logs in and confirms the right price
#!/usr/bin/ruby
#
# I deliberately didn't DRY /usr/local references into a variable as this
# script will not "just work" if you change the destination directory. However
# please feel free to fork it and make that possible.
#
# If you do fork, please ensure you add a comment here that explains what the
# changes are intended to do and how well you tested them.
#
# 14th March 2010:
# mongo_template.rb
# remove unneeded defaults
run "rm public/index.html"
run "rm public/images/rails.png"
run "rm public/javascripts/controls.js"
run "rm public/javascripts/dragdrop.js"
run "rm public/javascripts/effects.js"
run "rm public/javascripts/prototype.js"
# an example Monit configuration file for delayed_job
#
# To use:
# 1. copy to /var/www/apps/{app_name}/shared/delayed_job.monitrc
# 2. replace {app_name} and {environment} as appropriate
# 3. add this to your /etc/monit/monitrc
#
# include /var/www/apps/{app_name}/shared/delayed_job.monitrc
check process delayed_job with pidfile /var/www/apps/{app_name}/shared/pids/delayed_job.pid
def generate(params, defaults = {})
param_or_default = lambda { |p, d, k| (p[k] || d[k]).to_s }
matches = lambda { |v| v =~ /^(?-mix:[^\/.,;?]+)$/ }
v_controller = param_or_default.call(params, defaults, :controller)
v_action = param_or_default.call(params, defaults, :action)
v_id = param_or_default.call(params, defaults, :id)
unless matches.call(v_controller)
raise ArgumentError, "Condition cannot be generated with #{params.inspect}"