Tuesday, April 1, 2008

A website finally!

Since ten years ago, I never had any good feeling about writing personal or business website for myself until I realized the additional income potential out of it. I started writing intranet static pages and wrote as part of a fairly large enterprise team a large corporate website as part of my day-to-day jobs but never got the change to reflect on writing a site for myself.

Anyway, I finally deployed one Demo Site this month. I choose Slicehost after weighing what my wallet could afford at this point.

Why Bill Gates is Reckoned to be the Greatest Gift to Secular Humanity

Thursday, February 14, 2008

A simple DRY

It's interesting a lot of people come to like how ROR organized directories eg app, lib, public, db, etc. The point of attack seems to be homogeneous but nevertheless very handy when bundling particular category.

I come to like it too a lot specially expecting the controllers, model can concentrate on its functionalities rather than cluttering the classes/modules with bits and pieces of delegate methods.

Below is a simple DRY (don't repeat yourself) implementation of a template pattern inside ApplicationController (class require's are not explicitly shown). The main intent is to have one entry call for getting a util class. The redundant other implementation would require if-else statements to extract the Util class per controller.

class ApplicationController
...
def user_template
util = get_util #template_method
util._method1
...
end

...
def get_util #template_method
end
...
end

class AController < ApplicationController
def get_util
UtilA
end
end

class BController < ApplicationController
def get_util
UtilB
end
end

# lib/ folder classes

class Util
def self._method1
end
end

class AUtil < Util
def self._method1
#customized implementation here
end
end

class BUtil < Util
def self._method1
#customized implementation here
end
end

Why Bill Gates is Reckoned to be the Greatest Gift to Secular Humanity

Tuesday, February 5, 2008

Windows JS debugger

My old desktop has .NET installation on it just for the sole purpose of stepping-through the javascript error when opening my web apps with IE. It was kind of a sitting elephant doing the work of a fly but what choice do I have when IE script debugger was pretty much lame in doing strep-thru debug?

Now with Visual Web Developer freely available, this can be a huge sigh of relief when tracking down javascript errors may it be browser compatibility issues or just plain syntax error.

Why Bill Gates is Reckoned to be the Greatest Gift to Secular Humanity

Thursday, January 31, 2008

IPV6 fix

I had an annoying problem with firefox while testing my rails code in dev mode. It's so terribly slow! At first, I tried to reinstall mongrel and some stuff to no effect. Until I started looking for answers from the net and came across with this Firefox IPV6 issue.

Initially, I didn't expect FF was the culprit since it's running perfectly well before I tried developing apps on my new Laptop.

Why Bill Gates is Reckoned to be the Greatest Gift to Secular Humanity




Monday, January 28, 2008

Developer Environment

I recently spliced 20G out of my 160GB laptop drive so I can install Fedora 7 and work my rails app from there. After spending a week trying to look for suitable graphics and network cards, I gave up and switched back to Vista for my code writing and decided to use the Linux instead for pre-production deployment. Newer laptops almost always comes with pain when newer hardware doesn't have the linux kernel drivers yet.

Of course, there are Intel drivers out there but at this point, I would rather wait for new kernels that may support the existing graphics hardware rather than spending so many precious times doing trial and error to get my 1280x800 graphics looks cool.

Why Bill Gates is Reckoned to be the Greatest Gift to Secular Humanity

Sunday, January 13, 2008

Prototype 1.6.0

Just recently, I have tried to incorporate Prototype library into some of my old javascript source codes and I found the relative ease of using it. I used to spend a lot of time trying to have compatibility between browsers and while functions can easily be replicated in other browsers, the look and feel has always been too cumbersome.

For example, to grab the element that triggers the event, you can just call Event.element(event) and acquired the object you wanted.

Prototype provides a lot of useful functions that you don't worry much whether you are running mozilla, firefox or any others browser. If encountering some compatibility issues, you can still get quirky by running series of Try.these functions to hit a supported feature.

I got an old tree nodes that I customized for an online storage web application. Manipulating these nodes is a breeze when using the library.

Some examples:

1. Finding nodes/nodes:

To traverse allNodes array, a new array function 'find' can do the job elegantly avoiding the use of for/if statements in your code.

var allNodes = [];

function findNodeById(id) {
return allNodes.find(function(n) {
return (node.id == id);
}
}

function findChildNodes(parentId) {
return allNodes.findAll(function(n) {
return (node.pid == parentId);
}
}

2. Declaring nodes

var Node = Class.create();
Node.prototype = {
initialize: function(id, pid, name, title, open, fileType, hasChildren){
this.id = id;
this.pid = pid;
this.name = name;
this.title = title;
this.icon = '';
this.iconOpen = '';
this.fileType = fileType;
this._io = open || false;
this._is = false;
this._ls = false;
this._hc = hasChildren;
this._ai = 0;
this.indents = [];
}
}

Why Bill Gates is Reckoned to be the Greatest Gift to Secular Humanity