Skip to content

Instantly share code, notes, and snippets.

View mrrooijen's full-sized avatar

Michael van Rooijen mrrooijen

View GitHub Profile
gem 'resque', '>= 1.10.0'
gem 'heroku' # You will need the heroku gem for this too.
user app;
worker_processes 2;
error_log /home/app/logs/nginx.error.log info;
events {
worker_connections 1024;
}
module Dragonfly
module Endpoint
def success_headers(job)
{
"Content-Type" => job.app.resolve_mime_type(job.result),
"Content-Length" => job.size.to_s,
"Content-Disposition" => "filename=#{job.name}"
}.merge(cache_headers(job))
end
@mrrooijen
mrrooijen / gist:470114
Created July 9, 2010 21:48
Stub Paperclip Attachment
##
# With regular RSpec stubbing
it 'should allow JPG images' do
photo = Photo.new :photo => fixture_file_upload('photos/chameleon.jpg', 'image/jpeg')
photo.stub!(:save_attached_files).and_return true
photo.save.should be_true
end
##
# With Mocha on "any" instance of a Class
#! /bin/sh
### BEGIN INIT INFO
# Provides: mongodb
# Required-Start: $all
# Required-Stop: $all
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts the mongodb data-store
# Description: starts mongodb using start-stop-daemon
# index.html.erb
<ul id="projects">
<% @projects.each_with_index do |project, index| %>
<% content_tag_for :li, project do %>
<%= project.name %>
<%= button_to('up', :action => 'sort', :projects => @projects.swap(index, index -1)) if index > 0 %>
<%= button_to('down', :action => 'sort', :projects => @projects.swap(index, index +1)) if index < @projects.length - 1 %>
<% end %>
<% end %>