Skip to content

Instantly share code, notes, and snippets.

Ben Wong spannerinworks

Block or report user

Report or block spannerinworks

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:2767931
# ---------------------------
# In config/application.yml :
# development:
# blah: "foo"
# test:
# blah: "bar"
# ---------------------------
# In app:
spannerinworks / gist:2789543
Created May 25, 2012
Running a script on heroku and piping input and output
View gist:2789543
Don't expect pretty, it's a hack...
We need and END marker on the input because we have to tell the script to exit
$ cat > input.txt
a quick brown
fox jumple over the
laszy dog
$ heroku run "perl -pe 'exit if /^END$/; s/(\w)/\1\1/g;'" < input.txt > output.txt
spannerinworks / commit-msg
Created Apr 30, 2013
git hook to prepend story number to commit messages
View commit-msg
#!/usr/bin/perl -pi
$branch = `git symbolic-ref HEAD`;
$branch =~ s|^refs/heads/(MYC.\d+).*|\1|;
print "[${branch}] " if ($. == 1 && $branch =~ /^MYC.\d+$/);
spannerinworks / fullcross.css
Created Oct 22, 2013
Possible fix for uncentred "+" in new collection
View fullcross.css
&:before {
@include border-radius(20px);
color: white;
position: absolute;
background-color: $link-text-colour;
content: "\FF0B";
font-size: 30px;
height: 40px;
width: 40px;
left: 0;
export HOMEBREW_GITHUB_API_TOKEN=0123456789abcdef
export JAVA_HOME=$(/usr/libexec/java_home)
export PATH="~/scripts:$PATH"
if [ ! -z "$PS1" ] ; then
source ~/scripts/
View bad_event.rb
require 'ostruct'
id = 'BAD SQL')
bad_event = id)
# >
# => "BAD SQL"
spannerinworks /
Created Mar 18, 2015
Remigrate test database to create a clean schema.rb. For use during rebasing or when you have a dirty dev DB.
set -v
git show integration:db/schema.rb > db/schema.rb
RAILS_ENV=test rake db:drop
RAILS_ENV=test rake db:create
RAILS_ENV=test rake db:schema:load
RAILS_ENV=test rake db:migrate
View rspec_hash_with_regex_spec.rb
RSpec.describe 'test' do
it 'works' do
a = {a: 1, b: 'foobar'}
d = double
expect(d).to receive(:meh).with(a: 1, b: match(/ob/))

Keybase proof

I hereby claim:

  • I am spannerinworks on github.
  • I am spannerinworks ( on keybase.
  • I have a public key whose fingerprint is B78E C80C 409B 7EA3 6E59 7009 AD07 BFEE A1C4 AA4A

To claim this, I am signing this object:

spannerinworks /
Last active Aug 17, 2017
Route toggling with contraints
module Mode
  class Constraint
    def initialize(mode)
      @mode = mode

    def matches?(_request)
      @mode == Rails.application.config.mode # configured from the environment
You can’t perform that action at this time.