Skip to content

Instantly share code, notes, and snippets.

@tenbits
tenbits / Class.Store.js
Last active February 4, 2016 11:15
Class Store. Same interface for XHR Transport and MongoDB driver
// atma-class
// common node.js and browser
var Article = Class('Article', {
Base: Class.Serializable({
date: Date
}),
_id: null,
date: null,
body: '',
@tenbits
tenbits / obj_normalize.js
Last active December 26, 2015 11:49
Object normalization - needs to be improved
var obj_normalize = (function() {
function runNormalizer(currentValue, normalizer) {
if (typeof normalizer === 'function')
return normalizer(currentValue);
// other types of normalization, like Regexp-Replace
return currentValue.replace(normalizer[0], normalizer[1]);
@tenbits
tenbits / RegExpUtil.js
Last active December 17, 2015 21:19
string to regexp
RegExp.fromString = function(str, flags) {
return new RegExp(str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&"), flags);
};
@tenbits
tenbits / inline-eval.js
Created February 17, 2013 10:30
komodo inline eval macro
var view = ko.views.manager.currentView,
scimoz = view.scimoz,
selection = scimoz.selText,
result = null,
log = function() {
var message = '';
for (var i = 0; i < arguments.length; i++) {
message += arguments[i] + ' ';
}
@tenbits
tenbits / eval.js
Created December 19, 2012 12:20
Komodo IDE Macro. Unit Testing Thing. Evaluate selected or full source code. Evaluates also code in comment: /*{test} .... */
var view = ko.views.manager.currentView,
scimoz = view.scimoz,
selection = scimoz.selText || scimoz.text,
service = Components.classes["@mozilla.org/consoleservice;1"].getService(Components.interfaces.nsIConsoleService),
log = function() {
var message = '';
for (var i = 0; i < arguments.length; i++) {
message += arguments[i] + ' ';
}
@tenbits
tenbits / Deferred
Last active August 29, 2015 13:58
Deferred
function Deferred(){}
(function(){
Deferred.prototype = {
_isAsync: true,
_done: null,
_fail: null,
_always: null,