Skip to content

Instantly share code, notes, and snippets.

View JonRowe's full-sized avatar
💭
⛵️

Jon Rowe JonRowe

💭
⛵️
View GitHub Profile
@JonRowe
JonRowe / heroku_ruby_yaml.rb
Created February 8, 2014 01:37
Update heroku apps running old versions of libyaml.
require 'json'
class Shell
def self.heroku_apps
new('heroku apps').cache_at 'heroku_app_cache'
end
def self.ruby_version app
new("heroku run \"ruby -v\" --app #{app}").cache_at "ruby_version_#{app}"
end
module B
def a
puts 'b'
super
end
end
class A
class << self; prepend B; end
def self.a
@JonRowe
JonRowe / db_spec_helper.rb
Last active August 29, 2015 13:57
Delay the slow things!
# An example used to segregate DB loading to those specs requiring it only.
RSpec.configure do |config|
config.include DBHelper::DB, db: true
config.include DSL::Setup, db: true
config.before(:all, db: true) do
DBHelper.load!
end
@JonRowe
JonRowe / pre-recieve-hook
Last active August 29, 2015 13:57
A git pre-receive hook for Ruby deploying.
#!/bin/bash
# Let's deploy...
echo "Deploying..."
echo "Deploying as: `whoami`"
# turn on failing script on any command fail
set -e
set -o pipefail
@JonRowe
JonRowe / upgrade_ruby_pysch.rb
Created April 3, 2014 23:52
Updated script for updating psych. lul.
require 'json'
class Shell
def self.heroku_apps
new('heroku apps').cache_at 'heroku_app_cache'
end
def self.ruby_version app
new("heroku run \"ruby -v\" --app #{app}").cache_at "ruby_version_#{app}"
end
@JonRowe
JonRowe / mbp.md
Last active August 29, 2015 14:04
For Sale! 15" Macbook Pro (Mid 2010)

15" Macbook Pro (Mid 2010)

I'm selling my Macbook Pro (Mid 2010), it has commited many many lines of code, it has written chunks of RSpec, it has fought the rubies and won. It has travelled 17000km to Australia and survived, but now it must be passed on to a worth successor.

The specs:

  • Display: 15" 1680x1050 display.
  • Processor: 2 core / 4 thread 2.66GHz Intel Core i7.
  • Memory: 8GB DDR3
  • Video card: PCIe 512MB NVIDIA GeForce GT 330M
<script type="text/javascript">
// FORK IDEA
// By wrapping in try catch you can fallback to Typekit's default JS if they change the experimental feature.
try
{
// *** EXPERIMENTAL ***
//
// This is an experimental method to be notified when Typekit's fonts have loaded.
@JonRowe
JonRowe / Gemfile
Created January 26, 2010 14:10
Gemfile to allow bundling Merb 1.0.15 via Bundler... read symlink instructions...
# This Gemfile is a cheat
# It allows bundling via bundler using Merb 1.0.15
# To use this you *MUST* symlink gems/gems to gems/ruby/1.8/gems etc.
# I recommend symlinking gems/gems gems/cache gems/specification gems/doc just to be sure
bundle_path "gems"
bin_path "bin"
def self.dependency(*args)
gem(*args)
class Capybara::Driver::RackTest
private
def env
env = {}
begin
env["HTTP_REFERER"] = request.url
env["HTTPS"] = "on" if request.url =~ /^https/
rescue Rack::Test::Error
# no request yet
end
#Based upon capybara 0.3.5, the important part is the path_check method
class Capybara::Driver::RackTest
def visit(path, attributes = {})
path = path_check path
return if path.gsub(/^#{current_path}/, '') =~ /^#/
get(path, attributes, env)
follow_redirects!
cache_body
end