Just install this in your apps like so:
gem 'test-spec-mini', :git => 'git://gist.github.com/1806986.git', :require => 'mini'
Just install this in your apps like so:
gem 'test-spec-mini', :git => 'git://gist.github.com/1806986.git', :require => 'mini'
# config/environments/staging.rb | |
# Credit: http://olemortenamundsen.wordpress.com/2011/04/05/ruby-secure-staging-environment-of-your-public-app-from-users-and-bots/ | |
MyApp::Application.configure do | |
config.middleware.insert_after(::Rack::Lock, "::Rack::Auth::Basic", "Staging") do |username, password| | |
[username, password] == ['username', 'password'] | |
end | |
end |
sudo env ARCHFLAGS="-arch x86_64" gem install mysql -v 2.7 -- --with-mysql-dir=/usr/local/mysql --with-mysql-lib=/usr/local/mysql/lib --with-mysql-include=/usr |
" Vim indent file | |
" Language: Yaml | |
" Author: Ian Young | |
if exists("b:did_indent") | |
finish | |
endif | |
"runtime! indent/ruby.vim | |
"unlet! b:did_indent | |
let b:did_indent = 1 |
# Factory girl, relaxed. | |
# | |
# Factory.define :user do |f| | |
# f.login 'johndoe%d' # Sequence. | |
# f.email '%{login}@example.com' # Interpolate. | |
# f.password f.password_confirmation('foobar') # Chain. | |
# end | |
# | |
# Factory.define :post do |f| | |
# f.user { Factory :user } # Blocks, if you must. |
javascript:(function(){document.cookie='birthtime=-2000000000; expires=Wed, 1 Jan 2020 00:00:00 UTC; path=/';document.location=document.location})(); |
namespace :db do | |
task :rebuild => ['db:drop', 'db:create', 'db:migrate'] | |
namespace :test do | |
task :rebuild => :environment do | |
RAILS_ENV = 'test' | |
ActiveRecord::Base.establish_connection(:test) | |
Rake::Task['db:rebuild'].invoke | |
end | |
end |
# modifications from standard capistrano deploy as taken from: | |
# http://devthatweb.com/view/deploy-any-project-using-capistrano-2 | |
set :application, "name removed" | |
set :repository, "url to trunk of repo" | |
# If you aren't deploying to /u/apps/#{application} on the target | |
# servers (which is the default), you can specify the actual location | |
# via the :deploy_to variable: | |
set :deploy_to, "/var/www/#{application}" |
# A very simplistic "presenter" implementation. It works by simply extending | |
# an object with a presenter module | |
# presenter.rb | |
module Presenter | |
def self.for_class(klass) | |
Object.const_get(klass.name + 'Presenter') rescue nil | |
end | |
# extends the given record with the presenter module for the object type |
module SortableBy | |
module ClassMethods | |
# defines a 'sorted_by' named scope, which accepts a column name and optional direction | |
# example: sortable_by :columns => %w(id name) | |
# usage: SomeModel.sorted_by('name', 'asc') | |
def sortable_by(options) | |
class_eval "def self.sortable_columns; #{options[:columns].inspect}; end" | |
named_scope :sorted_by, Proc.new { |column, direction| | |
if sortable_columns.include?(column) |