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(array_plus) { | |
| function x_flatten(array, sum) { | |
| sum = sum || []; | |
| var y; | |
| for (var x = array.length-1; x >= 0; x--) { | |
| y = array[x]; | |
| if ((typeof y) == "object" && y.length) { | |
| x_flatten(y, sum); | |
| } else { | |
| sum.unshift(y); |
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
| # see: http://www.codenothing.com/archives/2010/8-jquery-micro-optimization-tips/ | |
| # usage: cat application.js | ruby jQuery.live2delegate.rb | |
| puts $_.to_s.gsub(/\((.+?)\)\.live\(/, '.root.delegate(\1,') while $stdin.readline rescue exit(0) |
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
| // modified from http://javascript.crockford.com/remedial.html | |
| String.prototype.safe_supplant = function (o) { | |
| return this.replace(/{([^{}]*)}/g, function (a, b) { | |
| var r = o[b]; | |
| if (typeof r === 'string') { | |
| return r.replace(/</g, '<').replace(/"/g, '"').replace(/'/g, '''); | |
| } else { | |
| return (typeof r === 'number') ? r : a; | |
| } | |
| }); |
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
| # Sometimes you just need objects that spew placeholder strings | |
| # | |
| # Regular supplant style http://javascript.crockford.com/remedial.html | |
| # >> x = SupplantTemplate.new | |
| # => "" | |
| # >> x.client.company_name | |
| # => "{client_company_name}" | |
| # >> x.client | |
| # => "{client}" |
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
| // | |
| // UIWindow+MyWindow.h | |
| // | |
| #import <Foundation/Foundation.h> | |
| @interface UIWindow (MyWindow) | |
| - (void)addEventMonitor:(void *)monitor; | |
| - (void)removeEventActivityMonitor:(void *)monitor; | |
| - (void)pendingMouseUpCount; |
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
| /* tested on the iPad and iPhone */ | |
| function getZoomFactor() { | |
| var deviceWidth, landscape = Math.abs(window.orientation) == 90 | |
| // workaround for strange screen.height on the iPhone (v3.1.3) | |
| if (window.screen.width == 320) deviceWidth = landscape ? 480 : 320 | |
| else deviceWidth = window.screen[landscape ? "height" : "width"] | |
| return deviceWidth / window.innerWidth | |
| } |
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
| Index: trunk/FBConnect/FBConnectHooks.php | |
| =================================================================== | |
| --- trunk/FBConnect/FBConnectHooks.php (revision 206) | |
| +++ trunk/FBConnect/FBConnectHooks.php (working copy) | |
| @@ -%ld,%ld +%ld,%ld @@ | |
| // Don't include jQuery if it's already in use on the site | |
| #$out->includeJQuery(); | |
| // Temporary workaround until until MW is bundled with jQuery 1.4.2: | |
| - $out->addScriptFile('http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js'); | |
| + $out->addInlineScript('!window.jQuery && document.write(unescape("%3Cscript src=\"http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js\"%3E%3C/script%3E"))'); |
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(url_parts, params) { | |
| var query_string = (url_parts && url_parts[1]); | |
| if (! query_string) return; | |
| var pairs = query_string.split('&'); | |
| for (var x = 0; x < pairs.length; x++) { | |
| var kv = pairs[x].split('='); | |
| params[decodeURIComponent(kv[0])] = decodeURIComponent(kv[1]); | |
| } | |
| // do useful with params | |
| })(window.location.href.split('?'), {}); |
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 Gruber | |
| # http://daringfireball.net/2010/07/improved_regex_for_matching_urls | |
| URL_REGEXP = %r{(?xi) | |
| \b | |
| ( # Capture 1: entire matched URL | |
| (?: | |
| [a-z][\w-]+: # URL protocol and colon | |
| (?: | |
| /{1,3} # 1-3 slashes | |
| | # or |
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
| // See: http://gist.github.com/537133 | |
| // standard script to track clicks on document elements, and send google analytic events | |
| // identifying which element was clicked (classname, id, href, src, csspath) | |
| // if "cssprefix_optional" is null, identify element as either using classname, id, href, src, csspath (order of preference) | |
| // if "pagename_optional" is null, identify "event category" as page filename | |
| (function(jQuery, pageTracker, cssselector, cssprefix_optional, pagename_optional) { | |
| if (! jQuery) return; | |
| try { | |
| var baseurl = window.location.href.split(/[?#;]/)[0]; | |
| var pathsegments = baseurl.split('/'); |