Skip to content

Instantly share code, notes, and snippets.

View jmhodges's full-sized avatar
🐶
return of the

Jeff Hodges jmhodges

🐶
return of the
View GitHub Profile
-module(recess_controller).
-import(error_logger).
-export([
render/2, render/3,
render_error/2,
not_found/1, not_found/2,
method_not_allowed/1, method_not_allowed/2,
internal_server_error/1, internal_server_error/2,
ambiguous_routing/1
]).
unless ARGV[0]
STDERR.puts "Hey, you suck. Include a process name to look for"
exit(1)
end
loop do
resident_mem =
`ps vx | grep -v grep | grep -v #{$0} | grep -i #{ARGV[0]}`.split(' ')[7]
puts "#{Time.now.to_i} #{resident_mem}" if resident_mem && !resident_mem.empty?
STDOUT.flush
class ReverseGeoThread < Thread; end
class ListingThread < Thread; end
def run
cj = caller.join
if cj =~ /reverse_geo/
klass = ReverseGeoThread
elsif cj =~ /listings/
klass = ListingThread
else
# this is how many Threads are currently allocated and in play
# over a 3 minute interval with the number of Threads being
# rechecked every two seconds
+4: Thread
+2: ThreadGroup
+2: Thread
+4: Thread
+2: ThreadGroup
+2: Thread
+4: Thread
class MemoryProfiler
# profile is a CLEAN, totally minimal memory profiler:
#
# * 1 thread
# * 2 hashes (curr, prev)
# * classes as keys
# * fixnums as values.
#
SELECT count(DISTINCT "searches".id) AS count_distinct_searches_all
FROM "searches"
LEFT OUTER JOIN "queries" ON "queries".id = "searches".query_id
INNER JOIN "tasks" ON tasks.search_id = searches.id
WHERE
(
(
(
(
NOT exists(
# fakefs will break autoloading in your tests. You can correct this by
# eval'ing the modules you care about before requiring fakefs. One way
# to do this would be to take the top-level module (or class) that
# contains modules (or classes) to be autoloaded and eval all of them
# in.
def autoload_all(namespace)
namespace.constants.each do |c|
const = namespace.module_eval c
autoload_all(const) if const.is_a? Module
# The code in lib/foobar.rb
require 'sinatra/base'
class Foobar < Sinatra::Base
VERSION = '1.0.0'
configure do
set :foobar, environment
end
end
# The tests in test/test_foobar.rb
# Nokogiri 1.2.4
irb(main):001:0> j = Nokogiri::HTML.parse('<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">')
=> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"></head></html>
irb(main):002:0> j.at('meta')
/opt/local/lib/ruby/gems/1.8/gems/nokogiri-1.2.4/lib/nokogiri/xml/node.rb:634: [BUG] Segmentation fault
ruby 1.8.7 (2008-08-11 patchlevel 72) [i686-darwin9]
# Nokogiri 1.2.3
→ irb -rrubygems -rnokogiri
irb(main):001:0> j.at('meta')
NameError: undefined local variable or method `j' for main:Object
from (irb):1
irb(main):002:0> j = Nokogiri::HTML.parse('<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">'); j.at('meta')
encoding error : output conversion failed due to conv error, bytes 0xCF 0x26 0x41 0xC0
I/O error : encoder error
=>