Skip to content

Instantly share code, notes, and snippets.

// Show popup when user hovers over a child element of a container div.
$('div.child', '#container').mouseover(function() {
$('#popup').show();
});
// But hide it only when the mouse pointer leaves the container. Mouseout doesn't
// work here because of event bubbling - it'll trigger on child elements of
// #container as well.
$('#container').bind('mouseleave', function() {
$('#popup').hide();
# Micro-benchmark for new OrderedHash impl in http://github.com/rails/rails/commit/355f41d8aafd75d76db25cdda4736e0052b0605c
class OrderedHash < Hash
def initialize(*args, &block)
super
@keys = []
end
def []=(key, value)
if !has_key?(key)
@keys << key
@chuyeow
chuyeow / Results
Created December 1, 2008 04:08
Is JSON.parse! faster?
user system total real
json:parse 0.100000 0.010000 0.110000 ( 0.106557)
json:parse! 0.110000 0.000000 0.110000 ( 0.129599)
$ ./hpricot_vs_nokogiri.rb
user system total real
hpricot:doc 0.230000 0.010000 0.240000 ( 0.265904)
nokogiri:doc 0.030000 0.010000 0.040000 ( 0.041641)
user system total real
hpricot:xpath 1.050000 0.020000 1.070000 ( 1.114454)
nokogiri:xpath 0.210000 0.010000 0.220000 ( 0.226418)
user system total real
hpricot:css 1.140000 0.030000 1.170000 ( 1.339635)
nokogiri:css 0.700000 0.010000 0.710000 ( 0.835559)