This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-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 | |
]). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MemoryProfiler | |
# profile is a CLEAN, totally minimal memory profiler: | |
# | |
# * 1 thread | |
# * 2 hashes (curr, prev) | |
# * classes as keys | |
# * fixnums as values. | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 | |
=> |