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
| // ============================ | |
| // $.myMethod-based plugin | |
| // ============================ | |
| (function($){ | |
| var ns = $.myMethod = function( options ) { | |
| options = $.extend( {}, ns.options, options ); | |
| // Awesome code goes here |
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
| // "Maximum encryption" | |
| function rot13( str ) { | |
| return ( str || '' ).replace( /[a-z]/ig, function(a){ | |
| var n = a.charCodeAt(0); | |
| return String.fromCharCode(n>109||n<97&&n>77?n-13:n+13); | |
| }); | |
| }; |
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
| #!/bin/bash | |
| # Tested in OS X 10.5 | |
| # | |
| # Echo a list of all bound IPs. If an IP is passed, echo that | |
| # IP if it is currently bound. | |
| IPLIST=$(ifconfig -u | grep -w 'inet' | grep -v '127[.]0[.]0[.]1' | cut -d ' ' -f 2 | sed 's/^ *//;s/ *$//') | |
| if [ $1 ]; then |
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
| // (c) 2010 NY Times Co. | |
| // (for work) | |
| (function($){ | |
| $.fn.billboardSlider = function( options ) { | |
| options = $.extend( {}, $.fn.billboardSlider.options, options ); | |
| return this.each(function(){ | |
| var that = $(this), |
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
| /*! | |
| * jQuery liveOne - v0.1 - 07/30/2010 | |
| * http://benalman.com/ | |
| * | |
| * Copyright (c) 2010 "Cowboy" Ben Alman | |
| * Dual licensed under the MIT and GPL licenses. | |
| * http://benalman.com/about/license/ | |
| */ | |
| // The power of .live and .one, together at last! |
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
| (* | |
| * Launch Firefox - v1.0 - 7/31/2010 | |
| * http://benalman.com/ | |
| * | |
| * Copyright (c) 2010 "Cowboy" Ben Alman | |
| * Dual licensed under the MIT and GPL licenses. | |
| * http://benalman.com/about/license/ | |
| *) | |
| -- Usage: |
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
| // Plugin released: | |
| // http://benalman.com/projects/jquery-misc-plugins/#each2 |
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
| // The basic premise, splicing data into an array used as a map of some sort | |
| // (assume that numbers 1-9 are placeholders for legitimate splice args) | |
| m = Array(100); | |
| s = 'splice'; | |
| m[s](1); | |
| m[s](2); | |
| m[s](3); // do this kind of thing many times | |
| // Before: | |
| m=Array(100); |
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
| // This might be useful for certain size-limited JS competitions, or not. #js | |
| function super_shrinkify( str ){ | |
| if ( str.length % 2 ) { | |
| str += ' '; | |
| } | |
| var prefix = '"', | |
| suffix = '".replace(/./g,function(a){a=a.charCodeAt();return String.fromCharCode(a>>7,a%128)})', | |
| str_bytes = unescape( encodeURIComponent( str ) ).length, |
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
| // Using `with` in this way will net 2N-3 bytes savings for N var | |
| // declarations, but it sure makes using YUI compressor harder! | |
| var m=Math,s=m.sin | |
| with(Math)var s=sin | |
| var m=Math,s=m.sin,c=m.cos | |
| with(Math)var s=sin,c=cos | |
| var m=Math,s=m.sin,c=m.cos,n=m.min |