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 / 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"
@mtcmorris
mtcmorris / gist:3082609
Created July 10, 2012 10:42
20 top films in the past 5 years
The Artist
Senna
Hanna
Headhunters (Hodejegerne)
The Help
Best Exotic Marigold Hotel
District 9
Crazy Stupid Love
The Social Network
Black Swan
@ozeias
ozeias / unicorn.rb
Created May 16, 2012 11:21 — forked from jamiew/unicorn.rb
Unicorn config for use with bundler and capistrano - fixes issues with environment pollution.rb
# My pimped out unicorn config, with incremental killof
# and all the latest capistrano & bundler-proofing
# @jamiew :: http://github.com/jamiew
application = "000000book.com"
environment = ENV['RACK_ENV'] || ENV['RAILS_ENV'] || 'production'
app_path = "/srv/#{application}"
bundle_path = "#{app_path}/shared/bundle"
timeout 30
@coreyhaines
coreyhaines / .rspec
Last active April 11, 2024 00:19
Active Record Spec Helper - Loading just active record
--colour
-I app
@kalbasit
kalbasit / das_download.rb
Created February 27, 2012 23:37 — forked from maca/das_download.rb
Script to download all Destroy All Software screencasts, account needed
#! /usr/bin/env ruby
# usage:
# $ das_download.rb email password [download_directory]
require 'mechanize'
# gem 'mechanize-progressbar'
email = ARGV[0] or raise('Please provide the email address for your account')
password = ARGV[1] or raise('Please provide the password for your account')
path = (ARGV[2] || './').gsub /\//,''
@tels7ar
tels7ar / gist:1760969
Created February 7, 2012 17:47 — forked from jtimberman/gist:881058
i can has ruby-1.9.3 package with fpm
sudo apt-get install libssl-dev
sudo gem install fpm
wget --timestamp ftp://ftp.ruby-lang.org//pub/ruby/1.9/ruby-1.9.3-p0.tar.gz
tar -zxvf ruby-1.9.3-p0.tar.gz
cd ruby-1.9.3-p0
time (./configure --prefix=/usr && make && make install DESTDIR=/tmp/installdir)
fpm -s dir -t deb -n ruby -v 1.9.3-p0 -C /tmp/installdir \
-p ruby-VERSION_ARCH.deb -d "libstdc++6 (>= 4.4.3)" \
@plasticine
plasticine / grid.scss
Created August 15, 2011 01:49
Generate a grid.
$grid_col_names:(
'one', 'two', 'three', 'four', 'five', 'six',
'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve'
);
@function col($count:1){ @return (($grid_col_width + $grid_gutter) * $count) - $grid_gutter; }
@mixin pre_col($count:1){ margin-left: col($count); }
@mixin post_col($count:1){ margin-right: col($count); }
@mixin make_grid_classes{
@for $index from 1 through $grid_num_cols {

Remove trailing whitespace, convert tabs to spaces and file format to unix (remove ugly ^M carriage returns) from files using a single command:

vim -es -c 'set et ts=2 | bufdo retab | %s/\s\+$//e | set ff=unix | w' -c 'q' FILES

You could get your FILES using find

vim -es -c 'set et ts=2 | bufdo retab | %s/\s\+$//e | set ff=unix | w' -c 'q' $(find scripts -name '*.sh' -type f)

If in doubt, ask man.

@notahat
notahat / capybara_support.rb
Created May 24, 2011 01:58
Make RSpec and Capybara give backtraces for controller exceptions
# Put this in spec/support
# Make sure we get stack traces for controller and view exceptions.
ActionController::Base.class_eval do
def rescue_action_without_handler(exception)
raise exception
end
end
@joho
joho / front-end-envato.markdown
Created April 20, 2011 01:47
Front End Developer @ Envato

Front End Developer @ Envato

Hi, we're Envato and we want to expand the number of front-end developers working on our marketplaces by 200%. That's right, you'll be the second one we've got!

The easiest way to describe the role is to just explain what Stu, our current front-end hotshot does: pretty much everything. You'll be working directly with our template code (ERB if you already know rails), with the design coming from any or all of: nice photoshop designs, wireframes, and vague suggestions of "make that work and be pretty". There's the occasional marketing style landing page to be made, the occasional HTML email template, and a whole bunch of design iteration on our marketplaces.

As this is the role that takes us from a front-end dev to a front-end "team", exactly how we're going to share out that work and run things are a bit up in the air right now, but that gives us some freedom to arrange things to play to the strengths of whichever candidate comes through the front door.

Possibly the best p