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
| Class.Initializers = {}; | |
| Class.initializer = function(obj){ return this._initializer_ = obj; } | |
| Class.Mutators.initialize = function(initialize){ | |
| if(!this._initializer_) return initialize; // quick exit | |
| return function(){ | |
| this._init_ = initialize; | |
| for (var modifier in Class.Initializers) { | |
| if (!this[modifier]) continue; | |
| this[modifier] = Class.Initializers[modifier].call(this, this[modifier]); |
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
| Number.implement({ | |
| parsePermissions : function(){ | |
| var types = {r : 4, w : 2, x : 1 }, levels = {u : 1, g : 8, o : 64 }, perms = {}; | |
| for(l in levels){ | |
| for(t in types) perms[l+t] = !!(this & (levels[l] * types[t])); | |
| } | |
| return perms; | |
| } | |
| }); |
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
| Element.implement({ | |
| truncate : function(len,str,mid){ | |
| var str = str || '...'; | |
| var mid = !!mid; | |
| var w = this.getSize().x; | |
| if( w < len) return this; | |
| var txt = this.get('text'); | |
| var char_size = Math.ceil(w / txt.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
| Element.implement({ | |
| truncate : function(len,str,mid){ | |
| var str = str || '...'; | |
| var mid = !!mid; | |
| var w = this.getSize().x; | |
| if( w < len) return this; | |
| var txt = this.get('text'); | |
| var char_size = Math.ceil(w / txt.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
| /* Window.Growl, version 2.0: http://icebeat.bitacoras.com | |
| * Daniel Mota aka IceBeat <[email protected]> | |
| * Updated to 1.2b2 by Paul Streise <[email protected]> | |
| * Updated to 1.2.2 by nwhite.net | |
| --------------------------------------------------------------------------*/ | |
| var Gr0wl = {}; | |
| Gr0wl.Base = new Class({ | |
| Implements : [Chain], |
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
| /* | |
| MooTools 1.2 Custom Backwards-Compatibility Library | |
| By David Isaacson | |
| Portions from Mootools 1.2 by the MooTools production team (http://mootools.net/developers/) | |
| Copyright (c) 2006-2007 Valerio Proietti (http://mad4milk.net/) | |
| Copyright (c) 2008 Siafoo.net | |
| Cleaned up, shortened and logging added by Nathan White (http://www.nwhite.net) | |
| */ |
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'), | |
| times = 500000 | |
| function bm(label, fn) { | |
| var start = +new Date | |
| fn() | |
| sys.puts(' ' + label + ' : ' + (+new Date - start) + ' ms') | |
| }; |
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
| Model.define('User',{ | |
| collection : 'test_user', // (optional) if not present uses the model name instead. | |
| // defines your data structure | |
| types: { | |
| _id : Object, // if not defined, Mongoose automatically defines for you. | |
| username: String, | |
| first : String, | |
| last : String, |
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
| result = {'array':[1,2,3], | |
| 'string':'hello', | |
| 'hash':{'a':1, 'b':2}, | |
| 'date':new Date(), // Stores only milisecond resolution | |
| 'int':42, | |
| 'float':33.3333, | |
| 'regexp':/foobar/i, | |
| 'boolean':true, | |
| 'null':null}; |
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 assert = require('assert') | |
| , subclass = function(type, proto){ | |
| // make sure we are extending a global constructor | |
| // accepted: [Boolean, Number, String, Array, Object, Function, RegExp, Date] | |
| if(!global[type.name] || global[type.name].name != type.name) throw new Error(); | |
| var constructor = proto.constructor, | |
| keys = Object.keys(proto), | |
| Obj = process.binding('evals').Script.runInNewContext('x = '+type.name), // eval ftw |
OlderNewer