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
| // Wrangling with "ghost clicks" in Sencha Touch... is this hungry enough to eat them? | |
| // Based on http://stackoverflow.com/questions/6457220/sencha-touch-button-handler-called-twice-for-single-click-why | |
| // Put this somewhere global and early. (top of app.js?) | |
| document.addEventListener('touchend', function(e) { | |
| var node = e.target; | |
| while (node) { | |
| if ( | |
| (node.localName && node.localName.toLowerCase && node.localName.toLowerCase() === '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
| # from: https://github.com/zimbatm/direnv/blob/3bb35d375331fca89614f0015b2a6cd21688ab79/bin/direnv | |
| # usage: abs_dirname $filename | |
| # finds the original $filename path and prints it's absolute folder path | |
| abs_dirname() { | |
| prev_path="$1" | |
| # Resolve the symlink(s) recursively | |
| while true; do | |
| abs_path=`readlink "$prev_path"` | |
| if [ -z "$abs_path" ]; then | |
| abs_path="$prev_path" |
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
| // Like underscore.js "filter", but returns an object with the keys and values | |
| // instead of just an array of values. | |
| Object.prototype.filter = function(obj, predicate) { | |
| var result = {}, key; | |
| for (key in obj) { | |
| if (obj.hasOwnProperty(key) && predicate(obj[key], key, obj)) { | |
| result[key] = obj[key]; | |
| } |
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) -> | |
| # Module systems magic dance. | |
| if (typeof require == "function" && typeof exports == "object" && typeof module == "object") | |
| # NodeJS | |
| module.exports = plugin | |
| else if (typeof define == "function" && define.amd) | |
| # AMD | |
| define -> plugin | |
| else | |
| # Other environment (usually <script> tag): plug in to global chai instance directly. |
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
| another filename |
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
| var setIntervalSynchronous = function (func, delay) { | |
| var intervalFunction, timeoutId, clear; | |
| // Call to clear the interval. | |
| clear = function () { | |
| clearTimeout(timeoutId); | |
| }; | |
| intervalFunction = function () { | |
| func(); | |
| timeoutId = setTimeout(intervalFunction, delay); | |
| } |
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
| JSONCircular = (circularValue = '[Circular]') -> | |
| cache = []; | |
| return (key, value) -> | |
| if (typeof value is 'object' && value isnt null) | |
| if (cache.indexOf(value) isnt -1) | |
| return circularValue; | |
| cache.push(value); | |
| return value; | |
| # use: |
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
| app.use (req, res, next) -> | |
| if req.url.indexOf('/fake') isnt -1 | |
| req.url = req.url.replace('/fake', '/ghost') | |
| next() |
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
| /** | |
| * Handlebars.js partial parent context access I wrote. | |
| * See https://github.com/wycats/handlebars.js/issues/182#issuecomment-4445747 | |
| */ | |
| Handlebars.registerHelper('$', function ( child, options ) { | |
| if ( typeof child !== 'object' ) { | |
| return ''; | |
| } | |
| child['$_'] = this; | |
| return options.fn( child ); |
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 Custom Errors in Node.js | |
| * http://dustinsenos.com/articles/customErrorsInNode | |
| */ | |
| // Grab the util module that's bundled with Node | |
| var util = require('util') | |
| // Create a new Abstract Error constructor | |
| var AbstractError = function (msg, constr) { |