Skip to content

Instantly share code, notes, and snippets.

View evanwalsh's full-sized avatar
❤️‍🔥
You make me feel almost human

Evan Walsh evanwalsh

❤️‍🔥
You make me feel almost human
View GitHub Profile
@evanwalsh
evanwalsh / gist:2165317
Created March 22, 2012 23:04 — forked from jrochkind/gist:2161449
A Capistrano Rails Guide

A Capistrano Rails Guide

by Jonathan Rochkind, http://bibwild.wordpress.com

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".

@evanwalsh
evanwalsh / gist:1405271
Created November 29, 2011 15:50
Print from a non-Postscript Ricoh printer on a Mac
Download the following in this order and install from here:
http://www.linuxfoundation.org/collaborate/workgroups/openprinting/macosxpxlmono
Ghostscript for Mac OS X 10.3.x (Panther) - Mac OS X 10.6.x (Snow Leopard)
Foomatic-RIP for Mac OS X 10.3.x (Panther) - Mac OS X 10.6.x (Snow Leopard)
pxlmono 1.6 for Mac OS X 10.3.x (Panther) - Mac OS X 10.6.x (Snow Leopard)
Once installed add your printer and use the following driver Ricoh Aficio MX C2500 PXL and you should have a fully working colour printer:
@evanwalsh
evanwalsh / gist:1332546
Created November 2, 2011 01:06
database_cleaner with MiniTest::Spec
require 'database_cleaner'
DatabaseCleaner.strategy = :truncation
class MiniTest::Spec
before :each do
DatabaseCleaner.clean
end
end
require 'spec_helper'
describe PostsController do
before do
@post = Fabricate :post
end
describe "GET index", type: :request do
before do
source :rubygems
gem 'rails', '~> 3.0.7'
# Database
gem 'mongoid', '~> 2.0.1'
gem 'bson_ext', '~> 1.3.0'
gem 'mongo_ext', '~> 0.19.3'
# Backend
require 'spork'
Spork.prefork do
# Loading more in this block will cause your tests to run faster. However,
# if you change any configuration or code from libraries loaded here, you'll
# need to restart spork for it take effect.
# Hey, Mongoid! Don't cache that class!
require "rails/mongoid"
Spork.trap_class_method(Rails::Mongoid, :load_models)
// 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%
if __FILE__ == $0
puts "Run with: watchr #{__FILE__}. \n\nRequired gems: watchr rev"
exit 1
end
# --------------------------------------------------
# Convenience Methods
# --------------------------------------------------
def run(cmd)
puts(cmd)
@evanwalsh
evanwalsh / generate_salt.rb
Created January 24, 2011 21:13
A function I wrote. Don't know if I'll ever need it.
def generate_salt(length)
salt = String.new
32.times { salt += Kernel.rand(9999).to_s }
if salt.length > length
salt[0, length.to_i]
else
salt
end
end
$.noConflict();
jQuery(document).ready(function($){
$('.audio').each(function(){
var match = $(this).find('script').html().match(/audio_file=(.*)\\x26/);
$(this).find('span').html('<audio src="'+match[1]+'?plead=please-dont-download-this-or-our-lawyers-wont-let-us-host-audio" controls="controls">Your browser does not support the audio element.</audio>').remove();
$(this).find('script').remove();
});
});