Skip to content

Instantly share code, notes, and snippets.

@tenbits
tenbits / Deferred
Last active August 29, 2015 13:58
Deferred
function Deferred(){}
(function(){
Deferred.prototype = {
_isAsync: true,
_done: null,
_fail: null,
_always: null,
@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 / 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 / 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 / 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 / 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 / kudu-iis.md
Last active March 21, 2016 11:19
Kudu
@tenbits
tenbits / dragger.js
Created January 30, 2013 12:24
element dragger - simple requestAnimationFrame example
window.dragger = (function() {
var requestAnimationFrame = (function() {
return window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame ||
function(callback) {
return setTimeout(callback, 17);
}
})();
var x = new RegExp( "/" )
console.log(x.test( "/hello" ));
var serializedRegexParser = /^\/(.+)\/(\w+)?$/
var serializedRegex = x.toString();
console.log('serializedRegex:', serializedRegex);
var matches = serializedRegexParser.exec(serializedRegex);
var [full, regexString, regexFlags] = matches;
import '/bower_components/spectrum/spectrum.css';
import '/bower_components/spectrum/spectrum.js';
define ColorPickButton {
slot domInsert () {
this.$.find('.color-picker').spectrum({
cancelText: 'Abbrechen',
chooseText: 'Auswählen',
allowEmpty: true,