Skip to content

Instantly share code, notes, and snippets.

View bquorning's full-sized avatar

Benjamin Quorning bquorning

View GitHub Profile
# RSpec 2.0 syntax Cheet Sheet by http://ApproachE.com
# 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
bquorning / gist:1146099
Created August 15, 2011 12:05
Careful Cutting To Get Faster RSpec Runs with Rails -- fix for Devise
# 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?
@bquorning
bquorning / payex.rb
Created May 16, 2011 09:09 — forked from dbackeus/payex.rb
Simple helper module to help communicate with payex.
module Payex
mattr_accessor :account_number
mattr_accessor :encryption_key
MD5_CHECK_FIELDS = {
"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],
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'
#!/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]
end
filtered_methods = methods.uniq - ["initialize"]
dirs = (Dir.glob("*") - ['vendor', 'log']).join(" ")
#!/bin/sh
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
fi
@bquorning
bquorning / gist:460ad070893cbe498df5
Last active August 29, 2015 14:16
Uniqueness validation bug in Rails 4.1.10.rc1
unless File.exist?('Gemfile')
File.write('Gemfile', <<-GEMFILE)
source 'https://rubygems.org'
gem 'rails', '4.1.10.rc1'
gem 'sqlite3'
GEMFILE
system 'bundle'
end