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'])
Bluepill.define_process_condition(:running_time) do
def initialize(options = {})
@below = options[:below]
end
def run(pid)
started = `ps -p #{pid} -o command`.match(/since (\d+)/)[1].to_i
Time.now - Time.at(started)
rescue
0
@gma
gma / gist:674141
Created November 12, 2010 14:17
Bluepill config for resque
ENV["PATH"] = "/opt/ruby/bin:#{ENV['PATH']}"
ENV["RAILS_ENV"] = "production"
ENV["QUEUE"] = "*"
Bluepill.application("nichelator") do |app|
app.working_dir = "/var/apps/nichelator/current"
app.uid = "app"
app.gid = "app"
2.times do |i|
app.process("resque-#{i}") do |process|
@davejlong
davejlong / mysql client
Created February 1, 2011 15:06
How to setup the MySQL client and MySQLDump client on Mac OS x from MySQL Workbench
#MySQL Client
ln -s /Application/MySQL\ Workbench.app/Contents/Resources/mysql /usr/bin/mysql
#MySQL Dump
ln -s /Application/MySQL\ Workbench.app/Contents/Resources/mysqldump /usr/bin/mysqldump
@gbbowers
gbbowers / railscast.bbcolor
Created July 26, 2011 01:01
Railscast bbcolor file I did a few years ago. Feel free to improve it and update for missing items, etc.
"Color:Background" = "rgb(11051,11051,11051)";
"Color:Background:Grep Replace Pattern" = "rgb(62915,62915,62915)";
"Color:Background:Grep Search Pattern" = "rgb(62915,62915,62915)";
"Color:CTagsIdentifier" = "rgb(48776,20456,15006)";
"Color:ColorAttributesSeparately" = 1;
"Color:Comment" = "rgb(26214,26214,26214)";
"Color:Comment:Markdown" = "rgb(43036,43036,43036)";
"Color:Foreground" = "rgb(59110,57825,56540)";
"Color:Foreground:Grep Replace Pattern" = "rgb(0,0,0)";
"Color:Foreground:Grep Search Pattern" = "rgb(0,0,0)";
@jamiepenney
jamiepenney / bootstrap.rb
Created February 14, 2012 19:57
Form builder for Twitter Bootstrap v2 form elements
# This file goes in config/initializers
require 'bootstrap_form_builder'
# Make this the default Form Builder. You can delete this if you don't want form_for to use
# the bootstrap form builder by default
ActionView::Base.default_form_builder = BootstrapFormBuilder::FormBuilder
# Add in our FormHelper methods, so you can use bootstrap_form_for.
ActionView::Base.send :include, BootstrapFormBuilder::FormHelper
@dstrelau
dstrelau / app.rb
Created November 22, 2010 20:36
Gollum protected by HTTP Basic
require 'gollum/frontend/app'
require 'digest/sha1'
class App < Precious::App
User = Struct.new(:name, :email, :password_hash)
before { authenticate! }
helpers do
def authenticate!
@madtrick
madtrick / gist:3917079
Created October 19, 2012 09:06
Warden strategy for Devise
module Devise
module Strategies
class RemoteAuthenticatable < Authenticatable
#
# For an example check : https://github.com/plataformatec/devise/blob/master/lib/devise/strategies/database_authenticatable.rb
#
# Method called by warden to authenticate a resource.
#
def authenticate!
#
@karmi
karmi / workers.rake
Created July 22, 2010 15:58
Rake taks to launch multiple Resque workers in development/production with simple management included
# Rake task to launch multiple Resque workers in development/production with simple management included
require 'resque/tasks' # Require Resque tasks
namespace :workers do
# = $ rake workers:start
#
# Launch multiple Resque workers with the Rails environment loaded,
# so they have access to your models, etc.
@s-andringa
s-andringa / Locales.yml
Created September 19, 2012 10:09
Amsrb talk 18 sept - exceptions_app in Rails 3.2
# config/locales/en.yml
en:
exception:
show:
not_found:
title: "Not Found"
description: "The page you were looking for does not exists."
internal_server_error:
title: "Internal Server Error"