Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env ruby
# put in /etc/munin/plugins and restart munin-node
# by Dan Manges, http://www.dcmanges.com/blog/rails-application-visualization-with-munin
# NOTE: you might need to add munin to allow passwordless sudo for passenger-memory-stats
def output_config
puts <<-END
graph_category App
graph_title Passenger memory stats
graph_vlabel count
@vitaly
vitaly / passenger_status
Created April 6, 2011 16:40
passenger_status plugin for munin
#!/usr/bin/env ruby
def output_config
puts <<-END
graph_category App
graph_title passenger status
graph_vlabel count
sessions.label sessions
max.label max processes
✗ which bundle
bundle () {
if (
unset bundle
command -v bundle > /dev/null 2>&1
)
then
true
else
if (
module Devise
module Models
# Validatable creates all needed validations for a user email and password.
# It's optional, given you may want to create the validations by yourself.
# Automatically validate if the email is present, unique and it's format is
# valid. Also tests presence of password, confirmation and length
module Validatable
# All validations used by this module.
VALIDATIONS = [ :validates_presence_of, :validates_uniqueness_of, :validates_format_of,
# Lets say you have f1, f2, f3 - functions provided by some API that you can't change
# and they use the standard (err, res...) callback scheme
# then suppose you need to call 3 of them one after the other
# the usual js way will be this:
foo = (params, callback) ->
f1 something, (err, res) ->
if err
callback err
else
f2 something, (err, res) ->
class C
def initialize(x)
@x = x
end
def each(&block)
@x.times(&block)
end
include Enumerable
safe do
local :path => "backup/:kind"
tar do
archive "a1", :files => "some-directory-to-backup"
end
end
require "fileutils"
safe do
local :path => "backup1"
tar do
archive "a1", :files => "some-directory-to-backup"
end
end
safe do
#!/usr/bin/env ruby
require 'base64'
require 'openssl'
require 'digest/sha1'
def ask(prompt)
STDOUT.print "#{prompt}: "
readline.strip
end
def self.postprocess(id)
Measurement.find(id).postprocess!
end
def postprocess!
process_start!
ImagesPostProcess.inspector_post_process("/demo/measurements/#{id}")
process_end!
end