Skip to content

Instantly share code, notes, and snippets.

@danielfone
danielfone / gist:5654600
Created May 27, 2013 00:41
Classes descending from StandardError in an unaltered Rails 3.2.13 application.
StandardError
SQLite3::Exception
SQLite3::MemoryException
SQLite3::LockedException
SQLite3::BusyException
SQLite3::AbortException
SQLite3::PermissionException
SQLite3::InternalException
SQLite3::SQLException
SQLite3::NotADatabaseException
@camerond
camerond / ui_helper.rb
Last active December 11, 2015 17:58
My simple UI Helper in its more-or-less-current incarnation
module UiHelper
def lorem(paras)
paras = around(paras) if paras.is_a?(Range)
Faker::Lorem.paragraphs(paras).map{|p| "<p>#{p}</p>"}.join.html_safe
end
def lorem_words(num)
num = around(num) if num.is_a?(Range)
Faker::Lorem.words(num).join(' ').html_safe
@steveclarke
steveclarke / capybara.md
Created April 10, 2012 17:32
RSpec Matchers

Capybara

save_and_open_page

Matchers

have_button(locator)
@siannopollo
siannopollo / benchmark.rb
Last active February 25, 2023 07:01 — forked from chanks/benchmark.rb
Benchmark haml vs. erb
require 'rubygems'
require 'benchmark'
require 'haml'
haml_template = File.read('template.haml')
erb_template = File.read('template.erb')
Benchmark.bm do |x|
x.report('haml:') { 1000.times{ Haml::Engine.new(haml_template).render } }
x.report('erb:') { 1000.times{ ERB.new(erb_template, nil, '-').src } }
@v1nc3ntlaw
v1nc3ntlaw / rbenv-install-system-wide.sh
Last active July 26, 2022 01:08
rbenv install ruby 1.9.3-p448 on Debian 6 Squeeze
# Update, upgrade and install development tools:
apt-get update
apt-get -y upgrade
apt-get -y install build-essential git-core curl libssl-dev \
libreadline5 libreadline5-dev \
zlib1g zlib1g-dev \
libmysqlclient-dev \
libcurl4-openssl-dev \
libxslt-dev libxml2-dev
@shapeshed
shapeshed / nginx_rails_3_1
Created October 10, 2011 19:13
Nginx Config for Rails 3.1 with Unicorn and Asset Pipeline
upstream app {
server unix:/srv/app/current/tmp/sockets/unicorn.sock fail_timeout=0;
}
server {
listen 80;
server_name www.app.com;
rewrite ^/(.*) http://app.com/$1 permanent;
}
server {
@stan
stan / 0_instructions.txt
Created May 19, 2011 02:25 — forked from sgruhier/0_instructions.txt
Sprocket 2 in Rails 3.0.x ala Rails 3.1
Some brief instructions on how to use Sprocket 2 in Rails to get CoffeeScript
powered JS and SASS powered CSS with YUI compression all via the magic of rack.
This stuff will be native in Rails 3.1 and the layout of the files on the
filesystem will be different but this guide will get you working with it
while we wait for all that to finalize.
Ignore the number prefixes on each file. This is just to ensure proper order in the Gist.
It's based on eric1234 gist https://gist.github.com/911003. ijust made it 3.1 compliant in terms of convention
@eric1234
eric1234 / 0_instructions.txt
Created April 9, 2011 01:12
Using Sprockets 2 in Rails 3.0.x with CoffeeScript & SASS
UPDATE: Please see some of the forks for an updated version of this guide. I
myself have moved onto the Rails 3.1 betas to get the asset pipeline. But if
you want to stay on stable there are other folks who are keeping this guide
relevant despite the changes constantly occurring on Sprockets 2. The comments
on this gist will lead you to the right forks. :)
Some brief instructions on how to use Sprocket 2 in Rails to get CoffeeScript
powered JS and SASS powered CSS with YUI compression all via the magic of rack.
This stuff will be native in Rails 3.1 and the layout of the files on the
@stackng
stackng / rails content_for caching
Created March 29, 2011 06:30
make action and fragment caching of rails3 compatible with content_for
module ActionController
class Metal
attr_internal :cached_content_for
end
module Caching
module Actions
def _save_fragment(name, options)
return unless caching_allowed?
@jboesch
jboesch / $.fn.outerHTML.js
Created March 27, 2011 07:11
$.fn.outerHTML method
/*
* Full example here: http://jsfiddle.net/jboesch26/3SKsL/1/
*/
$.fn.outerHTML = function(){
// IE, Chrome & Safari will comply with the non-standard outerHTML, all others (FF) will have a fall-back for cloning
return (!this.length) ? this : (this[0].outerHTML || (
function(el){
var div = document.createElement('div');