Skip to content

Instantly share code, notes, and snippets.

@jerodsanto
jerodsanto / firebug_logger.rb
Created December 9, 2009 16:23 — forked from simonjefford/firebug_logger.rb
Rack::FirebugLogger
module Rack
class FirebugLogger
def initialize(app, options = {})
@app = app
@options = options
end
def call(env)
status, headers, orig_response = @app.call(env)
return [status, headers, orig_response] unless (headers["Content-Type"] =~ /html/ && env['firebug.logs'])
@ctrochalakis
ctrochalakis / exception_notify_helper.rb
Created August 26, 2010 09:31
Using exception_notifier for rake tasks or scripts
# Exception notifier (rails3) only works as a rack middleware,
# but what if you need notifications inside a rake task or a script?
# This is a quick hack around that.
#
# Wrap your code inside an exception_notify block and you will be notified of exceptions
#
# exception_notify { clear_payments }
def exception_notify
yield
rescue Exception => exception
@snichme
snichme / gist:789589
Created January 21, 2011 12:05
A Doctrine logger for FireBug(FirePHP)
<?php
/**
* Doctrine logger for FireBug
*
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @author Magnus Andersson <mange@mange.name>
*/
namespace My\Namespace;
use Doctrine\DBAL\Logging\SqlLogger;
@pvdb
pvdb / deploy.md
Created March 13, 2011 10:09
Capistrano start/stop/restart tasks for Phusion Passsenger Standalone

With the introduction of Phusion Passenger Standalone, some of the established wisdom with regards to Capistrano tasks for managing Passenger are a tad outdated.

In particular, the start and stop tasks for Passenger are typically NOOPs, and only the restart task is deemed relevant. This is arguably no longer the case for standalone Passenger, where start and stop tasks do make sense, as they did back in the mongrel days.

The following Capistrano tasks illustrate how to start, stop and restart a standalone Passenger setup.

These tasks are for a Passenger setup that uses Unix domain sockets, but they can easily be modified for Passenger instances configured for TCP sockets.

    namespace :deploy do

task :start, :roles => :app, :except => { :no_release => t

@troex
troex / unicorn.sh
Created April 4, 2011 20:57
Unicorn start/stop/restart script for Debian
#!/bin/sh
### BEGIN INIT INFO
# Provides: unicorn
# Required-Start: $local_fs $remote_fs mysql
# Required-Stop: $local_fs $remote_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: unicorn initscript
# Description: Unicorn is an HTTP server for Rack application
### END INIT INFO
@aliang
aliang / mymodel.rb
Created June 13, 2011 06:25
render from model in Rails 3
# yes, sometimes you need to do this. you get pilloried in a forum if you
# ask about it, though!
# this code taken from
# http://wholemeal.co.nz/blog/2011/04/05/rendering-from-a-model-in-rails-3/
class MyModel < ActiveRecord::Base
# Use the my_models/_my_model.txt.erb view to render this object as a string
def to_s
ActionView::Base.new(Rails.configuration.paths.app.views.first).render(
@canweriotnow
canweriotnow / unicorn
Created July 5, 2011 17:38
/etc/init.d script for unicorn
#!/bin/sh
#
# init.d script for single or multiple unicorn installations. Expects at least one .conf
# file in /etc/unicorn
#
# Modified by jay@gooby.org http://github.com/jaygooby
# based on http://gist.github.com/308216 by http://github.com/mguterl
#
## A sample /etc/unicorn/my_app.conf
##
@richo
richo / home.profile
Created August 24, 2011 12:30
RVM's default config on debian stable
#!/bin/sh
[ -z "$have_rvm" ] &&
source /etc/profile.d/rvm.sh
@metaskills
metaskills / wait_until.rb
Last active May 2, 2024 01:51
Never sleep() using Capybara!
# WAIT! Do consider that `wait` may not be needed. This article describes
# that reasoning. Please read it and make informed decisions.
# https://www.varvet.com/blog/why-wait_until-was-removed-from-capybara/
# Have you ever had to sleep() in Capybara-WebKit to wait for AJAX and/or CSS animations?
describe 'Modal' do
should 'display login errors' do
visit root_path
@cyberfox
cyberfox / keychain.rb
Created September 18, 2011 06:03
Convert OS X Keychain exported entries into logins for 1Password import
#!/usr/bin/env ruby
#
# Usage:
# security dump-keychain -d login.keychain > keychain_logins.txt
# # Lots of clicking 'Always Allow', or just 'Allow', until it's done...