Skip to content

Instantly share code, notes, and snippets.


Benjamin Quorning bquorning

View GitHub Profile
View gist:150903
#!/usr/bin/env ruby
grep_result = `grep -ri "def " #{ARGV.join(' ')}`
methods = grep_result.split("\n").collect do |line|
line[/.*:\s+def ([a-z_]+)(\((.*)\))?/i, 1]
filtered_methods = methods.uniq - ["initialize"]
dirs = (Dir.glob("*") - ['vendor', 'log']).join(" ")
View gist:794778
Errno::EINVAL (Invalid argument):
redis (2.1.1) lib/redis/connection.rb:46:in `write'
redis (2.1.1) lib/redis/connection.rb:46:in `write'
redis (2.1.1) lib/redis/client.rb:60:in `process'
redis (2.1.1) lib/redis/client.rb:59:in `each'
redis (2.1.1) lib/redis/client.rb:59:in `process'
redis (2.1.1) lib/redis/client.rb:154:in `ensure_connected'
redis (2.1.1) lib/redis/client.rb:180:in `ensure_connected'
/usr/local/lib/ruby/1.8/monitor.rb:242:in `synchronize'
redis (2.1.1) lib/redis/client.rb:176:in `synchronize'
bquorning / payex.rb
Created May 16, 2011 — forked from dbackeus/payex.rb
Simple helper module to help communicate with payex.
View payex.rb
module Payex
mattr_accessor :account_number
mattr_accessor :encryption_key
"pxorder/pxorder.asmx/Initialize7" => [:accountNumber, :purchaseOperation, :price, :priceArgList, :currency, :vat, :orderID, :productNumber, :description, :clientIPAddress, :clientIdentifier, :additionalValues, :externalID, :returnUrl, :view, :agreementRef, :cancelUrl, :clientLanguage],
"pxagreement/pxagreement.asmx/CreateAgreement3" => [:accountNumber, :merchantRef, :description, :purchaseOperation, :maxAmount, :notifyUrl, :startDate, :stopDate],
"pxagreement/pxagreement.asmx/DeleteAgreement" => [:accountNumber, :agreementRef],
"pxorder/pxorder.asmx/Complete" => [:accountNumber, :orderRef],
"pxagreement/pxagreement.asmx/AutoPay2" => [:accountNumber, :agreementRef, :price, :productNumber, :description, :orderId, :purchaseOperation],
bquorning / gist:1146099
Created Aug 15, 2011
Careful Cutting To Get Faster RSpec Runs with Rails -- fix for Devise
View gist:1146099
# Don't need passwords in test DB to be secure, but we would like 'em to be
# fast -- and the stretches mechanism is intended to make passwords
# computationally expensive.
module Devise
module Models
module DatabaseAuthenticatable
def valid_password?(password)
return false if encrypted_password.blank?
View rspec-syntax-cheat-sheet.rb
# RSpec 2.0 syntax Cheet Sheet by
# defining spec within a module will automatically pick Player::MovieList as a 'subject' (see below)
module Player
describe MovieList, "with optional description" do
it "is pending example, so that you can write ones quickly"
it "is already working example that we want to suspend from failing temporarily" do
pending("working on another feature that temporarily breaks this one")
bquorning / gist:5325718
Created Apr 6, 2013
Here's the script I use to remove my merged branches, both remote and local. Disclaimer: Don’t blame me if you use this script to remove something you wanted do keep. Maybe add the `-n` flag to `git push` while you’re trying out how the script works. If in trouble, read [man git-reflog](
View gist:5325718
git checkout master
git pull
git remote prune origin
git branch -r --merged | grep bquorning | awk -F'/' '{ print ":" $2 "/" $3 }' | xargs git push origin
git branch --merged | grep -v "\* master" | xargs git branch -d
# That was actually a somewhat simplified version. Here's what I really use:
git checkout master && git pull && (git remote prune origin && git branch -r --merged | grep bquorning | awk -F'/' '{ print ":" $2 "/" $3 }' | xargs git push origin) & ; git branch --merged | grep -v "\* master" | xargs git branch -d
bquorning / post-checkout hook
Last active Dec 17, 2015
Run bundler automatically when needed. Save file as .git/hooks/post-checkout in your project, and do a `chmod +x`. Heavily inspired by
View post-checkout hook
if [ ! `git diff --name-only HEAD@{1}..HEAD Gemfile Gemfile.lock | wc -l` -eq 0 ]
echo -e "\033[0;31m*** Gemfile change detected, running bundle check ***\033[0m"
(unset GIT_DIR ; bundle check || bundle install --local || bundle install)
bquorning / gist:460ad070893cbe498df5
Last active Aug 29, 2015
Uniqueness validation bug in Rails 4.1.10.rc1
View gist:460ad070893cbe498df5
unless File.exist?('Gemfile')
File.write('Gemfile', <<-GEMFILE)
source ''
gem 'rails', '4.1.10.rc1'
gem 'sqlite3'
system 'bundle'
View My project's git pre-commit hook runs Rubocop on changed files
STAGED=$(git diff --cached --name-only --diff-filter=ACM | grep -e '\.rb$' -e '\.rake$' -e '\.ru$' -e Capfile -e 'Gemfile$')
if [ "$STAGED" ]; then
./bin/rubocop -- $STAGED
bquorning / active_record_master.rb
Last active Mar 7, 2016
Eager loaded belongs_to associations are always readonly
View active_record_master.rb
require 'bundler/inline'
rescue LoadError => e
$stderr.puts 'Bundler version 1.10 or later is required. Please update your Bundler'
raise e
gemfile(true) do
source ''
gem 'rails', github: 'rails/rails'
You can’t perform that action at this time.