This file contains 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
/** | |
* @file IVARTECH Events Class | Mediator pattern | |
* @author Nikola Stamatovic Stamat <stamat@ivartech.com> | |
* @copyright IVARTECH http://ivartech.com | |
* @version 20130313 | |
* | |
* @namespace ivar.patt | |
*/ | |
//TODO: write support for ['foo','baz','baz'] |
This file contains 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
Array.prototype.chain = function() { | |
var res = undefined; | |
var args = []; | |
var i = 0; | |
while (arguments.hasOwnProperty(i)) { | |
args.push(arguments[i]); | |
i++; | |
} | |
This file contains 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
//SORT WITH STRINGIFICATION | |
sortProperties = function(o, fn) { | |
var res = {}; | |
var props = keys(o); | |
props = fn ? props.sort(fn): props.sort(); | |
for(var i = 0; i < props.length; i++) { | |
res[props[i]] = o[props[i]]; | |
} |
This file contains 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
//SORT WITH STRINGIFICATION | |
var orderedStringify = function(o, fn) { | |
var props = []; | |
var res = '{'; | |
for(var i in o) { | |
props.push(i); | |
} | |
props = props.sort(fn); | |
This file contains 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
/** | |
* A hash table value value storage for quick seek in large lists of big objects/arrays/strings. | |
* It uses CRC32 algorithm to convert supplied values into integer hashes and produce more elegant solution escaping data redundancy and heavy memory loads but also leaning on native hash map implementation for seek speed and optimization. | |
* | |
* @author Nikola Stamatovic Stamat < stamat@ivartech.com > | |
* @copyright ivartech < http://ivartech.com > | |
* @version 1.0 | |
* @date 2013-07-02 | |
* @namespace ivar.data | |
*/ |
This file contains 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
#Complete dictionary merge | |
def update(d1, d2): | |
for k,v in d2.items(): | |
if k in d1 and type(d1[k]) is dict and type(v) is dict: | |
update(d1[k], v) | |
else: | |
d1[k] = v | |
return d1 | |
#Deep merges two dictionaries to a given level, after that level it only overwrites the values |
This file contains 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
import os | |
import imp | |
def importFromURI(self, uri, absl=False): | |
if not absl: | |
uri = os.path.normpath(os.path.join(os.path.dirname(__file__), uri)) | |
path, fname = os.path.split(uri) | |
mname, ext = os.path.splitext(fname) | |
no_ext = os.path.join(path, mname) |
This file contains 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
/** | |
* @file IVARTECH Map data class | |
* @author Nikola Stamatovic Stamat <stamat@ivartech.com> | |
* @copyright IVARTECH http://ivartech.com | |
* @version 20130313 | |
* | |
* @namespace ivar.data | |
*/ | |
/** |
This file contains 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
//Returns the object's class, Array, Date, RegExp, Object are of interest to us | |
var getClass = function(val) { | |
return Object.prototype.toString.call(val) | |
.match(/^\[object\s(.*)\]$/)[1]; | |
}; | |
//Defines the type of the value, extended typeof | |
var whatis = function(val) { | |
if (val === undefined) |
This file contains 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 fancyDate(then, now, suffix) { | |
if(now === undefined) | |
now = new Date(); | |
if(suffix === undefined) | |
suffix = 'ago'; | |
var thenMs = null; | |
typeof then === 'number' ? thenMs = then : thenMs = then.getTime(); | |
var nowMs = null; |