module Mode
class Constraint
def initialize(mode)
@mode = mode
end
def matches?(_request)
@mode == Rails.application.config.mode # configured from the environment
end
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Slug | |
CIPHER = 'RC2'.freeze | |
def initialize(key, iv) | |
@key = key | |
@iv = self.class.hex_to_bytes(iv) | |
end | |
def self.generate_iv | |
bytes_to_hex(OpenSSL::Cipher.new(CIPHER).random_iv) |
I hereby claim:
- I am spannerinworks on github.
- I am spannerinworks (https://keybase.io/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:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/)) | |
d.meh(a) | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'ostruct' | |
id = OpenStruct.new(to_i: 'BAD SQL') | |
bad_event = OpenStruct.new(id: id) | |
# > bad_event.id.to_i | |
# => "BAD SQL" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export HOMEBREW_GITHUB_API_TOKEN=0123456789abcdef | |
export JAVA_HOME=$(/usr/libexec/java_home) | |
export PATH="~/scripts:$PATH" | |
if [ ! -z "$PS1" ] ; then | |
source ~/scripts/git-prompt.sh | |
RVM_PROMPT="\[\033[1;36m\]\$(rvm-prompt.sh)\[\033[0m\]" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
&: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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl -pi | |
$branch = `git symbolic-ref HEAD`; | |
chomp($branch); | |
$branch =~ s|^refs/heads/(MYC.\d+).*|\1|; | |
print "[${branch}] " if ($. == 1 && $branch =~ /^MYC.\d+$/); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
END | |
$ heroku run "perl -pe 'exit if /^END$/; s/(\w)/\1\1/g;'" < input.txt > output.txt |
NewerOlder