Saturday, September 29, 2007

The Rich Men who Saved

Leafing through last night's Wall Street Journal, I found a book review about Chuck Feeney (here's a similar article I found online), my first response was, Chuck Who?

If you're like me who didn't know, Chuck was actually ranked 23th on Forbes Richest List in 1988. Except now, he isn't. He has already given out most of his wealth to charity. He belongs to a class of wealthy people whom I greatly admired. Among that class, the list includes people like:
  • Andrew Carnegie (Industrialist Magnate)
  • Warren Buffet (Berkshire Hathaway)
  • John D. Rockafeller (Standard Oil)
  • Sam Walton (Walmart)
  • Ingvar Kamprad (Ikea)
What distinguishes these men, are not just about their immense wealth, but that they lived a more modest lifestyle than most ordinary people despite being rich. This list is further segregated down to a few of my favourites, at the top being Warren Buffet, followed by Andrew Carnegie and J.D. Rockafella.

There is a common theme among these 3 I've mentioned, that they have contributed much to philantrophy. Buffet had given out his wealth under the auspices of the 'Bill and Merlinda Gates Foundation', not under his name. Carnegie and Rockafeller had also given their immense fortunes away, but they left behind a legacy that carried past them, in terms of their foundations, as well as with famous landmarks like Carnegie Hall and Rockafeller Centre.

I love people who are great contributors to philantrophy, but I believe that the motivations behind the contributions are equally important too. To quote John Train, from one of my favourite books, "Money Masters of Our Time":
"Philantrophy, while meritorious, on a large scale, becomes a political act. The tycoon who extracts a fortune from the public to build a museum in one place rather than another has not created new beauty, only imposed his priorities on society."
That is what really impressed me about Chuck. As rich as he is, he has given his wealth anonymously, not seeking to have his name etched into a monument for posterity.

It's just me, but I really enjoy people who are truly altruistic, because I believe that's what humanity is all about. I know it probably doesn't amount to much Chuck, but I'd like you to know that you have topped my list as the new No. 1 of the people that I have aspirations to be.

Personal Experiences

Over the course of my career, I had the opportunity to know a very well-off executive who holds a number of major positions in a number of Australia's biggest companies. He is however, a frugal man, who does not spend his money on excessive luxury items or fund himself for a flamboyant lifestyle. Not just that, he is an amazingly affable person, someone who has never carried himself as being snobbish or showoff-ish at all.

Between the occasional Subway lunch treats, and the dollar notes he dishes out of his wallet into the hands of the homeless people on the streets, I really don't see how different the rich are from the poor. The only differences that I know of, are those of jerks who install gold plated taps and those who are not.

Lesson Learnt

I see a lot of commonalities between these rich people, that they have inculcated the value of frugality in their lives. Perhaps it was the combination of an impoverished background and upbringing in their earlier years that defines this virtue, something I can relate from the experiences of my own personal life.

If rich men can live with such frugality, I certainly can't see why common people like us should have an excuse to participate in frivolous consumerism[1]. The credit card and the debt driven culture many have grown addicted to should be something that should be curtailed. If there is a lesson that everyone can take away from it will be that we should only spend what we can afford, but not in excess of it.

[1] The keyword here is frivolous. I don't think that consumerism is bad, per se. In the words of Henry Ford, "More production could lead to better wages, which in turn would lead to more spending by the public, yet more production and eventually even higher wages."
Monday, September 24, 2007

Why More Lisp and Less Prolog in the U.S.

Reading through the topics on Y Combinator, there seems to be renewed interest from people in learning Lisp, which is a language I've never heard of until recently. So I looked online for a primer on Lisp, to my surprise, I find Lisp similar to Prolog (in intent), which is something that I'm more familiar with, in relation to the AI classes that I took during my undergraduate studies.

But I was still curious why Prolog was hardly mentioned until I found this:
Q: How does Prolog differ from Lisp?

Lenat: There has been a constant dream in AI, by a large fraction of people in the field for 25 years, of the form: there really ought to be some way of formalizing and axiomatizing human thought and reason. But time and time again, all attempts at axiomatizing things have led people to trivialize them, to the point where they no longer apply to what they were originally modelled after in the real world.

There are a lot of people in the field who want to be sure, who want to believe that they can get absolutely precise, logically guaranteeable models that are close to what is going on in the real world. If you believe that, then the kinds of operations you want as primitives are logical operations, those involved simply in theorem proving. Those are the sort of operations that are present in Prolog.

Q: Why is Prolog used more in Europe than in the U.S.?

Lenat: In most European countries [and elsewhere- jb], you have very rigid hierarchies of 'ancient' professors, and then younger professors, and then research associates-- and then it filters down about seven levels to the people actually writing the programs. It is the people at the top who decide what research is going to get done, not the people at the bottom who have experience with what is actually happening.

The people at the top-- who [may] want to believe in a nice, simple, mathematical, axiomatizable universe-- basically determine the kind of research that is going to get done. The experiences that would lead them to change their minds are simply not occurring to them, they are occurring to the people at the bottom, who have no say.
(Quoted off:

That was just hilarious. I didn't realise that North America and the rest of the world hated each other so much when it comes to AI. Well, here's a more measured historical reference of why Lisp is used more commonly than Prolog in North America.
Sunday, September 23, 2007

Weekend Reading

It's been a while since I've been to a bookstore to pick up a book to read anymore, solely because that there is just so much to read online these days. However, unlike books, there is much less quality control on the net, and thus I tend to be even more picky in the things that I read. The following are a few I've picked that I'll like to share:

This is the blog of Marc Andreessen of the Netscape fame. Post-Netscape, he has been founded Opsware (which was acquired by HP) and Ning, a social-network creation site. If you're interested in the details of how startups, entrepreneur-ism, and his thoughts on the capital market, his blog will be an insightful read.

Brazen Careerist
As the author of Brazen Careerist, Penelope writes mostly about things related to career building, chatting about issues related to the workplace, lots of it by example. She sometimes talks about issues that are personal to her life as well, which gives a rather genuine feel to her blog than most.

Sudden Debt
While this guy writes anonymously about the market gyrations on Wall Street, he sounded like someone who is either and insider or pretty senior in the financial market. If you are interested in learning what the next major market pitfall might be, this blog will be for you, besides the fact that he has a wicked sense of humour!

Coding Horror
Who says that Computer Science can't be fun? Jeff Atwood, who writes on his blog called 'Coding Horror', deals with mostly fun stuffs related to Computer Science and IT in general. One of the sites that makes an entertaining read.

If there are any good quality blogs that you enjoy reading, feel free share what your favourite genre of blogs that you read, leave a URL as a comment, but no spammy, ad-laden sites please!

And have a good weekend read!
Thursday, September 20, 2007

My First 3 Lines of Code

When I was really young, my life ambition was to be a magician, followed by being a chef (which I did become briefly, as I mentioned in 'about me'). It was only in my early teens that I had my first hand experience with a computer which has piqued my interest in wanting to become a software hacker, ultimately which is now my career.

The trigger of it all, started from my first experience with a computer, during a school excursion I had to the Singapore Science Centre when I was 11. I remembered that it was an IBM PC computer, running a text-based graphical application with colours on a CGA display, which was probably quite an expensive model those days, given that computers usually came with green tinted monochrome monitors.

There was already an application running on the computer, which I only vaguely recalled that it had something to do with elevators. It was some sort of application teaching about some mathematical concept, using elevators as an example. How boring was that?!

Being the mischievous kid I was, rather than using the application 'correctly', the first thing I instinctively did was to start sweeping my palms across the keyboard, seeing if I could cause the application to do something that deviated from standard behaviour. By deviated, gee, I probably considered crashing the application as satisfying my criteria!

(Microsoft's GW-BASIC, the closest screenshot to what I remembered. Courtesy of Wikipedia)

But I got more than what I bargained for, as my random sweepings invoked the BASIC interpreter, which was built into the PC. That was a curious sight for me, given that the only thing that was visible was a flashing cursor, and a function menu at the bottom of the screen. I kept banging on the keyboard (rather violently), which really didn't do any much more, besides producing random gibberish on the screen.

It happened that there was a young man with his girlfriend, both probably in their mid-20's, who saw what I was doing, and walked towards me. I gave the guy a sheepish smile, thinking that he was going to give me an admonishment. Instead, he took over to the keyboard and typed the following:
10 INPUT "What is your name ?"; A$
20 PRINT "Hello "; A$
30 GOTO 10
Finishing that, he executed the application, and asked me to type in my name:
What is your name ? Vincent
Hello Vincent
What is your name ?
That was the first time I saw code and I was immediately hooked. The guy gave me a smile and walked off with his girlfriend, leaving me to tinkering around the with application.

While there's really not terribly much that I could code without any more knowledge, but even with that limitation, I did try writing my own variation of the application based on the only 3 instructions I knew and wrote a really lousy version of a text adventure game that I got bored real quick.

It'll be a few more years before I got to learn more programming, but that was how I've learnt my first 3 lines of code.

So what's your story with your first coding experience?
Tuesday, September 18, 2007

Installing Flash for Opera

The instructions for installing flash on Opera seems to be a little bit lacking, given that the flash installer script seems to think that Firefox is the only browser that I have and refuses to offer me an alternative installation path.

The way to get around that is to manually copy into the /plugins subdirectory under Opera's root directory. ( Thanks to the guy in #opera@freenode who told me to look under Tools |Preferences | Advanced tab | Content | plug-in options | to find out where to stick )

It's not too difficult to install the flash plugin, just download it, untar the archive, copy into the subdirectory and you're done!

While Flash works, it does not seem like it's working completely yet. On my console, I've noticed a couple of error messages like the ones below, which seems to suggest that the plugin isn't working as intended:
(process:27461): GLib-GObject-CRITICAL **: gtype.c:2254: initialization assertion failed, use IA__g_type_init() prior to this function

(process:27461): Gtk-CRITICAL **: gtk_clipboard_get_for_display: assertion `GDK_IS_DISPLAY (display)' failed
Adobe FlashPlayer: gtk_clipboard_get(GDK_SELECTION_PRIMARY); failed. Trying to call gtk_init(0,0);
opera: Plug-in 27461 is not responding. It will be closed.
opera: Define environment variable OPERA_KEEP_BLOCKED_PLUGIN to keep blocked plug-ins.
On sites like YouTube and Yahoo Finance, Flash seems to work properly, even with the error messages shown, but on, most of the Flash game widgets will not load, where the only output is only a grey box, indicating that the plugin isn't running.

('top' showing ~90% CPU utilization for Opera)

Other times, visiting sites with flash content on Opera will cause a 90% CPU utilization, the culprit being 'operapluginwrap'. This seems to affect other plugins as well.

Opera 9.50 is still an Alpha version, so I'll give it a benefit of a doubt. Hopefully these issues can be resolved in the Beta stage, and definitely I won't want to see this in a 'release-candidate'. Hope that the issue will be fixed soon!
Sunday, September 16, 2007

Analysis of a Mail Scam

It is actually surprising that that actually a spam/scam phishing mail actually made it past Gmail's filter, given that I have only had a handful of spam mails making through out of the years I've had the account.

If that made through, I'm sure other people would have received the same thing as well, so it might be a good idea to share with others this information, lest someone gets their bank account broken into.

Besides marking out my email addresses with XXXXX, the entire body of the message remains the same:
Received: from []
by localhost with POP3 (fetchmail-6.3.4)
for <XXXXX@localhost> (single-drop); Sat, 15 Sep 2007 13:30:05 -0700 (PDT)
Received: by with SMTP id h12cs126573wac;
Sat, 15 Sep 2007 13:21:15 -0700 (PDT)
Received: by with SMTP id t19mr4664427ant.1189887674970;
Sat, 15 Sep 2007 13:21:14 -0700 (PDT)
Received: from ([])
by with SMTP id i10si2529292wxd.2007.;
Sat, 15 Sep 2007 13:21:14 -0700 (PDT)
Received-SPF: neutral ( is neither permitted nor denied by domain of client-ip=;
Authentication-Results:; spf=neutral ( is neither permitted nor denied by domain of
Message-Id: <>
From: Bank Of America Security Team <>
Subject: *** Important Notice From Bank Of America Security Center ***
Date: Sat, 15 Sep 2007 13:21:16 -0700
MIME-Version: 1.0
Content-Type: text/plain;
Content-Transfer-Encoding: 7bit
X-Priority: 3
X-MSMail-Priority: Normal
X-Mailer: Microsoft Outlook Express 6.00.2600.0000
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000

We recently have determined that different computers have logged onto your Online Banking account, and multiple password failures were present before the
logons. We now need you to re-confirm your account information to us.

If this is not completed by September 17, 2007, we will be forced to suspend your account indefinitely, as it may have been used for fraudulent purposes. We
thank you for your cooperation in this manner.

To confirm your Online Banking records click on the following link:

Thank you for your patience in this matter.

Bank of America Customer Service

Please do not reply to this e-mail as this is only a notification. Mail sent to this address cannot be answered.

2007 Bank of America Corporation. All rights reserved.
The parts highlighted in red is the ones that people should look out for. Firstly, Bank of America decided to send me a mail via Yahoo, how interesting. The second part, being that instead of linking to Bank of America's website, an IP address is used for this purpose. That's a giveaway that the server isn't legitimate.

Doing a reverse DNS lookup via 'host' yields the following information:
Isn't that interesting to find out that Bank of America has to rely on someone's home ADSL connection. is one of the America's Internet providers, so I assume this has originated from somewhere in the US.

Doing a 'traceroute' seems to confirm that it came from somewhere in the East Coast, possibly New York, and the machine is still up and running.

Well either the hacker is really dumb, or some poor guy's machine has been compromised and became an unwitting accomplice in a phishing scam attempt. If you are one of the few who has received any warning email from Bank of America, take note, and don't fall for it.
Saturday, September 15, 2007

Cscope with Vim for finding Java symbols

Cscope, like ctags, allow you to find symbols in your source from multiple files in your project easily. While it was originally developed for C (easily inferred by the name), the project has extended to cover a number of other languages as well, Java included.

Before you mistake cscope as a rehash of my tip on using exuberant-ctags, let me explain why scope is different. Cscope has semantic knowledge of the Java as a language, and understands when you are looking for a symbol (a variable or method definition), and other useful search functions, like finding out other methods that invoke method you want, or listing all the methods definition uses.

(Image of Cscope in Action)

The advantage of semantic knowledge is that when you are looking for a variable or method, you won't be sent to some uncharted parts of your code, such as within your comments, just because there is a piece of text that matches the name.

To use it with vim as the default editor, you'll have to set that in the environment in your shell (where the following is for bash) if it isn't set already:

export EDITOR=/usr/bin/vim

You'll need to generate a list of files for cscope to be able to generate cross references to. This is easily done by using the find command in the root directory where your java files are found:

find ./ -name *.java > cscope.files

cscope.files is the filename that cscope will read each time it starts up, so make sure you adhere to that.

There are ways to allow cscope to run within vim instead of the other way round, but while I managed to do it after a bit of experimentation, I did find that I've used it with cscope invoking vim more commonly, whenever I need to fire it up and look for the methods or variables that I want from time to time. Happy cscoping!

If you like reading this, you may also enjoy:
Friday, September 14, 2007

Opera 9.50 Alpha

I have just downloaded Opera 9.50 for a test run, because Opera 9.23 wouldn't render my blog's menubar properly. The good news is, Opera 9.50 has fixed up the problem already. At least it means that Opera 9.23 is the problem, rather than my CSS code :)

(Image of Opera 9.50 running on Linux)

While I have been a happy Firefox user for the last few years, using Opera has been more of 'the spur of the moment' event, after reading's article about Opera's remarkable speed with respect to other browsers. While I wasn't not too keen on swapping browsers originally, I'm must say that I am pretty impressed by Opera's sleek user interface and it's high quality page renderings.

Although it is still a struggle for switching from what I'm used to, on the overall Opera is a pretty impressive browser, with some unusual features and capabilities that other browsers do not offer.

So for now I'm quite happy to give Opera a go, but it still remains to be seen if my preferences will stick in the long run.
Thursday, September 13, 2007

Hot Tech Gossips Heard Through the Grapevine

The things I've learnt about the Computing Industry today:

- That VMWorld is having a fantastic sellout with 10000+ attendees, each paying $1800 just to get into the event. At this number, it's more lucrative for VMWare to be an events company than trying to make money from selling software licenses.

- That the bad news is, Google's new data centre at North Carolina has cooling systems that spans an entire floor itself. The good news is, it's powered with hydro-electricity from some nearby dam. The bad news is, some hippie stood up in a conference moaning that Google is sucking up all water required for the hydro-power and killing all the salmons, maaaan. The good news is, well, it's probably unsubstantiated anyway. The bad news is, well, nobody really cares.

- That if Sun keeps giving software away to the open-source movement, they might as well change their ticker from 'JAVA' to 'FREE'. And while they are at that, they can start giving away their hardware for free too. At least they can make it all up with all the increase in volume.

- That Google is rumoured to have breached the 1 million machines mark with all their data centers combined. And that number is still growing, fast. Unfortunately, future growth will solely be limited by the moods of the delivery guys on a given day from now onwards.

Now that's a lot of heavy hitting disclosure from me within a single day. I'm seriously pushing it, man. Might even lose my job for disclosing them, you know?
Wednesday, September 12, 2007

Do not RTFM!

How many times have you ever been told to RTFM (Read the Fine Manual) when you got stuck with a problem? As a technically inclined person, even I myself find such responses unhelpful, especially when it propagates a snobbish, elitist attitude towards those who may be genuinely seeking help.

For most non-trivial problems, RTFM is probably the most time-consuming and least rewarding activity. Even worse, when the problem is truly cryptic, there is even a likely possibility that the manual will not have what you are looking for!

Unfortunately, the phenomenon of not finding what you want in the manuals happens more often than not in real life. Besides, the quickest way to learn something, is to ask somebody who already knows the subject matter well.

Most will be able to provide you with the right information straight on, or at least point you to the right direction to start looking. Just by knowing where to look will already massively reduce the time you'll spend scour at all the wrong places, minimizing unnecessary time loss from scanning through wrong documentation.

If you do not have the luxury of a friend who may know, Google is your next best friend. Querying a search engine will probably people who may have the same questions you have, and if it is widespread, generally someone will have posted up the solution out there.

If Google turns up with nothing, the next thing to try is to look out for mailing lists, IRC channels, or forums where you can locate people who share the same interests. Many will be helpful, and some will probably be experienced enough to give you an immediate answer to what you're looking for. Personally, it has been amazing to find out how much you can learn by just reading chatlogs of special interest group channels on IRC.

If there is one class of people who should be subjected to the RTFM treatment, it has to be the serial offenders who always leech onto you for help, even for the most trivial of things. For such situations, the RTFM is always an appropriate and recommended response:

"Read The F**king Manual!"
Monday, September 10, 2007

Coming out, then taken down

It seems like just within a day, there is a lot of buzz generated about a teacher from Raffles Institution, one of the top schools in Singapore. The major news is that he has came out of the closet, asserting his gay identity, but has promptly taken down his article shortly after.

But when the genie's out of the bottle, it's hard to put it back in again, as a search on Google's cache easily pulled out the original article. I believe he has his reasons to take down his post, so re-posting it will only fan the flames and not be helpful to his cause, so it won't be appropriate to give any links to the article in respect of his privacy.

I pretty much share the same views with Aaron Ng on this issue, and like him, I do have an aversion for gays. But this is well justified for, given that I've been 'picked up' by random gay men on the streets before, unsurprisingly. After all, I live in two of the largest gay cities in the world. Sexual assult by homosexual men is not unheard of.

But I am alright with gay people, just not with random sexual harassment from men. (Women who wish to do so are perfectly welcomed to :P) There is a broad distinction between homosexuality and sexual harassment, and we should not to blur those two issues together, and stigmatise them just because of their sexual orientation.
Saturday, September 08, 2007

Installing Internet Explorer on Linux

You've heard me right. I'm talking about installing Microsoft's Internet Explorer on Linux.

There is a pragmatic reason for this. Because of the incompatibilities and quirks that emerged between web browsers from the 'Browser Wars', the same HTML generated may be rendered in different ways among browsers, which is why it is still important to check across different browsers.

One thing to note is that Windows' native PE executable format will not work natively on Linux, so it is necessary to install 'wine', a software compatibility layer in order for you to run Windows applications within a Linux environment.

Rather than fumbling around trying to install Internet Explorer manually via wine, there is a better way to do it. ie4linux is a prepackaged installer that will automatically do for you. From my personal experience, I have found it to be a really great and hassle free way to install Internet Explorer automatically.

(A screenshot of my blog rendered with IE)

Unless it's wine that's causing a problem, people using IE really should consider switching, given that IE's text rendering looks abysmal. The font display doesn't seem to be anti-aliased and the jagged edges are pretty visible.

It also looks like I'll have to generate better IE-friendly CSS as well, given that it doesn't look exactly the way I wanted it to. (The menus are a little off to the right.) Besides that, I can't be sure if the lack of transparency for my icons are there because of wine or an issue with my CSS code, which is a little troubling.

I do recommend ie4linux to those who are concerned with browser cross compatibility, especially when you are not using the Windows platform. If you're reading this from Internet Explorer, do leave me a note if my icon's transparency is incorrect, so that I can try to see if I can do something about it.
Friday, September 07, 2007

The Dangers of Auto-boxing in Java

This is one of the those subtle bugs that I have unwittingly coded in because of the inherent laziness that is afforded by Autoboxing, a feature that was available with Java 1.5 onwards.

What auto-boxing means, is that Java will perform conversion between primitives to its Object equivalents and vice-versa for you automatically, rather than via the new() constructor way that you do traditionally.

However, because of the inherent non-obvious assumptions made, it can lead to subtle bugs that can be hard to spot. It did for me, especially when it was enmeshed in a part of a long stretch of code.

To give an illustrative example of the bug:

import java.util.*;
public class Test {
static HashMap<Integer,String> hm = new HashMap<Integer, String>();

public static void main(String args[]) {
byte b = 1;
hm.put(1, "Hello World");
String s = hm.get(b);
System.out.println("The result is: " + s);

As said, this example will only compilable with 1.5 and above, so take note if you want to compile it. Java will 'intelligently' determine the type of the primitive variable and turn them into objects for you, making it easier to use primitives with utility libraries such as java.util.HashMap. But if you run it, you're going to find that it is printing 'null' rather than 'Hello World'.

Caught the bug yet?

If you haven't, let me show you what Java has implicitly converted the code into through Autoboxing:

public void main(String args[]) {
byte b = 1;
hm.put(new Integer(1), "Hello World");
String s = hm.get(new Byte(1));
System.out.println("The result is: " + s);

I've shown the offending lines in blue. As you should know, Java objects of the same value but of different types are fundamentally not equal, i.e. Integer(1) != Byte(1). That is the sole culprit of the problem, which is being masked by using Auto-boxing.

That is a good reminder to look out and be careful of pitfalls like this, one which costed me 2 hours to find. Next time I'll think twice and look triply hard before relying on Autoboxing to do the right thing again!
Wednesday, September 05, 2007

The Story Behind My Ragged Schoolbag

This my personal story about a ragged little schoolbag I had with me for the last 18 years. Some of my friends may have seen me carrying it around from time to time, but probably didn't know that I had it so long, even less are those who knew the story behind it.

The bag was stolen merchandise, one of the things that mother had not paid for. That happened a long time ago, about when she was divorced. In those days, she had little education and no skills to provide for my brother and I. My father was a serial womanizer who had lost all his money and declared himself a bankrupt a few years before. That had exonerated him from all his responsibilities, to which he had not paid even a single cent of alimony till this day.

I can still recall vividly the day mum got caught stealing from a supermarket. I was only a child of 8 or 9 years then, as I remembered this woman walking up to mum and grabbed her by the arm. She didn't say much, merely uttering a single phrase, "You're coming with me", before towing her towards the to back of the supermarket.

The lady, a store detective, looked pretty stern, even though she did not look at me throughout the entire time. I had no idea what was going on and didn't understand why mum had not resisted, only seeing a defeated look on her face. That scared me and I began to cry, which had probably blown the detective's cover, given that everybody was staring at me while I sobbed, trailing behind them as they headed to the store office.

That was the first time that I realised that mum had stolen in order provide for us. All those Transformers, Mask, He-Man and Lego toys that I had, were stolen just to not make us feel deprived, all that, for her little boys who had meant a world to her. I felt guilty, even at that tender age, to learn that I was the reason for her crime.

I had not stop wailing even within the store office. There were a few people there, one of which was the manager who was sympathetic, seeing that she was a hapless mother with a child. They decided to let us go, but warned her not to do it again. They could have called in the police, which would have meant sending her to jail, and my brother and I, either into state custody, or of my father's, neither of which would have been a pleasant outcome.

The bag was probably the very last thing she had stolen from that period of her life. I do not remember if I had ever mentioned about not wanting her to steal anymore, but I had since consciously never asked her for anything frivolous, for the fear that she would have to resort to pilfering once again.

That is why I have kept this schoolbag with me, as a reminder to work hard, be frugal and be sensible with life so that we'll never have to be destitute again. Some people have mistakenly believed that I am a bloody cheapskate before, for not even bearing to replace an old tattered bag, a claim I readily admit, for I can never be sure how much it will cost to buy the lesson that came along with it.

If they only knew.
Tuesday, September 04, 2007

Using 'moto4lin' for interfacing Motorola phones with Linux

I've got a new digital camera! Well kind of, the camera being my Razr phone that I had with me for almost a year now. I've really not used the phone much, granted that I have never been a mobile phone fanatic, besides the reason that I find Motorola's phones lacking in usability compared to a Nokia. Not getting a new phone wasn't an option, given that my old Nokia 8210 did not have support for multi-band frequency, which makes it a problem because of the different frequencies used by the GSM networks in the US.

(Picture taken of the Bay Bridge with the Razr v3i)

While I've only been using my phone predominantly for calls, it was only a while ago that it struck me that I can use the phone-camera to snap pictures and upload them online, provided that I can get to work with my computer. Good news is, there are software available on Linux that allows you to do just that.

('make menuconfig' screenshot for Linux's CDC ACM kernel module)

'moto4lin' is one of them, which allows you to connect to Motorola phones directly from Linux. Before it is able to work, you'll need to have your kernel compiled with 'USB Modem (CDC ACM)' support enabled. It is keyword masked in Gentoo, so you may need to unmask it if you want to use 'emerge' to compile it for you, by adding this line into /etc/portage/package.keywords:
app-mobilephone/moto4lin ~x86
Because of the proprietary nature of phone OSes, it can be hard to figure out what to do in order to make your phone work, so I'll be explicit about mine:
Motorola Razr V3i
Boot Loader 0A.30.
SW Version: R47A_G_08.D8.35R
Initially, I've spent quite a bit of time trying to figure out why my phone doesn't work, and after reading about other people's failures, and quirks, I was almost giving up, until I read the output from the 'dmesg' command:
sd 0:0:0:0: SCSI error: return code = 0x08000002
sda: Current: sense key=0x3
ASC=0x0 ASCQ=0x0
end_request: I/O error, dev sda, sector 101
printk: 246 messages suppressed.
Buffer I/O error on device sda1, logical block 0
It seems like Linux is treating my phone as a USB memory device, and it wasn't able to determine what filesystem it was. That had led me to try to mount the phone as a filesystem, which didn't work.

Finally, I resorted to tinkering on the phone itself to see if there is any settings to stop making the phone act as if it is a memory card. The closest thing I found was the menu item 'Settings->Connectivity->Usb Settings' where the configuration was set as 'Memory Card'. I decided to change it to 'Data/Fax' for testing, even though I wasn't confident it'll work.
usb 4-1: USB disconnect, address 3
usb 4-1: new full speed USB device using uhci_hcd and address 4
usb 4-1: configuration #1 chosen from 2 choices
cdc_acm 4-1:1.0: ttyACM0: USB ACM device
usbcore: registered new driver cdc_acm
drivers/usb/class/cdc-acm.c: v0.25:USB Abstract Control Model driver for USB modems and ISDN adapters
From the output from 'dmesg' again, it indicates that something is different. After which re-running moto4lin works now! After trying a few downloads of the pictures I've taken, I must say that I'm surprised that phone cameras these days have a pretty modest picture fidelity, although the colour depth of the pictures isn't too great. Still, it is nice to be able to pull something out of the pocket to take a snap whenever something interesting happens!
Monday, September 03, 2007

Vim Remade: Working on Java with all of Netbeans' features

The title sounds like a bold claim, given that the comparison sounds like one between apples and oranges. While vim will probably never incorporate some features that Netbeans as an IDE has, fundementally, both are text editors, and do share some commonalities that we can contrast and compare with.

I started using Netbeans because I needed a good RAD tool for building Swing GUIs. Matisse, the graphical GUI builder built-in with Netbeans, came to me as an impressive tool that allows for an easy and intuitive way of building graphical frontends.

It wasn't just Matisse that impressed me. Netbeans had bucketloads of other editing features that weren't available with vim, which left me feeling less satisfied than I originally was. But even as I toyed with the idea of dumping vim for Netbeans, trying to unlearn my keystrokes, getting used to context switches from fidgeting with menus and alternating between the mouse and keyboard again just wasn't worth the trouble.

That had been my primary reason for writing the various Java Tips for Vim, which I hope becomes useful to other Java developers who code primarily in vim. To do a rehash on my current list of tips:

Intellisense (or Syntax Completion)

The first and foremost feature that I'd really liked in Netbeans is 'intellisense', or the auto-completion of syntax. It makes coding much a less tedious effort, saving up time and the trouble of having to constantly look up API calls via Javadoc.

Tabbing for Syntax Completion
As nice as it is, Netbeans' auto completion sometimes does not work as intended, either suggesting wrong stuff, or nothing at all. But what irks me most is that auto-suggestion can be intrusive and uncalled for at times.

However the existing keystroke sequences <C-X><C-U> for syntax completion in vim can be a bother sometimes, and easier way is to map the <tab> key to contextually determine whether you want syntax suggestion, or a tab itself.


Related to automatic syntax completion, is the ability to complete brackets, braces and curly braces, etc. While I haven't completely figured out the way to foolproof auto-bracketing quotes and other quirks with my solution, this solution will probably be one of those 'keep in view' hacks that I'll try to improve in the future.

API Lookup using ctags
Netbeans has a preview window that pops up relevant API information for Java, something that is lacking in vim. The closest alternative I know, is achieved by using ctags to look up API calls, saving a bit of a hassle by directing you to the right source file automatically.

Automatic compilation via Ant
Allows you to do a compilation with just the :make command. Of course you can bind it to the <F5> key and that would make it feel just as the same as an IDE.

Code Folding
Reduces visual clutter from your code, by folding them up according to methods, or other large blocks of code that makes semantic sense to you.

After these adjustments I've made, it is really starting to feel that vim is now customized sufficiently to have roughly the same amount of usability as Netbeans for Java specific development, so it will probably be while later before I revisit these issues again. Hopefully the tips will be as useful for you as I've found it!