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
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 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 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 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 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 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 zsh | |
function resolve_symlink() { | |
local result=`readlink $1` | |
[ -z $result ] && echo $1 || $0 $result | |
} | |
function expand_path() { | |
cd -qP $1 | |
pwd |
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
# Using Sprockets in Rails 3 | |
MyApp::Application.routes.draw do | |
match 'application.js', :to => Sprockets::Server.new(YAML.load_file(Rails.root.join("config/sprockets/application.yml"))) | |
end |
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
// Mobile Safari doesn't fire touchstart or touchend events for | |
// input[type=text], input[type=password], input[type=search], | |
// and textarea elements. | |
(function() { | |
if (!("createTouch" in document)) return; | |
var selector = "input[type=text], input[type=password], input[type=search], textarea"; | |
function fire(element, type, identifier) { | |
var touch = document.createTouch(window, element, identifier, 0, 0, 0, 0); |
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
#!/usr/bin/env ruby | |
# js1k packer | |
if ARGV[0] == "-n" | |
ARGV.shift | |
wrap = false | |
else | |
wrap = true | |
end |
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
# A reference counter that invokes a callback when it reaches zero. | |
# Use it to implement after-finished callbacks in asynchronous code. | |
(exports ? this).Finalizer = class Finalizer | |
@from: (finalizerOrCallback) -> | |
if finalizerOrCallback instanceof Finalizer | |
finalizerOrCallback | |
else | |
new Finalizer(finalizerOrCallback ? ->) |