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
(function(){ | |
function focusInHandler(e){ | |
Event.element(e).fire("focus:in"); | |
} | |
function focusOutHandler(e){ | |
Event.element(e).fire("focus:out"); | |
} | |
if (document.addEventListener){ | |
document.addEventListener("focus", focusInHandler, true); |
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 was surprisingly difficult to find, the documentation and API is poor | |
require "net/http" | |
require "uri" | |
url = URI.parse("http://www.whatismyip.com/automation/n09230945.asp") | |
req = Net::HTTP::Get.new(url.path) | |
req.add_field("X-Forwarded-For", "0.0.0.0") | |
# For content type, you could also use content_type=(type, params={}) |
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
(function(){ | |
function delegateHandler(e){ | |
var element = e.element(), elements = element.ancestors ? element.ancestors().concat([element]) : [element]; | |
((Element.retrieve(this, 'prototype_delegates') || $H()).get(e.eventName || e.type) || []).each(function(pair){ | |
if (element = Selector.matchElements(elements, pair.key)[0]) | |
pair.value.invoke('call', element, e); | |
}); | |
} | |
function delegate(element, selector, event, handler){ |
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
CONTENT_TYPES = {:html => 'text/html', :css => 'text/css', :js => 'application/javascript'} | |
before do | |
# instead of using case here, metaprogram it | |
request_uri = case request.env['REQUEST_URI'] | |
when /\.css$/ : :css | |
when /\.js$/ : :js | |
else :html | |
end | |
content_type CONTENT_TYPES[request_uri], :charset => 'utf-8' |
NewerOlder