Skip to content

Instantly share code, notes, and snippets.

@mikewilcox
mikewilcox / Dojo Replace
Created January 31, 2013 23:52
Converts older dojoType/dojoAttachEtc to data-dojo-etc
komodo.assertMacroVersion(3);
if (komodo.view) { komodo.view.setFocus(); }
Find_ReplaceAllInMacro(window, 0, 'dojoAttachEvent', 'data-dojo-attach-event', false, 0, 0, false, false);
Find_ReplaceAllInMacro(window, 0, 'dojoAttachPoint', 'data-dojo-attach-point', false, 0, 0, false, false);
Find_ReplaceAllInMacro(window, 0, 'dojoType', 'data-dojo-type', false, 0, 0, false, false);
@mikewilcox
mikewilcox / Komodo Quote Conv Cmd
Created January 31, 2013 23:48
Convert double quotes to single quotes
komodo.assertMacroVersion(3);
if (komodo.view) { komodo.view.setFocus(); }
ko.views.manager.currentView.scimoz.beginUndoAction();
var str = ko.views.manager.currentView.scimoz.selText;
str = str.replace(/\"/g, "'");
komodo.view.selection = str;
ko.views.manager.currentView.scimoz.endUndoAction();
@mikewilcox
mikewilcox / SuperDeclare.js
Created January 25, 2013 03:44
Testing an inheritance system
var declare = function(){
var
args = Array.prototype.slice.call(arguments)
constructors = [],
protos = [];
for(var i = 0; i < args.length; i++){
if( typeof args[i] === 'function'){
console.log(' fn', args[i].prototype.constructor);
constructors.push(args[i]);
@mikewilcox
mikewilcox / on_example.js
Created July 18, 2012 13:41
Example file of a an event connection system
(function(b){
// NOTE: "b" is the main library, "bv" (BetterVideo)
var cons = {}, aListeners = {};
var fns = [];
var theOne;
var topics = {};
var d_topics = {};
var DEFAULT_TIMER = 30;
var WKADJUST = (b.is_chrome && b.is_chrome()) ? -20 : -120; // don't break if sniff.js is not incl
@mikewilcox
mikewilcox / Deferred.js
Created June 7, 2012 16:25
Deferred Error Testing
require([
"dojo/Deferred"
], function(Deferred){
var useError = 0 ;
var getError = function(name, useThisError){
var msg = name + ' error';
return useError || useThisError
?
@mikewilcox
mikewilcox / AnonymousArgument.js
Created February 20, 2012 19:05
Function Statements, Definitions, Literals, and Expressions
myArray.sort(function(a,b){
// compare a and b
});