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
| String.prototype.closest = function(find, pos) { | |
| var found = -1; | |
| var cur1,cur2; cur1 = cur2 = pos; | |
| while (cur1 > 0 || cur2 <= this.length) { | |
| is = this.substr(cur1, find.length); | |
| it = this.substr(cur2, find.length); | |
| if (is == find) return cur1; |
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 is a 10:45:01 test | |
| * | |
| x | |
| * * | |
| x x | |
| * | |
| y | |
| * test position | |
| x/y positive / negative result |
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
| String.prototype.closest2 = function(find, pos) { | |
| var cur = 0; | |
| while (cur <= this.length) { | |
| if (pos + cur <= this.length) var is = this.substr(pos + cur, find.length); | |
| if (pos - cur > 0) var it = this.substr(pos - cur, find.length); | |
| if (is == find) return pos + cur; | |
| if (it == find) return pos - cur; | |
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
| // I have no idea what anyone would want to use this for. | |
| function ask(questions, passcb, failcb) { | |
| var require = []; | |
| var pass = []; | |
| var fail = []; | |
| for (var question in questions) { | |
| if (question.search('required') > -1) { | |
| require.push(question); |
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 Script = process.binding('evals').Script; | |
| Script.runInNewContext('setTimeout(function() {sys.puts(\'2 seconds\')}, 2000);', {sys: require('sys'), setTimeout: setTimeout}); | |
| var sandbox = {setTimeout: setTimeout, callback: function(output) { | |
| require('sys').puts('Output: ' + output); | |
| }}; | |
| Script.runInNewContext('setTimeout(function() {callback.call(this, \'2 more seconds\');}, 2000);', sandbox); |
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 sys = require('sys'); | |
| var EventEmitter = require('events').EventEmitter; | |
| var Script = process.binding('evals').Script; | |
| function EventScript(code, filename) { | |
| this.code = code; | |
| this.filename = filename; | |
| }; | |
| sys.inherits(EventScript, EventEmitter); |
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 jsdom = require('jsdom'); | |
| var request = require('request'); | |
| request.get({url: 'http://google.com/', followRedirect: true}, function(err, res, body) { | |
| if (!err) { | |
| if (res.statusCode == 200) { | |
| jsdom.env(body, ['http://code.jquery.com/jquery-1.5.min.js'], function(errors, window) { | |
| $ = window.jQuery; | |
| $('#lga').append('<div>WHAT</div>'); |
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
| Backbone.CompatModel = function(attributes, options) { | |
| var defaults; | |
| attributes || (attributes = {}); | |
| if (options && options.parse) attributes = this.parse(attributes); | |
| if (defaults = getValue(this, 'defaults')) { | |
| attributes = _.extend({}, defaults, attributes); | |
| } | |
| if (options && options.collection) this.collection = options.collection; | |
| this.attributes = {}; | |
| this._escapedAttributes = {}; |
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
| path = require('path') | |
| loader = (ns) -> | |
| ns = ns.toString() | |
| parts = ns.split /\./ | |
| requirePath = ns.replace /\./g, '/' | |
| try | |
| requirePath = path.dirname(require.main.filename) + '/' + requirePath | |
| require requirePath |
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
| ns = {} | |
| test = 0 | |
| class ns._Users | |
| constructor: -> | |
| test++ | |
| class ns.Users | |
| _instance = undefined |
OlderNewer