Skip to content

Instantly share code, notes, and snippets.

// Blog post: http://brandonaaron.net/blog/2010/03/4/event-delegation-with-jquery
// Try this instead of the above (didn't test)
$('#container').delegate('a.top', 'click', function(e) {
log( $(this).text() + ' clicked1');
return false;
});
.selector {
/* styles that change how the element acts/positons */
position: relative; top: 0; left: 0; display: block; float: left; z-index: 1; overflow: hidden;
/* styles that change its dimensions */
margin: 0; border: 1px solid #000; padding: 0; width: 0; height: 0;
/* sstyles that change its appearance */
background: #777 url(/images/image.png) 0 0 no-repeat; color: #000;
/*
* Sugar for type detection working across frames and browsers ;)
*
* Detected types
*
* 'arguments', 'array', 'boolean', 'date', 'document', 'element', 'error', 'fragment',
* 'function', 'nodelist', 'null', 'number', 'object', 'regexp', 'string', 'textnode',
* 'undefined', 'window'
*
* Copyright (c) 2009 Daniel Steigerwald (http://daniel.steigerwald.cz), Mit Style License
/*
* Sugar for type detection working across frames and browsers ;)
*
* Detected types
*
* 'arguments', 'array', 'boolean', 'date', 'document', 'element', 'error', 'fragment',
* 'function', 'nodelist', 'null', 'number', 'object', 'regexp', 'string', 'textnode',
* 'undefined', 'window'
*
* Copyright (c) 2009 Daniel Steigerwald (http://daniel.steigerwald.cz), Mit Style License
// requires nightly version of jQuery b/c it uses the add special event hook
// more about special event hooks: http://brandonaaron.net/blog/2009/06/4/jquery-edge-new-special-event-hooks
(function( $ ) {
$.event.special.hashchange = {
setup: function( data, namespaces ) {
if ( 'onhashchange' in window ) {
// sweet, native support... short-circuit
return false;
}
// onhashchange is not natively supported ... work around it :(
Element.Methods.update_old = Element.Methods.update;
Element.Methods.update = function() {
Element.Methods.update_old.apply(this, arguments);
$.livequery.run();
};
Ajax.Responders.register({
onComplete: function() { $.livequery.run(); }
});
$(document).ajaxSend(function(event, request, settings) {
// pass authenticity token with requests
// requires global AUTH_TOKEN var to be set by Rails:
// <%= javascript_tag "var AUTH_TOKEN = #{form_authenticity_token.inspect};" if protect_against_forgery? %>
settings.data = (settings.data ? settings.data + "&" : "") + "authenticity_token=" + encodeURIComponent( AUTH_TOKEN );
// make respond_to jump to the js block
if ( settings.dataType == 'html' ) request.setRequestHeader("Accept", "text/javascript");
});
# environment variables
export PATH=/usr/local/bin:$PATH
export PATH="$HOME/bin:$PATH"
export PATH=/usr/local/git/bin:$PATH
export PATH="/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:$PATH"
export MANPATH=/usr/local/git/man:$MANPATH
export EDITOR="mate -w"
export SVN_EDITOR="mate -w"
# aliases
alias flushdns="dscacheutil -flushcache"
alias svnaddall='svn status | grep "^\?" | awk "{print \$2}" | xargs svn add'