Skip to content

Instantly share code, notes, and snippets.

@ches
ches / spec_suites.rake
Created November 29, 2010 18:08
Set up Rake tasks to execute defined sets of specs
# Nice idea from:
# http://kpumuk.info/ruby-on-rails/my-top-7-rspec-best-practices/
#
# ~/test$ rake -T spec:suite
#
# (in /Users/kpumuk/test)
# rake spec:suite:acl # Run all specs in access control spec suite
# rake spec:suite:amazon # Run all specs in Amazon libraries spec suite
SPEC_SUITES = [
@pjkelly
pjkelly / DevelopmentEnvironmentInstructions.markdown
Created December 13, 2010 17:13
Instructions for setting up a Rails development environment using Cinderella

These instructions are for Snow Leopard only.

XCode

Ensure that you have XCode for the version of OS X you're running. These are not installed by default on new machines and can be installed off the OS installation DVD. If you're not sure, run the following command. It should return something like this: /usr/bin/gcc; if it does not, you need to install XCode.

which gcc

SSH Keys

@pjkelly
pjkelly / install-apt-file.sh
Created July 7, 2011 01:00
Not sure what apt-get package contains a file?
# credit: http://crshlv.ly/qkAzW0
#
# I found this especially useful when trying
# to figure out equivalent apt-get packages
# for certain Perl CPAN modules.
apt-get install apt-file
apt-file update
apt-file search URI::Escape
@mislav
mislav / Gemfile
Created August 31, 2011 21:48
How to integrate Compass with Rails 3.1 asset pipeline
group :assets do
gem 'sass-rails', '~> 3.1.0'
gem 'coffee-rails', '~> 3.1.0'
gem 'uglifier'
gem 'compass'
end
@rmetzler
rmetzler / app.rb
Created January 22, 2012 12:51 — forked from jamiehodge/app.rb
Sinatra API for resumable.js
require 'sinatra'
require 'slim'
require 'coffee-script'
require 'sass'
require 'sequel'
DB = Sequel.sqlite
DB.create_table :uploads do
String :id, text: true, primary_key: true
@aroop
aroop / GenerateImageThumbnailsJob.rb
Created February 1, 2012 07:45
Dragonfly image processor
class GenerateImageThumbnailsJob < Struct.new(:photo_id)
def perform
photo = Photo.find(photo_id)
photo.medium_image = photo.image.thumb('940x600')
photo.large_image = photo.image.thumb('450x')
photo.small_image = photo.image.thumb('172x167#c')
photo.save
end
@nz
nz / example-installation-testing-session.sh
Created February 12, 2012 23:34
Getting started with Bonsai.io's hosted ElasticSearch service
$ heroku addons:add elasticsearch:test
-----> Adding elasticsearch:test to bonsai-search... done, v51 (free)
$ heroku config | grep ELASTICSEARCH_URL
ELASTICSEARCH_URL => http://index.bonsai.io/pw4mw3d5y1rql88i44eo
$ curl 'http://index.bonsai.io/pw4mw3d5y1rql88i44eo/test?pretty=true' -d '{"test":"hello world"}'
{
"ok":true,
"_index":"pw4mw3d5y1rql88i44eo",
@sj26
sj26 / README.md
Created February 29, 2012 10:38
Subdomains in Rails 3

Subdomains in Rails 3

Are still a nightmare to get tested, etc.

To share sessions across subdomains you need to set the session options during the request so you know what domain you're sharing across. This means we still need to do it with a before_filter, or something similar. It looks like you should be able to set :domain => true in config/initializers/session_store.rb to do this instead but Devise does not support it yet as far as I can see.

Here I'm using subdomains with a custom url_for extension which means from "http://www.smackaho.st" root_path would be "/" while from "http://admin.smackaho.st" root_path would be "http://www.smackaho.st/".

In cucumber this is forced to always qualify the full URL with the subdomain. It also rewrites the port in/out as neccessary to cope with Capybara's server using an alternate port (used by Selenium for javascript testing etc). The project I'm on is still using web_steps (sigh) so I had to touch the "should be on" step definition to cope with

@twasink
twasink / gist:1997799
Created March 8, 2012 01:20
Colourised git-aware PS1 that also knows what repo you're in.
__git_repo () {
local g="$(__gitdir)"
local repo_dir=""
if [ -n "$g" ]; then
if [ ! ".git" == "$g" ]; then
git_dir=`dirname $g`
repo_dir=`basename $git_dir`
printf " $repo_dir"
fi
@audionerd
audionerd / middleman_mustache.rb
Created March 13, 2012 02:24
Mustache support for Middleman
require 'tilt-mustache'
# Mustache Renderer
module Middleman::Renderers::Mustache
class << self
def registered(app)
# Mustache is not included in the default gems,
# but we'll support it if available.
begin