Skip to content

Instantly share code, notes, and snippets.

@jarrodbell
jarrodbell / gist:3762140
Created September 21, 2012 15:22
CommandFusion XML Parsing - JavaScript API
var parser = new DOMParser();
var xmlDoc = parser.parseFromString(body, 'text/xml');
// Get the data from XML
var results = xmlDoc.evaluate("//Item", xmlDoc, null, XPathResult.ANY_TYPE, null);
var infoItem = results.iterateNext();
while (infoItem) {
CF.log("Name Attribute: " + infoItem.getAttribute("Name"));
CF.log("Node Value: " + infoItem.childNodes[0].nodeValue);
infoItem = results.iterateNext();
# Taken from passenger_memory_stats script
# Returns the private dirty RSS for the given process, in KB.
def determine_private_dirty_rss(pid)
total = 0
File.read("/proc/#{pid}/smaps").split("\n").each do |line|
line =~ /^(Private)_Dirty: +(\d+)/
if $2
total += $2.to_i
end
@marshluca
marshluca / unicorn.rb
Created February 3, 2011 07:03
unicorn+nginx配置
# Sample verbose configuration file for Unicorn (not Rack)
#
# This configuration file documents many features of Unicorn
# that may not be needed for some applications. See
# http://unicorn.bogomips.org/examples/unicorn.conf.minimal.rb
# for a much simpler configuration file.
#
# See http://unicorn.bogomips.org/Unicorn/Configurator.html for complete
# documentation.
@jamiew
jamiew / Munin Passenger Phusion Memory Stats.rb
Created October 31, 2008 18:55
munin plugin to monitor Passenger Phusion memory stats
#!/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