Skip to content

Instantly share code, notes, and snippets.

View joho's full-sized avatar
At harbour

John Barton joho

At harbour
View GitHub Profile
@joho
joho / pry from within specs
Last active December 12, 2015 10:19
Error while trying to upgrade from rails 3.2.11 -> 3.2.12
=> ["/Users/joho/source/goodfilms/site/vendor/bundle/ruby/1.9.1/gems/arel-3.0.2/lib/arel/expressions.rb:3:in `count'",
"/Users/joho/.rbenv/versions/1.9.3-p125/lib/ruby/1.9.1/psych/visitors/yaml_tree.rb:220:in `binary?'",
"/Users/joho/.rbenv/versions/1.9.3-p125/lib/ruby/1.9.1/psych/visitors/yaml_tree.rb:229:in `visit_String'",
"/Users/joho/.rbenv/versions/1.9.3-p125/lib/ruby/1.9.1/psych/visitors/yaml_tree.rb:102:in `accept'",
"/Users/joho/.rbenv/versions/1.9.3-p125/lib/ruby/1.9.1/psych/visitors/yaml_tree.rb:282:in `block in visit_Hash'",
"/Users/joho/.rbenv/versions/1.9.3-p125/lib/ruby/1.9.1/psych/visitors/yaml_tree.rb:280:in `each'",
"/Users/joho/.rbenv/versions/1.9.3-p125/lib/ruby/1.9.1/psych/visitors/yaml_tree.rb:280:in `visit_Hash'",
"/Users/joho/.rbenv/versions/1.9.3-p125/lib/ruby/1.9.1/psych/visitors/yaml_tree.rb:102:in `accept'",
"/Users/joho/.rbenv/versions/1.9.3-p125/lib/ruby/1.9.1/psych/visitors/yaml_tree.rb:387:in `block in emit_coder'",
"/Users/joho/.rbenv/versions/1.9.3-p125/lib/ruby/1.9.
@joho
joho / tab_in_private.rb
Created November 19, 2012 08:46
Which is better for marking methods as private/protected?
# is this way of marking methods as private better/worse than...
class Meh
def your_face
"blah"
end
private
def banana
"there are no private bananas"
@joho
joho / stumbleupon_widget.js
Created November 7, 2012 05:55
un-minified version of the stumbleupon widget js
STMBLPN = window.STMBLPN || {};
(function () {
if (STMBLPN && STMBLPN.hasHelperFunctions) return;
if (STMBLPN instanceof Array) {
var list = STMBLPN;
STMBLPN = {};
STMBLPN.list = list;
}
STMBLPN.browser = function () {
var ua = navigator.userAgent;
@joho
joho / Gemfile
Created October 15, 2012 02:52
Teeny-tiny sinatra app on heroku
source :rubygems
gem "thin"
gem "sinatra"
group :development do
gem "heroku"
gem "foreman"
end
@joho
joho / dabblet.css
Created October 8, 2012 05:46
The first commented line is your dabblet’s title
/**
* The first commented line is your dabblet’s title
*/
div.container {
width: 600px;
border: solid 3px red;
}
div.widget {
@joho
joho / dabblet.css
Created September 21, 2012 05:57
Blinking like it's 1999
/**
* Blinking like it's 1999
*/
@-webkit-keyframes blink {
0% { opacity: 0 } 50% { opacity: 0 }
50.01% { opacity: 1 } 100% { opacity: 1 }
}
blink {
@joho
joho / blink.css.sass
Created September 20, 2012 10:19
blink tag for webkit in sass
@joho
joho / gzip_net_http.rb
Created September 19, 2012 04:12
Handling gzip responses in Ruby Net::HTTP library
# from http://pushandpop.blogspot.com.au/2011/05/handling-gzip-responses-in-ruby-nethttp.html
# i wanted syntax highlighting
require 'net/http'
debug = Proc.new{|msg| STDERR.puts "[#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}] #{msg}" }
page = nil
http = Net::HTTP.new( "www.google.com", 80 )
req = Net::HTTP::Get.new( "/search?num=20&hl=en&noj=1&q=test&btnG=Search", { "Accept-Encoding" => "gzip", "User-Agent" => "gzip" } )
@joho
joho / gist:3735740
Created September 17, 2012 05:40 — forked from rafaelss/gist:3700977
PostgreSQL 9.2 upgrade steps
Steps to install and run PostgreSQL 9.2 using Homebrew (Mac OS X)
(if you aren't using version 9.1.5, change line 6 with the correct version)
1. launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
2. mv /usr/local/var/postgres /usr/local/var/postgres91
3. brew update
4. brew upgrade postgresql
5. initdb /usr/local/var/postgres -E utf8
6. pg_upgrade -b /usr/local/Cellar/postgresql/9.1.5/bin -B /usr/local/Cellar/postgresql/9.2.0/bin -d /usr/local/var/postgres91 -D /usr/local/var/postgres
7. cp /usr/local/Cellar/postgresql/9.2.0/homebrew.mxcl.postgresql.plist ~/Library/LaunchAgents/
@joho
joho / deploy.rb
Created September 13, 2012 01:30
How to serve emergency "signed out" views from page cache without affecting signed in users in rails.
set :path_to_repo, "/path_to_repo/"
set :running_app_user, "appusername"
namespace :webscale do
desc "Cache a signed out version of the path. Usage: cap webscale:signed_out_cache_page -s path_to_cache=/films/on_netflix"
task :signed_out_cache, roles: :app do
cache_base_path = "#{path_to_repo}/public/signed_out"
cached_destination_path = "#{cache_base_path}#{path_to_cache}.html"
working_path = "#{cached_destination_path}.tmp"