Skip to content

Instantly share code, notes, and snippets.

DEPRECATION WARNING: RAILS_ROOT is deprecated! Use Rails.root instead. (called from join at /Users/xac/swx/eve-alert/gems/bundler/gems/shoulda-5bdb93ac5542865aecd4806415ea2a68ea660c1c-rails3/lib/shoulda/autoload_macros.rb:40)
/Users/xac/swx/eve-alert/gems/bundler/gems/shoulda-5bdb93ac5542865aecd4806415ea2a68ea660c1c-rails3/lib/shoulda/autoload_macros.rb:40:in `join': can't convert #<Class:0x101ea7fe8> into String (TypeError)
from /Users/xac/swx/eve-alert/gems/bundler/gems/shoulda-5bdb93ac5542865aecd4806415ea2a68ea660c1c-rails3/lib/shoulda/autoload_macros.rb:40:in `autoload_macros'
from /Users/xac/swx/eve-alert/gems/bundler/gems/shoulda-5bdb93ac5542865aecd4806415ea2a68ea660c1c-rails3/lib/shoulda/autoload_macros.rb:40:in `map'
from /Users/xac/swx/eve-alert/gems/bundler/gems/shoulda-5bdb93ac5542865aecd4806415ea2a68ea660c1c-rails3/lib/shoulda/autoload_macros.rb:40:in `autoload_macros'
from /Users/xac/swx/eve-alert/gems/bundler/gems/shoulda-5bdb93ac5542865aecd4806415ea2a68ea660c1c-rails3/lib/shoulda/rails.rb:1
@benders
benders / Gemfile
Created January 13, 2010 23:21
Very, very, very quick guide to using gem bundler
gem "rails", "2.3.5"
gem "sqlite3-ruby"
clear_sources
source "http://gemcutter.org"
disable_system_gems
bundle_path 'gems'
LoadModule passenger_module <your-passenger-root-path>/ext/apache2/mod_passenger.so
PassengerRoot <your-passenger-root-path>
PassengerUseGlobalQueue on
PassengerMaxPoolSize 16
PassengerPoolIdleTime 0
PassengerMaxRequests 1000
@benders
benders / check_bj_activity.rb
Created November 7, 2009 21:51
Script for checking BackgroundJob activity, suitable for Cron or Nagios
#!/usr/bin/env ruby
# Crontab example:
# 55 * * * * (cd $HOME/rails-app/current ; ./script/check_bj_activity.rb >/dev/null)
TEST_SQL = <<-SQL
SELECT COUNT(*) FROM bj_job WHERE state = 'finished'
AND finished_at > DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR)
SQL
# -*- ruby -*-
God.watch do |w|
w.name = "couchdb"
w.interval = 10.seconds
w.start = "su - couchdb -s /bin/bash -c '/usr/local/bin/couchdb -b'"
w.stop = "su - couchdb -s /bin/bash -c '/usr/local/bin/couchdb -d'"
w.pid_file = "/usr/local/var/run/couchdb.pid"
@benders
benders / add_method_tracer-singleton.rb
Created July 10, 2009 06:31
Use New Relic add_method_tracer with Class methods
class Product < ActiveRecord::Base
class << self
# Define a public instance method on the singleton Class named Product
def get_recommended_for_subscriber(subscriber)
# ... call some web service, then use find to return a product instance ...
end
add_method_tracer :get_recommended_for_subscriber, 'Custom/Product.get_recommended_for_subscriber'
end
@benders
benders / add_method_tracer-wrong.rb
Created July 10, 2009 06:29
Failing strawman for New Relic add_method_tracer
# This doesn't work
class Product < ActiveRecord::Base
# Define a public Class method on Product
def self.get_recommended_for_subscriber(subscriber)
# ... call some web service, then use find to return a product instance ...
end
add_method_tracer :get_recommended_for_subscriber, 'Custom/Product.get_recommended_for_subscriber'
# Instance methods of Product go here
From: "Stuart Slade" <shiva06804>
Date: Mon Aug 19, 2002 07:53:22 AM US/Pacific
Subject: Nuclear Warfare 101
The Nuclear Game - An Essay on Nuclear Policy Making
When a country first acquires nuclear weapons it does so out of a very accurate perception that possession of nukes fundamentally changes it relationships with other powers. What nuclear weapons buy for a New Nuclear Power (NNP) is the fact that once the country in question has nuclear weapons, it cannot be beaten. It can be defeated, that is it can be prevented from achieving certain goals or stopped from following certain courses of action, but it cannot be beaten. It will never have enemy tanks moving down the streets of its capital, it will never have its national treasures looted and its citizens forced into servitude. The enemy will be destroyed by nuclear attack first. A potential enemy knows that so will not push the situation to the point where our NNP is on the verge of being beaten. In effect, the effect of acquiring nuclear weapons is t
# Settings specified here will take precedence over those in config/environment.rb
# The production environment is meant for finished, "live" apps.
# Code is not reloaded between requests
config.cache_classes = true
# Use a different logger for distributed setups
# config.logger = SyslogLogger.new
# Full error reports are disabled and caching is turned on
@benders
benders / gist:134278
Created June 23, 2009 00:15
God setup for Apache httpd (Red Hat)
We couldn’t find that file to show.