Latest Publications

How can Android Succeed?

The Nexus One is an Android phone that has max-ed out whatever hardware capabilities available out there to become the “super” phone. The problem now lies with the software side, where various manufacturers like HTC and Motorola can start competing to differentiate themselves. Since the hardware is already awesome, what else is there but the flaws of the software that is keeping a lot of people from moving to Android, or in particular the Nexus One. Here are some points why the Nexus One is a phone you might consider.

  1. Best hardware specifications you can currently get in the market.
  2. Multi-tasking.
  3. Great graphics capabilities and acceleration.
  4. Open platform for customizing and hacking.

I had an interesting discussion with DK over the weekend whether if he will switch over to the Android platform now that Nexus One is out. Being a current user of the iPhone 3G and many other phones, his answer was more along the lines of “But…”. I thought some of his points were valid and it is something that Google needs to address quickly.

  1. More efforts to grow the Android Market.
  2. Efforts to make paid apps available to more places (specifically Singapore).
  3. Integrate RFID or some other niche technology (temperature?) into the phone.
  4. A “killer” app available on Android phones.

I think the above points to just one single problem – Software. Android is one of the most promising mobile OS out there and it needs more developers on it. The hardware pretty much blows the competition away. Oh, and one more thing. If Android can also get the normal phone functionalities (e.g. actually able to call, put on hold, conference call, etc.) working properly like our good old Symbian phones, I say there’s really no point to continue sasying that Android is a platform with “potential”, but living up to its name as a platform that is running “the superphone”.

Nexus One 3G Setup for Singapore

For those who bought the Nexus One and have some 3G problems, here are the steps to set up your connections.

For SingTel customers, the Nexus One should auto-connect to their 3G network.  For Starhub and M1 customers, they will need to enter in their APN settings to connect to their 3G network.  This can be done by any user in less than a minute:

  1. Go to Settings > Wireless & Networks > Mobile Networks > Access Point Names.
  2. Hit Menu button, create new APN.
  3. Enter new APN settings.  See below for the details.
  4. Hit Menu button, save settings.
  5. Select the new APN name, then hit the home button.  Your 3G connection will shortly appear in the top bar.

Since I’m a StarHub customer, here are the more detailed settings I got from StarHub.

For StarHub customers:

Name: StarHub GPRS (or anything you want)
APN: shwap (or shwapint)
Proxy: 10.12.1.2
Port: 8080
Username: [Leave it blank]
Password: [Leave it blank]
Server: [Leave it blank]
MMSC: [Leave it blank]
MMS proxy: [Leave it blank]
MMS port: [Leave it blank]
MMC: 525
MNC: 05
APN type: [Leave it blank] (or default)

For StarHub MMS configurations:

Name: StarHub MMS
APN: shmms
Proxy: [Leave it blank]
Port: [Leave it blank]
Username: [Leave it blank]
Password: [Leave it blank]
Server: [Leave it blank]
MMSC: http://mms.starhubgee.com.sg:8002/
MMS proxy: 10.12.1.80
MMS port: 9201
MMC: 525
MNC: 05
APN type: MMS

For M1 customers:

Name: M1 Internet
APN: sunsurf
Username: 65
Password: user123

And in case it is not working for SingTel customers:

Name: SingTel Internet
APN: internet
Username: 65IDEAS (or blank)
Password: IDEAS (or blank)

I hope that helps people having problems with their 3G on their Nexus One.

Compiling Android Source on Mac OS X 10.6 Snow Leopard

After various attempts, I’ve finally figured out how to compile the android source code on Mac OS X 10.6 Snow Leopard. It works on both 64-bit and 32-bit kernels. Here are the steps.

1. Install XCode, Macports, repo, etc.

I assume everyone knows how to do this. Follow the instructions from the Android source page. Just remember to create a new partition that is a case-sensitive partition if you’re using a non case-sensitive primary partition. I’ll start off after you’ve gotten the source from git.

2. Get the following patches.

Notice that I didn’t use “repo download” to get those patches. I realized that repo sometimes “undo” the patches when you download another patch. All bash commands start at the root of your Android source directory.

Patch 12074 - Change Ic4caeff0: Enable building on java 1.6 without conflicts.

This patch will allow you to use Java 1.6 that comes with Snow Leopard instead of Java 1.5.

cd build
git pull git://android.git.kernel.org/platform/build refs/changes/74/12074/3

Patch 11845 – Change I155a531a: Add x86-64 checking for Darwin

This patch will add x86-64 checking for Darwin.

cd system/core
git pull git://android.git.kernel.org/platform/system/core refs/changes/45/11845/3

Patch 11846 – Change Id241a12d: Force gcc-4.0 for qemu build on Mac OS X

This patch allows qemu to build.

cd external/qemu
git pull git://android.git.kernel.org/platform/external/qemu refs/changes/46/11846/3

Patch 12597 – Change I0a8c2440: Use intptr_t for args expecting pointers

This patch allows libacc to compile.

cd system/core
git pull git://android.git.kernel.org/platform/system/core refs/changes/97/12597/1

3. Build and watch it fly.

make

I haven’t quite tested the image files and binaries but it seems to me like it works pretty well. Now to get my hands dirty and start messing around with the actual code.

Oh and remember, every time you do a repo sync, you might have to reapply some of the patches. I’m not too sure why. If there’s anyone who understands git well enough, please explain.

Code You Should Not Be Writing – Part 6

I want to bring in the new year with this code that doesn’t seem all very harmful, but could be written in a more elegant way. I just hope this will educate people on some of the new functional additions to C#.

public List<int> GetListOfIntegers()
{
    List<int> list = new List<int>();
    for(int i = 0; i < 24; i++)
    {
        list.Add(i);
    }
    return list;
}

At its very core essence, this is simply creating a list of numbers from 0 to 23. However, try to find out the various possibilities of mistakes one can make with this code. I’ll leave it as an exercise of the reader to figure out all the possibilities of mistakes in this code. (side note: In fact, there was an error made in the original code. Yes, it looks simple, yet error-prone.)

Here’s a simpler and elegant way to do something like the above.

public List<int> GetListOfIntegers()
{
    Enumerable.Range(0, 24).ToList();
}

One of the interesting things with Enumerable.Range is it returns an IEnumerable. This effectively generates the numbers lazily. However in this example, in order not to change the signature of the method, ToList() is called to generate the numbers instantly, instead of lazily.

With ranges, you can create various interesting sets of numbers with Linq in a more functional way. I hope this week’s “Code You Should Not Be Writing” helps someone out there.

Change your Windows 7 ISO to any Edition

If you don’t already know, all editions of Windows 7 discs ships with the same content. The only difference is determined by a configuration file which decides which edition your Windows 7 disc or ISO is. Knowing that, there is a tool out there to change your edition to any edition, or make it a universal ISO.

The Windows 7 ISO Image Edition Switcher is a set of small binary patches (and a tool to apply these patches) that will convert an official Windows 7 ISO disc image into an official Windows 7 ISO disc image of another edition.

The ei.cfg Removal Utility is a simple tool that will remove the ei.cfg from any Windows 7 ISO disc image, thereby converting the image into a “universal disc” that will prompt the user to select an edition during setup.

For those system admins, this will be great for you. For those who tend to lose their disc or ISOs, you can now grab a friend’s copy and change the disc to the edition you want. But remember, this does not mean your CD key will work for any edition.

Source: win7utils – Windows 7 ISO Disc Image Utilities

Diagramming and Collaboration Online Tool

When I saw this tool, I thought to myself, “This is what Visio is like on the web, except better.” Cacoo is a an online diagramming tool much like what Visio offers to you, except it has better looking stencils. With the added benefit of being online, it allows you to collaborate between multiple people in real time!

Not only can it just draw simple diagrams like flowcharts, network diagrams, office layout diagrams, UML diagrams, but what I like is the freehand wireframe stencils! Check out my horrible looking UI I drew from the stencils in just a few minutes.

Test Freehand Diagram

Awesome isn’t it? Or maybe something more advanced.

Watch their video tour below.

Cacoo – Real-time Collaborative Diagramming & Design from Nulab Inc. on Vimeo.

What’s more, basic features are free! Try it out now at Cacoo.com.

Happy New Year 2010

Well it is the new year and a lot of things have happened to me in the past 1 year. Looking back at what I’ve done, I think it is wise to say there were good and bad times. Looking forward to 2010, there are a few things I do want to achieve. Here are my resolutions.

  1. Help build up the Microsoft developer community.
  2. Grow and inculcate the spirit of HackerspaceSG.
  3. Create dialogues and win-win situations between groups of people.
  4. Study and learn new things.
  5. Lose weight… LOTS OF IT.

That’s it. Yes, I’m a boring person.

So what is your new year resolution?

Code You Should Not Be Writing – Part 5

This is my last post of the year, and I hope to make it special by giving you a piece of code that just amazes me. Staying within the whole “new year” feel, this code is for validating a date.

string strMessage = string.Empty;
int index = 0;
bool IsInputValid = true;

string strDate = TextBox_Date.Text; // TextBox_Date is just a textbox to get the date from.
DateTime date;
if (strDate.Length == 10)
{
    int year = Int32.Parse(strDate.Substring(6, 4));
    if ((year > 1900) && (year < 3000))
    {
        string strMonth = strDate.Substring(3, 2);
        string strDay = strDate.Substring(0, 2);
        date = Convert.ToDateTime(strMonth + "-" + strDay + "-" + strDate.Substring(6, 4));
    }
    else
    {
        index++;
        strMessage += index + ". Date format(dd/mm/yyyy) is not correct.<br/>";
        IsInputValid = false;
    }
}
else
{
    index++;
    strMessage += index + ". Date format(dd/mm/yyyy) is not correct.<br/>";
    IsInputValid = false;
}

Remember the code you saw in Part 2 about the try-catch, using exceptions to do your data validation? Yes, that code surrounds this code. Imagine the double whammy I got when I saw this code, and the satisfaction of deleting it all.

I don’t know if you realise this, but do you have to take time to actually try to figure out what this developer is trying to do? As in understanding the code? How long do you take to figure out this code and what it is doing, and how flawed it is?

I hope you enjoy this edition of Code You Should Not Be Writing. Till next year, I have more to share! :)

C9 Lectures: Functional Programming Fundamentals

Finally, all 13 chapters are done. Now I can compile them into 1 big post with all the videos. I highly recommend every developer to watch these videos even though you’ll not be writing Functional code.

Edit: I totally forgot to link back all the chapters. Click on the links on each chapter for the original page and details to download the videos.

Chapter 1

Get Microsoft Silverlight

Chapter 2

Get Microsoft Silverlight

Chapter 3

Get Microsoft Silverlight

Chapter 4

Get Microsoft Silverlight

Chapter 5

Get Microsoft Silverlight

Chapter 6

Get Microsoft Silverlight

Chapter 7

Get Microsoft Silverlight

Chapter 8

Get Microsoft Silverlight

Chapter 9

Get Microsoft Silverlight

Chapter 10

Get Microsoft Silverlight

Chapter 11

Get Microsoft Silverlight

Chapter 12

Get Microsoft Silverlight

Chapter 13

Get Microsoft Silverlight

Creating Beautiful Code with Functional Languages

I encourage everyone who is still sitting on the fence about whether to learn a functional language to read this Beautiful Code – The Manifesto article written by Lau B. Jensen.

To summarize, his point of writing beautiful code essentially avoids a lot of the pitfalls you get from Imperative languages.

Beautiful Code is…

  • Concise – Free from both obvious and hidden ceremony
  • Expressive – Compartmental in its architecture, showing intent
  • Safe – Being explicit about state and time, defaulting to immutability

Of course, functional languages do all that. Therefore, functional languages create beautiful code. Trust me, you want to learn a functional language.

Try Haskell for size and read this book Real World Haskell which is a fantastic book to learn Haskell.

Or learn F# for those in the Microsoft space. I highly recommend Chris Smith’s Programming F# book to learn F#.