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
require 'logger' | |
require 'rubygems' | |
require 'wirble' | |
require 'pp' | |
Wirble.init | |
Wirble.colorize | |
# require 'utility_belt' | |
if ENV.include?('RAILS_ENV')&& !Object.const_defined?('RAILS_DEFAULT_LOGGER') | |
Object.const_set('RAILS_DEFAULT_LOGGER', Logger.new(STDOUT)) |
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
# If your workers are inactive for a long period of time, they'll lose | |
# their MySQL connection. | |
# | |
# This hack ensures we re-connect whenever a connection is | |
# lost. Because, really. why not? | |
# | |
# Stick this in RAILS_ROOT/config/initializers/connection_fix.rb (or somewhere similar) | |
# | |
# From: | |
# http://coderrr.wordpress.com/2009/01/08/activerecord-threading-issues-and-resolutions/ |
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
class User | |
# ... | |
def method_missing(sym, *args) | |
if sym.to_s =~ /\A(.*)\?\z/ && ROLES.include?($1) | |
roles.include?($1) | |
else | |
super | |
end | |
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/bash | |
### ABOUT | |
### Runs rsync, retrying on errors up to a maximum number of tries. | |
### Simply edit the rsync line in the script to whatever parameters you need. | |
# Trap interrupts and exit instead of continuing the loop | |
trap "echo Exited!; exit;" SIGINT SIGTERM | |
MAX_RETRIES=50 |
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
This example shows how to setup an environment running Rails 3 under 1.9.2 with a 'rails3' gem set. | |
∴ rvm update --head | |
# ((Open a new shell)) or do 'rvm reload' | |
# If you do not already have the ruby interpreter installed, install it: | |
∴ rvm install 1.9.2 | |
# Switch to 1.9.2-head and gemset rails3, create if it doesn't exist. | |
∴ rvm --create use 1.9.2@rails3 |
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
# | |
# Settings for php-cgi in external FASTCGI Mode | |
# | |
# Should php-fastcgi run automatically on startup? (default: no) | |
START=yes | |
# Which user runs PHP? (default: www-data) |
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
#!/usr/bin/env ruby | |
# | |
# Helper script to temporary fix some RubyMine 2.0.2 functionality by | |
# creating old-style Rails 2 scripts. This enables me actually to | |
# run & debug apps and use the Rails console. | |
# | |
# On my machine I have to increase the debugger timeout to connect to a | |
# Rails 3 app on Ruby 1.9.1. This is done for OS X by modify the Info.plist | |
# to increase the timeout. | |
# |
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
# part of config/enviroment.rb | |
... | |
Rails::Initializer.run do |config| | |
# Load model files from sub folders | |
config.load_paths += Dir["#{RAILS_ROOT}/app/models/*"].find_all { |f| File.stat(f).directory? } | |
# Load middleware - initially used by flash-session-hack | |
config.load_paths << "#{RAILS_ROOT}/app/middleware" |
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
From 02e5f09f4d96c4f8ac0c2172008aef0117a70f3e Mon Sep 17 00:00:00 2001 | |
From: Ryan Bigg <[email protected]> | |
Date: Sat, 10 Jul 2010 20:14:30 +1000 | |
Subject: [PATCH] Remove ugly caller trace. | |
--- | |
lib/i18n/backend/base.rb | 2 +- | |
1 files changed, 1 insertions(+), 1 deletions(-) | |
diff --git a/lib/i18n/backend/base.rb b/lib/i18n/backend/base.rb |
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
def kata(digits = [], has_pair = false) | |
if digits.inject {|sum, digit| sum + digit } == 15 | |
has_pair ? [digits] : [] | |
else | |
start = (digits.last || 0) + 1 | |
(start..9).inject([]) do |result, digit| | |
result + kata(digits + [digit], has_pair) + kata(digits + [digit, digit], true) | |
end | |
end | |
end |
OlderNewer