Skip to content

Instantly share code, notes, and snippets.

# an example Monit configuration file for delayed_job
#
# To use:
# 1. copy to /var/www/apps/{app_name}/shared/delayed_job.monitrc
# 2. replace {app_name} and {environment} as appropriate
# 3. add this to your /etc/monit/monitrc
#
# include /var/www/apps/{app_name}/shared/delayed_job.monitrc
check process delayed_job with pidfile /var/www/apps/{app_name}/shared/pids/delayed_job.pid
# unicorn_rails -c /data/github/current/config/unicorn.rb -E production -D
rails_env = ENV['RAILS_ENV'] || 'production'
# 16 workers and 1 master
worker_processes (rails_env == 'production' ? 16 : 4)
# Load rails+github.git into the master before forking workers
# for super-fast worker spawn times
preload_app true
anonymous
anonymous / factories.rb
Created February 24, 2010 05:05
Factory.define :item do |f|
include ActionDispatch::TestProcess
f.name "Macbook Pro 15"
f.price_in_dollars 1500
f.photo fixture_file_upload('/files/avatar.jpg', 'image/jpg')
end
class Users::SessionsController < Devise::SessionsController
# Have to reimplement :recall => "failure"
# for warden to redirect to some action that will return what I want
def create
resource = warden.authenticate!(:scope => resource_name, :recall => "failure")
# set_flash_message :notice, :signed_in
sign_in_and_redirect(resource_name, resource)
end
@zhengjia
zhengjia / capybara cheat sheet
Created June 7, 2010 01:35
capybara cheat sheet
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')
@kdwinter
kdwinter / authenticable.rb
Created June 14, 2010 21:52
Authlogic with Mongoid (in spirit of http://pastie.org/503478)
module Authenticable
def self.included(model)
model.class_eval do
extend ClassMethods
include InstanceMethods
field :username
field :email
field :crypted_password
field :password_salt
@gunn
gunn / close_tags.rb
Created November 8, 2010 11:39
Nokogiri can be used to fix html
require "rubygems"
require 'nokogiri'
doc = Nokogiri::HTML.parse(<<-eohtml)
<html>
<head>
<title>Hello World</title>
<body>
<h1>This is an awesome document</h1>
<p>
@zhasm
zhasm / fanfou.py
Created February 24, 2011 04:13
fanfou sdk draft in python, basic auth.
#!/usr/bin/python
# -*- coding: utf-8 -*-
#
#author: rex
#blog: http://iregex.org
#filename test.py
#created: 2010-12-18 22:42
import re
import pycurl
import json
@gunn
gunn / _form_carrier_wave_file.html.haml
Created March 24, 2011 10:14
Carrierwave support for rails_admin
= label_tag "#{field.abstract_model.to_param}_#{field.name}", field.label
.input
- if field.bindings[:object].send("#{field.name}_url")
.row
= link_to field.bindings[:object].send("#{field.name}_url")
%br
= form.check_box "remove_#{field.name}"
= form.label "remove_#{field.name}", "Remove existing #{field.label.downcase}", class: "inline"
.row
= form.file_field field.name, class: "fileUploadField #{field.has_errors? ? "errorField" : nil}"
@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