This file contains hidden or 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() { | |
var queue = []; | |
function checkQueue() { | |
if (queue.any()) | |
queue.pop().fire("dom:modified"); | |
} | |
var notify; | |
function deferFire(element) { | |
if (!queue.include(element)) |
This file contains hidden or 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
# Pipe Ars Technica's live Apple event coverage into a Campfire room. | |
# http://arstechnica.com/apple/news/2010/01/tablet-live-event-liveblog.ars | |
# | |
# Usage: | |
# $ gem install -r hpricot tinder | |
# $ ruby -rubygems ars_live.rb -ssl mysubdomain myroomid myapikey | |
require "hpricot" | |
require "open-uri" | |
require "tinder" |
This file contains hidden or 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
[RAILS_ROOT]/app/models/projects/comment.rb:146:in `ping_commentable' | |
[RAILS_ROOT]/app/models/projects/history.rb:13:in `ignore' | |
[RAILS_ROOT]/app/models/projects/comment.rb:146:in `ping_commentable' | |
[RAILS_ROOT]/vendor/rails/activesupport/lib/active_support/callbacks.rb:178:in `send' | |
[RAILS_ROOT]/vendor/rails/activesupport/lib/active_support/callbacks.rb:178:in `evaluate_method' | |
[RAILS_ROOT]/vendor/rails/activesupport/lib/active_support/callbacks.rb:166:in `call' | |
[RAILS_ROOT]/vendor/rails/activesupport/lib/active_support/callbacks.rb:93:in `run' | |
[RAILS_ROOT]/vendor/rails/activesupport/lib/active_support/callbacks.rb:92:in `each' | |
[RAILS_ROOT]/vendor/rails/activesupport/lib/active_support/callbacks.rb:92:in `send' | |
[RAILS_ROOT]/vendor/rails/activesupport/lib/active_support/callbacks.rb:92:in `run' |
This file contains hidden or 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
// In most browsers, a <label> tag around a form field, e.g.: | |
// | |
// <label> | |
// <input type="checkbox" id="private" name="private"> | |
// This message is private | |
// </label> | |
// | |
// works just as if you'd specified a for= attribute on the label | |
// for the first visible field inside the label. In Safari 4, this | |
// seems not to be the case (i.e. the for= attribute is required). |
This file contains hidden or 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() { | |
var focusInHandler = function(e) { e.findElement().fire("focus:in") }; | |
var focusOutHandler = function(e) { e.findElement().fire("focus:out") }; | |
if (document.addEventListener) { | |
document.observe("focus", focusInHandler, true); | |
document.observe("blur", focusOutHandler, true); | |
} else { | |
document.observe("focusin", focusInHandler); | |
document.observe("focusout", focusOutHandler); |
This file contains hidden or 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
Element.addMethods({ | |
preservingScrollPosition: function(element, callback) { | |
element = $(element); | |
var offset = element.cumulativeOffset().top - document.viewport.getScrollOffsets().top; | |
callback(); | |
window.scrollTo(0, element.cumulativeOffset().top - offset); | |
return element; | |
} | |
}); |
This file contains hidden or 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
token Op {'/' || '*' || '+' || '-'}; | |
token Value { \d+[\.\d+]? }; | |
token Item { <Value> || <Op> }; | |
token Expr { [<ws> <Item> <ws>]+ }; | |
sub do_op($lhs, $rhs, $op) { | |
given $op { | |
when '*' { $lhs * $rhs } | |
when '+' { $lhs + $rhs } | |
when '-' { $lhs - $rhs } |
This file contains hidden or 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
#!/usr/bin/env macruby | |
# % gdb macruby ns_url_protocol_test.rb | |
# | |
# (gdb) run ns_url_protocol_test.rb http://www.google.com/ | |
# Starting program: /usr/local/bin/macruby ns_url_protocol_test.rb http://www.google.com/ | |
# | |
# received 4900 bytes | |
# | |
# Program exited normally. |
This file contains hidden or 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 Tcl | |
class << self | |
# Returns a well-formed Tcl list from the given array of strings. | |
def array_to_list(array) | |
array.map { |element| string_to_word(element.to_s) }.join(" ") | |
end | |
# Returns a well-formed Tcl word from the given string. | |
def string_to_word(string) | |
should_be_braced?(string) ? brace_string(string) : escape_string(string) |
This file contains hidden or 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
# A library for downloading issues of Harpers from the archives. | |
# | |
# To use, log in to the archives from your web browser. Then set the | |
# HARPERS_ARCHIVE_COOKIE environment variable to the value of the .harpers.org | |
# "archive" cookie, which you can find by visiting the following URL while on | |
# the Harpers website: | |
# | |
# javascript:prompt("HARPERS_ARCHIVE_COOKIE",document.cookie.match(/(?:;|^)\s*archive=(.+?)(?:;|$)/)[1]) | |
# | |
# Example: |