View gist:188817
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
// API | |
// all deparam methods return an object | |
$.deparam( params, coerce ) // deserialize params string, optionally coercing true, false, undefined, numbers | |
$.deparam.qs( coerce ); // get document query string as object | |
$.deparam.hash( coerce ); // get document hash as object | |
$.deparam.qs( params_or_url, coerce ); // get params from url or params string as object |
View gist:189027
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
// API | |
// history, window.onhashchange | |
$.history.add( params, merge_mode ); // set new 'state' (into location.hash, triggers hashchange event) | |
$.history.retrieve( key, coerce ); // get current 'state' (from location.hash, wrapper for $.deparam.hash) | |
$(window).bind( 'hashchange', function(e){ | |
e.hash; // the current 'state' as normalized hash string | |
e.retrieve(); // like $.history.retrieve but for this specific state |
View gist:189255
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 get_hash() { | |
var loc = document.location; | |
return loc.hash ? loc.href.replace( /^.*\#/, '' ) : ''; | |
} | |
if ( 0 ) { | |
var esh = $.event.special.hashchange = { | |
setup: function(){ | |
console.log( 'setup' ); | |
$(this).bind( 'hashchange', esh.handler ); |
View gist:190474
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
// API for jQuery BBQ: Back Button & Query Library | |
// ==== HISTORY, window.onhashchange ==== | |
// set new 'state' to location.hash (triggers hashchange event) | |
$.history.add( params, merge_mode ); | |
// get current 'state' from location.hash (wrapper for $.deparam.fragment) | |
$.history.retrieve( key, coerce ); |
View gist:194959
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
// proposed 'until' extension to jQuery.dir to support 'nextUntil' and 'prevUntil' | |
// suggested by LaC_OS_X | |
jQuery.dir = function( elem, dir, until ){ | |
var matched = [], cur = elem[dir]; | |
while ( cur && cur != document ) { | |
if ( cur.nodeType == 1 ) | |
matched.push( cur ); | |
if ( until && jQuery( cur ).is( until ) ) | |
return matched; |
View bash_prompt.sh
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
#!/bin/bash | |
# My bash prompt - Ben Alman | |
# Source: http://gist.github.com/194971 | |
# Screenshot: http://www.flickr.com/photos/rj3/3959554047/sizes/o/ | |
# | |
# In my home folder, [user@host:directory] on the 1st line, [HH:MM] on the 2nd line: | |
# | |
# [cowboy@benalman:~] | |
# [19:55:20] $ |
View jQuery.fn.nextUntil.js
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 has moved! Get it here: | |
// http://github.com/cowboy/jquery-misc/blob/master/jquery.ba-nextUntil.js | |
jQuery.fn.nextUntil = function( expr ) { | |
var elems = []; | |
this.nextAll().each(function(){ | |
return jQuery(this).is( expr ) | |
? false | |
: elems.push( this ); |
View gyazo.php
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
<?PHP | |
/* | |
* PHP upload for Gyazo - v1.2.1 - 3/13/2011 | |
* http://benalman.com/news/2009/10/gyazo-on-your-own-server/ | |
* | |
* Copyright (c) 2011 "Cowboy" Ben Alman | |
* Licensed under the MIT license | |
* http://benalman.com/about/license/ | |
*/ |
View gist:204177
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
// Potentially part of the jQuery urlInternal plugin | |
(function($){ | |
// Method: jQuery.isUrlFragment | |
// | |
// Test whether or not a URL is a fragment. The URL can either begin with # | |
// or be a partial URL or full URI, that when navigated to, only changes the | |
// document.location.hash. | |
// |
View jquery-param.js
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
// jQuery.param, pulled out of 1.4.2 | |
(function($){ | |
var r20 = /%20/g; | |
// Serialize an array of form elements or a set of | |
// key/values into a query string | |
$.param = function( a, traditional ) { | |
var s = []; |
OlderNewer