Source Line of Code Counter
Since I couldn't find a SLOC (source line of code) counter that satisfies me, I decided to write one. This SLOC counter equipped with a file system browser which is very handy for precisely defining inclusion and exclusion of files/directories. Besides that, the SLOC counter supports pattern matching for file inclusion and exclusion, and directory inclusion using regular expression. The usage section of this post has a detailed list on how to use pattern match.
This LOC counter is written in Visual C# 2005. That means you need Microsoft .NET Framework 2.0 to run this program. You can download a free copy of .NET Framework from here.
A Compilation of YUI Callback
I have been coding JavaScript with YUI for quite a while now. Still, I am consistently confused by various callback functions in YUI. The thing that troubled me the most was the parameters those callback functions take. The API documentation does not provide any information about this. For example, if you go to YAHOO.util.Event, under addListener method, the description for parameter fn as follow: <Function> The method the event invokes.
Yes, it's a straightforward description, but it doesn't help too much. What I really need is the signature of this callback function. For the purpose of my own use, and to benefit the community, I decided to make a compilation of callbacks in YUI.
The Missing Parameter of jQuery.post
When coding JavaScript that requires a lot of DOM manipulations, jQuery no doubt is my favorite JavaScript framework. Surprisingly, with file size of 26KB (packed distribution), it supports Ajax along with many other handy features.
If you've previously used jQuery's Ajax API, you probably noticed that there's a jQuery.getJSON() function call that grabs the server response from a given URL and parses it into a JSON object. However, you couldn't find the corresponding method from online documentation for post request, namely jQuery.postJSON.
Tableless Image Gallery - An Experiment of Fluid Grid
Today I want to build a tableless image gallery. The motivation came from a web project I am currently doing. In one of the web pages I am coding, I need to make a grid layout and put image thumbnails in it. I started off by using table to layout the grid. Although it turned out nicely, the gallery itself is not very friendly to DOM manipulation. For instance, when removing a table cell during a delete operation using Ajax, a hole remains in the gallery.
I told myself that there must be a better way to do this. So I started experimenting tableless grid layout. It took me a while, but I am quite satisfied by the result. You can take a look how the finish product looks like or download sample layout files. For illustration of deletion using Ajax, I used jQuery to perform a simple DOM removal operation, which removes a clicked cell off the grid. While you are testing the online example, look closely how the gap is being filled when a cell is removed. I've tested it in IE 6 and Firefox 2.0.0.7, and both worked like a charm.
Easy JSON Encoding/Decoding in PHP
So you are writing a piece of PHP code to handle some Ajax request and you've just finished coding the business logic. It is time to output some server response so that the page which initiated the Ajax request can obtain the requested result.
You decided to use JSON because you don't want to get your hands dirty by traversing nodes after nodes. After encoding a fairly complex and nested PHP array into JSON, you find out writing such code is very unpleasant and you start wondering if there is an easier way to do this. The answer is yes - Zend Framework will save your day.

