Here is a handy script I’ve been using for MongoDB to retrieve a list of all the fields used in a collection. This uses a map/reduce routine and has to comb over all the documents in a collection so you may want to exercise caution when using this script. // […]
javascript
Slides
node.js at Facebook
Here is a solution for making simple JSONP requests in ExtJS 4 Ext.define('Ext.ux.JSONP', { extend: 'Ext.data.ScriptTagProxy', alias: 'ux.jsonp', createRequestCallback: function(request, operation, callback, scope) { var me = this; return function(response) { callback.apply(scope, [response]); operation.setCompleted(); operation.setSuccessful(); me.afterRequest(request, true); }; } });
Ext.ux.JSONP for ExtJS 4
Here’s a simple message bus/broker I wrote for Ext.js 4 Ext.define('Ext.ux.MessageBroker', { extend: 'Ext.util.Observable', statics: { instance: null, setInstance: function(i) { this.instance = i; }, sendMessage: function(msg, data) { this.fireEvent('message',{"msg":msg,"data":data}); } }, constructor: function(config){ this.addEvents({ "message" : true }); if(config && config.listeners) this.listeners = config.listeners; Ext.ux.MessageBroker.superclass.constructor.call(this, config) } }, function() […]
Simple message bus for extjs 4
Here is a simple Javascript class to calculate the percent of a gradient between two colors given the percent (as a float 0-1) and two colors. Uses functions from php.js. Color = function() { }; Color.hexdec = function(hex_string) { hex_string = (hex_string + '').replace(/[^a-f0-9]/gi, ''); return parseInt(hex_string, 16); } Color.dechex […]
Calculate a color gradient in Javascript
Here is a direct replacement for Java’s String.hashCode() method implemented in Javascript. I wrote this function to fulfill a requirement at work. Apparently, the back-end engineers thought hashCode() was a standard function. One of the hurdles for this project was not only figuring out how to translate the mathematical formula […]
Javascript implementation of Java’s String.hashCode() method
Recently I embarked on a quest to design a framework which would help us keep track of large and complex javascript projects in easily identifiable and extendable patterns. After some thought and deliberation, we eventually settled on the observer pattern using Ext’s Ext.util.Observable object as the base object to use […]
Primitive OOP observer pattern with ExtJS

I recently worked on improving performance in a labor scheduling application. The app was originally designed to load all the employees at one time in one large chunk, processing and stuffing the data into various places as needed on startup. This all worked fairly well on average stores with 50-100 […]
Cleaning up unresponsive script errors
Being a scripted language whose behavior can vary depending on the browser environment it is run in, Javascript can be particularly difficult to work with and debug sometimes. Here are a few tools I’ve found to be helpful: Firebug for FireFox, along with other handy extensions Visual Studio 2005+, Script […]
Javascript resources
JSLint is a very helpful code quality utility for javascript that purports to hurt your feelings but helps you write ECMAScript compliant code. Many development suites like Aptana now include lint checking while you code. A major advantage of making sure your code is linted is that it ensures your […]