Skip to content

Instantly share code, notes, and snippets.

@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 / exif-date-touch.js
Last active April 13, 2024 18:30
nodejs script to set a file modification date from EXIF
/**
* Change file modification time to the date from EXIF
*
* System Requirements:
*
* > npm install -g includejs
* > npm install -g exif
*
* Usage:
*
@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 / 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);
}
})();
@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] + ' ';
}