Skip to content

Instantly share code, notes, and snippets.

Being good to others

Evan Walsh evanwalsh

Being good to others
View GitHub Profile
View selector.rb
Capybara.add_selector :record do
xpath { |record| XPath.css("#" + ActionController::RecordIdentifier.dom_id(record)) }
match { |record| record.is_a?(ActiveRecord::Base) }
evanwalsh / app--helpers--application_helper.rb
Created May 4, 2012 — forked from nickhoffman/app--helpers--application_helper.rb
pjax is awesome, but causes code within #content_for not to be rendered. Here's a solution.
View app--helpers--application_helper.rb
module ApplicationHelper
def content_for_or_pjax(name, &block)
request.headers['X-PJAX'] ? capture(&block) : content_for(name, &block)
evanwalsh / gist:2552100
Created Apr 29, 2012 — forked from joelmoss/gist:2470666
Capistrano recipe for Puma start/stop/restarts
View gist:2552100
set :shared_children, shared_children << 'tmp/sockets'
namespace :deploy do
desc "Start the application"
task :start, :roles => :app, :except => { :no_release => true } do
run "cd #{current_path} && RAILS_ENV=#{stage} bundle exec puma -b 'unix://#{shared_path}/sockets/puma.sock' -S #{shared_path}/sockets/puma.state --control 'unix://#{shared_path}/sockets/pumactl.sock' >> #{shared_path}/log/puma-#{stage}.log 2>&1 &", :pty => false
desc "Stop the application"
task :stop, :roles => :app, :except => { :no_release => true } do
evanwalsh / gist:2165317
Created Mar 22, 2012 — forked from jrochkind/gist:2161449
A Capistrano Rails Guide
View gist:2165317

A Capistrano Rails Guide

by Jonathan Rochkind,

why cap?

Capistrano automates pushing out a new version of your application to a deployment location.

I've been writing and deploying Rails apps for a while, but I avoided using Capistrano until recently. I've got a pretty simple one-host deployment, and even though everyone said Capistrano was great, every time I tried to get started I just got snowed under not being able to figure out exactly what I wanted to do, and figured I wasn't having that much trouble doing it "manually".

View grid.sass
// REQUIRED VARS. Defaults to a 950px wide, 24-column grid that has 30px wide units and 10px wide
// gutters. If you do the fluid grid, then this 950/24/30/10px size will become the maximum size.
$grid_type: fixed !default
$grid_columns: 24 !default
$grid_column_width: 30 !default
$grid_gutter_width: 10 !default
// GENERATED VARS. You can ignore these.
$grid_full_width: $grid_columns * $grid_column_width + $grid_columns * $grid_gutter_width - $grid_gutter_width
$grid_column_width_percent: ($grid_column_width / $grid_full_width * 100) * 1%
View watchr-runner.rb
if __FILE__ == $0
puts "Run with: watchr #{__FILE__}. \n\nRequired gems: watchr rev"
exit 1
# --------------------------------------------------
# Convenience Methods
# --------------------------------------------------
def run(cmd)
View _yerb.rb
# = YERB
# Who needs HAML when you have YAML + ERB? :)
# See example.yaml below for an example. You can run this code
# by cloning this gist and then `ruby _yerb.rb example.yaml`.
# Notice that you need Ruby 1.9 so the hash order is preserved.
# Obviously, this is just for fun. Definitely slow as hell.
View gist:44426
# 1) Point * in your DNS setup to your server.
# 2) Setup an Apache vhost to catch the star pointer:
# <VirtualHost *:80>
# ServerName *
# </VirtualHost>
# 3) Set the current account from the subdomain
class ApplicationController < ActionController::Base