Tag: development
-
Mouse Wheel Handling in Prototype/Javascript
Here’s how to handle mouse wheel events in prototype, code heavily borrowed from other places on the net, but brought together and made unobtrusive: /* Mouse Wheel */ Object.extend(Event, { wheel:function (event){ var delta = 0; if (!event) event = window.event; if (event.wheelDelta) { delta = event.wheelDelta/120; if (window.opera) delta = -delta; } else if […]
-
Simple Javascript Validation
I hunted around for a good Javascript class to use for validation and finally clobbered together this from various sources on the net. This should be extremely useful for anyone doing client-side validation. Validate = { forMinLength: function(whatYouTyped, length_min) { var fieldset = whatYouTyped.parentNode; var txt = whatYouTyped.value; if (txt.length >= length_min) { fieldset.className = […]
-
Multiple DB connections in Rails/ActiveRecord
You might often want to connect to different databases using ActiveRecord. Here’s how you do it: #DB definitions: class DatabaseCurrent < ActiveRecord::Base self.abstract_class = true establish_connection settings[‘database’] end class DatabaseOld < ActiveRecord::Base self.abstract_class = true establish_connection settings[‘database2’] end #Model definitions (current): class Video < DatabaseCurrent belongs_to :user set_table_name :videos end class Photo < DatabaseCurrent belongs_to […]
-
Deploying JAR/JAD content via WAP
An easy way to deploy JAR/JAD content on all phones with GPRS is to create a WML site and provide a link to the JAR file that you have. [As an aside, the whole J2ME scene is so fragmented that it sucks completely. Let’s hope Android sorts it out.] Here’s how you go about setting […]