miobox

Had a first experience with a 2Wire mio box last Saturday, when I was helping my niece set up her broadband connection. The box is essentially an ADSL router-modem with VoIP features built in.

Similar to a typical ADSL setup, you hook up the power, microfilter, phone line and ethernet cable, and your PC should pick up a DHCP address. Launch the gateway IP into the browser and you’ll get into the setup screen. From there you can get to a familiar page with PPPoE configuration.

One good thing about its default setup is the wireless enabled by default, with WEP. The default WEP key is printed on the box itself.

OSGi

http://www.javaworld.com/javaworld/jw-03-2008/jw-03-osgi1.html

Wonderful tutorial about OSGi. Solves a few mysteries (to me) about Eclipse plug-ins.

In summary,

  • OSGi is a Java-based architecture for developing/deploying modular components. Such components should be able to be deployed without restarting the container.
  • These components are known as “bundles”.
  • Eclipse plug-ins are based on OSGi bundles, so every plug-in is a bundle. Eclipse uses Equinox, which is the reference implementation of the OSGi Service Platform version 4.
  • A bundle needs to have an “Activator”, which implements start/stop methods to handle the bundle life cycle. A bundle also needs to have a manifest, which describes the bundle and points to the Activator.
  • OSGi also helps to manage dependencies through package visibility. Bundles specify which packages to export, so implementation packages can be hidden from bundle clients.

Defraggler

From the same people who brought CCleaner, here’s Defraggler. I’ve not tried it personally yet, but I need to get it down here before I lose it again. (I often lose links, so its one of the purposes of this site.)

It’s free, compact, and it allows single file defrag. Sometimes its just that one big file that you load often, and you want it fast. So this is a program I’ve dreamed of.

StringBuffer obsession

For those of you who are obsessed with reusing StringBuffers, take a look at this. They’re good for adding strings up, but once you’re done, throw it away and get a new one. There’s no need to clear it and use it again.

Like what I say, too much of anything is no good.

btw this was talking about JDK1.4 in 2003. It’s probably worth a re-investigation 5 years from then, in JDK6 (or 7).

Utility calls

Java is very verbose. Therefore many people have come up with calls to do very common things. For example:

java.util.Arrays.toString(array);
java.util.Arrays.deepToString(nestedArray);

This prints the contents of the array, instead of a cryptic string. This method is available since 1.5.

Another good one is:

org.apache.commons.io.IOUtils.closeQuietly(stream);

Usually used in a finally clause, this one closes streams or readers, ignore IOExceptions, and handles null. This is available in the Apache commons-io library.

ZSNES

Once again, Ubuntu amazed me with zsnes (Super Nintendo Emulator) in its package repository.

There was no sound initially, until I tried “zsnes -ad sdl“. Then I got sound. But terrible and crackling. Next I tried installing alsa-oss. Didn’t work, until I invoke it with “aoss zsnes”. Good sound! And it works subsequently from the “Start Menu”. Yey!

Now the problem is my gamepad is semi-working… It works fully in Windoze, but here it only recognizes the buttons but not the directional pad. Why? I followed some tips to install joystick and jscalibrator, but it didn’t work. Until I tried this site, to chmod 666 the device, and it worked! So now I’m not sure if its just the chmod, coz I uninstalled joystick and jscalibrator and it still works. (I did not uninstall the prerequisites of joystick and jscalibrator though). So if you have the same problem you may want to try the chmod first, to find out if joystick/jscalibrator was needed.

One more thing to note: Windoze stores game states in the same folder as the ROM, while in Ubuntu, the game states are in ~/.zsnes . Took me quite a while there.

VirtualBox vs VMWare

Although I run Ubuntu, I seriously need Windows simulation for some reasons, such as running my company VPN client. So I’ve been looking at VMWare which I used to run Windows as guest on a Windows box. I’m resisting to building software myself, as I’m trying to use Ubuntu as a Windows user — and Windows people don’t build software (as in compile themselves). So I had problems with VMWare. I looked at WINE briefly, but I didn’t install it as I was not convinced that its model would allow me to run my VPN client on Ubuntu. I checked out alternative VPN solutions (vpnc) but it didn’t work out.

Today I found a preferable alternative: VirtualBox. Its free, open source, and light. I attempted to install it from Synaptic, but I couldn’t start the VM due to this error: “kernel driver not installed” and prompted me to install virtualbox-ose-modules-generic. I tried to do that but it wouldn’t allow me, saying its dependency was not fulfilled.

By luck I went to check my kernel version with “uname -r” and found that my kernel is “2.6.24-19-generic”, and Synaptic was trying to install “2.6.24-20-generic”, as the default module installs the latest, which is 20. I manually selected and install the “virtualbox-ose-modules-2.6.24-19-generic”, and it worked!

(Note: some additional steps I took were to add myself to the vboxusers group and relogin before start VirtualBox, and to mount the CD after starting up the VM. I write this in case the next time I reinstall my OS I forgot what I did)

So while I’m waiting for XP to install I’m noting all these down. At the minimum I know I will have XP running as guest on my Ubuntu.

getdeb

My aMSN wouldn’t login today. Went to aMSN forums, and read that MSN has changed its server protocol, and they had released patches in 0.97.2 to address that.

My aMSN was installed using Synaptic, but when I tried to update it, it says I already have the newest built version 0.97. I understood that they could not release the new version just as fast as the source, and they need someone to build and test it, before they can announce it available on the “official” repository.

Fortunately I found a site which bridges that gap. It sacrifices possible quality issues for a faster release (so that I don’t have to build the updates from source). http://www.getdeb.net/ produces Ubuntu builds for new applications that has not been released in the official repository yet. Best of all, it is released as debs which integrates into the package manager beautifully. The almost one-click process takes me through removing the older aMSN, replaces it with the new one, and retains my settings (my email id on the login screen and chat history were intact and accessible). Of course, I was able to log in peacefully after the upgrade.

+1 for Ubuntu.

Refactoring

I’ve been refactoring some code, and just have some thoughts on common things I’m fixing.

  1. Do the same thing at the same place. If the same snippet of code appears more than twice, e.g. checks if the user is logged in and redirects the user to the login page, it should be extracted. The fewer the control points, the easier it is to debug or change its implementation. IDEs will also allow you to easily trace who is using this functionality, which may help you access the risk of change. “More than twice” is a general guideline. You might see the potential of extraction even if the code only appears once or twice. Sometimes its not suitable for extraction even if it appears more than twice.
  2. Reduce condition nesting by quickly eliminating alternative flows. Leave the rest of the method for the happy/main flow. e.g. If you detect the user is not logged in, call the redirect and return. Using the return avoids needing an “else” after the if. Adding a comment here helps to understand the alternative condition (see point 5).
  3. Learn the lazy loading pattern. Helps reduce nesting as well if you understand how to apply ifs.
  4. Coherence and Coupling. Standard OOAD.
  5. Comments. Not easy to see good commented code. School only tell us to write comments. Who teaches how to write good comments at appropriate places? There’s no need to comment every line. Nor is it good to be comment-less.

Hardy

I have finally taken the effort to upgrade my Dapper 6.06 LTS to Hardy 8.04 LTS. I’ve been waiting for Hardy for quite some time, mainly because its an LTS and it’ll be more popular and supported. The experience is pretty good so far, I’m actually evaluating it from the perspective of a Windows user, so its about bringing the Windows pattern to Ubuntu and running the corresponding software here. The steps to get stuff set up will be documented in “The Ubuntu Experience“.

The improvements from Dapper was tremendous, in particular novice usability and software support. In Dapper I often had to get down to the terminal to hack stuff and get things working, but stuff in Hardy just works. Out of the box that is. For example, these were quite important to me:

  • Wireless adapter support
  • WPA (saw but not verified)
  • Bluetooth enabled by default
  • SCIM (although no Chinese input by default)
  • NTFS read/write

Installation was a breeze, no more fumbling with custom partitions, the LiveCD installer takes care of it for me. Also since all the software was available through Synaptic, so far it all works pretty stably. I’ve added in aMSN, SCIM Chinese, Compiz, JRE, and desktop customizations. Next to explore will be CD/DVD writing, media player, start button and VMWare.

In Dapper all those were quite painful, and I didn’t manage to get VMWare working. Also because of Compiz I could not shut down normally, and had to use a script every time. VMWare would still be critical this time, for my VPN client and alternatives when the software or website only supports Windows.