July 30th, 2006
Heavily-scripted data entry forms that expand on-the-fly as the user enters new data make life easier for the user. However, it can be hell for a developer to devise a method for the representation and submission of data with arbitrary length and depth.
A logical thing to do seems to be to take an object-oriented approach to represent all client-side data as one or multiple JavaScript objects. The objects themselves could be arrays or objects with child objects and so on. Of course the objects need to be serialized in some way before they’re posted back. Now, if you’re using PHP at the back-end, you might make use one of the multitude of JSON implementations out there for posting back the data in JSON format and converting the data back to PHP objects (assuming that you want to end up with PHP objects.) JSON is pretty much native to JavaScript (clever use of the toSource method may cut it in most cases) but you need extra PHP code for deserialization.
If you want to take the opposite approach and use PHP-native serialization, then the following function will convert any complex JavaScript object into PHP-serialized string which can be converted back into PHP objects with a single call to the deserialize PHP function. Read the rest of this entry »
Posted in JavaScript, PHP | 2 Comments »
July 15th, 2006
A common mistake that most programmers do is to hard-code hand-counted lengths of string literals. For example:
if (!strncmp(str, "MAGIC_PREFIX_", 13))
{
...
}
Even if the string literal “MAGIC_PREFIX_” is not due to change in a life time, it makes the code more prone to human error and harder to read when the length of the string is hand-counted and hard-coded as a separate entity (13 in this case). Read the rest of this entry »
Posted in C++ | 1 Comment »
July 10th, 2006
I created this GIF animation back in 1997, when I used to play Quake 25 hours a day. I recall the tedious process of manual tweening to create the individual frames (by calculating the angle and position differences and dividing them by the number of frames) using Freehand. I would probably use Flash if I were to do it today…
Posted in Experiments | 3 Comments »
July 10th, 2006
JavaScript lacks a built-in function for getting the exact class names of object instances. The typeof operator just returns “object” for instances of both Object and Array, as well as user-defined classes. The following example illustrates this:
function MyClassA()
{
}
var obj = new Object();
var arr = new Array();
var myobj = new MyClassA();
document.write(typeof(obj) + "<br />");
document.write(typeof(arr) + "<br />");
document.write(typeof(myobj) + "<br />");
The output of the code above, with your browser is:
Read the rest of this entry »
Posted in JavaScript | 1 Comment »
July 10th, 2006
Win-Res-Q (read “win rescue”) is a simple utility that restores (shows) hidden windows. It can be used for bringing back your “lost” applications after their taskbar icons disappear following Explorer crashes that abundantly occur on Windows 98. It’s also useful for exposing strange, hidden windows lurking around your desktop.
Read the rest of this entry »
Posted in Freeware | 1 Comment »
July 10th, 2006
E-Res-Q (read “ee rescue”) is a very simple, portable POP3 mail reader. It enables you to selectively read and delete messages without having to download them all. It’s ideal for getting rid of large messages that clog up your mailbox or getting rid of spam messages without even downloading them.
Read the rest of this entry »
Posted in Freeware | 11 Comments »
July 10th, 2006
Two (or more) photographs of the same scene and that have different focal distances can be joined together to create an image where both distant and close objects can be in focus. Read the rest of this entry »
Posted in Experiments, Processing | No Comments »
April 18th, 2006
Adobe Photoshop’s Color Picker has a Custom Colors dialog that offers a wide variety of colors from several industry-standard color catalogs such as ANPA, DIC, Focoltone and Pantone.

Adobe Photoshop’s Custom Colors Dialog
The color catalog data comes from Adobe Photoshop Color Book files. These file have the .ACB file extension on Windows and reside inside the “…/Presets/Color Book” folder in a typical installation. Read the rest of this entry »
Posted in Projects | 7 Comments »
April 18th, 2006
Multiple photographs taken with different light sources can be blended together to create images that appear to have all the light sources simultaneously active. The light sources can be attributed arbitrary colors as well, allowing the creation of an infinite number of synthetic scenes. Read the rest of this entry »
Posted in Experiments, Processing | No Comments »