Skip to content

Instantly share code, notes, and snippets.

config.load_paths += Dir["#{RAILS_ROOT}/vendor/gems/**"].map do |dir|
File.directory?(lib = "#{dir}/lib") ? lib : dir
end
irb(main):001:0> class Foo
irb(main):002:1> def self.bar; p 'class'; end
irb(main):003:1> end
=> nil
irb(main):008:0> module Foo
irb(main):009:1> def self.bar; p 'module'; end
irb(main):010:1> end
TypeError: Foo is not a module
Rails
=============D
Merb
===================D
#!/usr/bin/env ruby
require 'rubygems'
require 'beanstalk-client'
if ARGV.length > 0 && ARGV[0] == 'config'
puts "graph_title Beanstalk Queue Size"
puts "graph_vlabel watching"
puts "watching.label Watching"
puts "graph_vlabel reserved"
#!/usr/bin/ruby
# Horridly hacked together by David Smalley (david@davidsmalley.com) with bits pulled from the
# Rspec spec_server script, and the acts_as_ferret ferret_start/ferret_stop scripts
# 11/01/2007
require File.expand_path(File.dirname(__FILE__) + '/../config/boot')
require RAILS_ROOT + '/config/environment'
require 'async_observer/worker'
# Rails doesn't have a way to pre-generate javascript cache files
# This is lifted directly from rails ..
def write_asset_file_contents(joined_asset_path, asset_paths)
unless file_exist?(joined_asset_path)
FileUtils.mkdir_p(File.dirname(joined_asset_path))
File.open(joined_asset_path, "w+") { |cache| cache.write(join_asset_file_contents(asset_paths)) }
end
end
namespace :javascript do
#!/usr/bin/env ruby
#
# Be sure to configure this node in the plugin configuration
# Memory stats must be run by root
# Ex:
# [passenger_memory]
# user root
# env.memory_stats_command path_to_passenger-memory-stats
#
#!/usr/bin/env ruby
#
# [passenger_processes]
# user root
# env.process_stats_command /opt/ruby-enterprise-1.8.6-20080810/bin/passenger-status
#
process_stats_command = ENV['process_stats_command'] || '/opt/ruby-enterprise-1.8.6-20080810/bin/passenger-status'
if ARGV.length > 0 && ARGV[0] == 'config'
1926 David Heinemeier Hansson
1615 Jeremy Kemper
436 Rick Olson
377 Josh Peek
354 Jamis Buck
339 Nicholas Seckar
295 Michael Koziarski
244 Pratik Naik
156 Marcel Molina Jr.
142 Geoff Buesing
#!/usr/bin/env ruby
command = '/opt/ruby-enterprise-1.8.6-20080810/bin/passenger-memory-stats'
memory_limit = 200 # megabytes
def running?(pid)
begin
return Process.getpgid(pid) != -1
rescue Errno::ESRCH
return false