This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ~/.irbrc | |
# Requires the following gems: wirble, hirb | |
# | |
# Hirb: http://tagaholic.me/hirb/doc/index.html | |
# Wirble: http://pablotron.org/software/wirble/ | |
require 'irb/completion' | |
require 'irb/ext/save-history' | |
IRB.conf[:SAVE_HISTORY] = 100 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# dump SQL into console | |
require 'logger' | |
if ENV.include?('RAILS_ENV') && !Object.const_defined?('RAILS_DEFAULT_LOGGER') # rails 2 | |
Object.const_set('RAILS_DEFAULT_LOGGER', Logger.new(STDOUT)) | |
else # rails 3 | |
ActiveRecord::Base.logger = Logger.new(STDOUT) if defined? Rails::Console | |
end | |
# enable result formatting - install gem 'hirb' | |
require 'hirb' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Put this content to ~/.irbrc file (no extension) | |
require "rubygems" | |
begin | |
require "ap" | |
rescue LoadError => err | |
puts "Cannot find awesome_print gem. Please run 'gem install awesome_print' to install it." | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/sh | |
### BEGIN INIT INFO | |
# Provides: redis-server | |
# Required-Start: $syslog | |
# Required-Stop: $syslog | |
# Should-Start: $local_fs | |
# Should-Stop: $local_fs | |
# Default-Start: 2 3 4 5 | |
# Default-Stop: 0 1 6 | |
# Short-Description: redis-server - Persistent key-value db |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/sh | |
### BEGIN INIT INFO | |
# Provides: nginx | |
# Required-Start: $local_fs $remote_fs $network $syslog | |
# Required-Stop: $local_fs $remote_fs $network $syslog | |
# Default-Start: 2 3 4 5 | |
# Default-Stop: 0 1 6 | |
# Short-Description: starts the nginx web server | |
# Description: starts nginx using start-stop-daemon |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# config/initializers/sql_logger.rb | |
connection = ActiveRecord::Base.connection | |
class << connection | |
alias :original_exec :execute | |
def execute(sql, *name) | |
# try to log sql command but ignore any errors that occur in this block | |
# we log before executing, in case the execution raises an error | |
begin | |
rails_env = ENV['RAILS_ENV'] || 'development' | |
file = File.open(Rails.root.to_s + "/log/sql_#{rails_env}.log",'a'){|f| f.puts Time.now.to_s+": "+sql} if (%w(staging development).include? rails_env) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
amount = thing.build_payment.price_in_cents | |
response = EXPRESS_GATEWAY.setup_authorization(amount, | |
:ip => request.remote_ip, | |
:return_url => new_payment_url, | |
:cancel_return_url => new_order_url, | |
:no_shipping => true, | |
:items => [{:name => "#{thing.title}", :amount => amount}] | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# wrapper to daemonize rake tasks: see also http://mmonit.com/wiki/Monit/FAQ#pidfile | |
usage() { | |
echo "usage: ${0} [start|stop] name target [arguments]" | |
echo "\tname is used to create or read the log and pid file names" | |
echo "\tfor start: target and arguments are passed to rake" | |
echo "\tfor stop: target and arguments are passed to kill (e.g.: -n 3)" | |
exit 1 | |
} | |
[ $# -lt 2 ] && usage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sass::Engine::DEFAULT_OPTIONS[:load_paths].tap do |load_paths| | |
load_paths << "#{Rails.root}/app/assets/stylesheets" | |
load_paths << "#{Gem.loaded_specs['compass'].full_gem_path}/frameworks/compass/stylesheets" | |
load_paths << "#{Gem.loaded_specs['html5-boilerplate'].full_gem_path}/stylesheets" | |
load_paths << "#{Gem.loaded_specs['fancy-buttons'].full_gem_path}/lib/stylesheets" | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/sh | |
### BEGIN INIT INFO | |
# Provides: nginx | |
# Required-Start: $local_fs $remote_fs $network $syslog | |
# Required-Stop: $local_fs $remote_fs $network $syslog | |
# Default-Start: 2 3 4 5 | |
# Default-Stop: 0 1 6 | |
# Short-Description: starts the nginx web server | |
# Description: starts nginx using start-stop-daemon |