Ben Wong is a Web/iOS Developer from Brisbane, Australia. When he's working he is usually coding in HTML, CSS, Javascript, ASP.NET (C#/VB.NET) or SQL. When he's not coding he's probably on a basketball court.

Always specify radix parameter for Javascript parseInt

This week I learned how important the radix parameter for the javascript parseInt is. I implemented my own custom date string parser and discovered that older versions of Firefox behaved differently when running the following line.

All the latest version browsers (IE, Chrome, Firefox, Safari) I tested on returned 8, but older versions of Firefox returned 0. My solution to this was to set the radix to 10.

Mozilla Developer Network’s Javascript parseInt page recommends always specifying the radix parameter to guarantee predictable behaviour.

How to use ASP.NET FileUpload’s PostedFile.InputStream

This week I started working on a new file uploader for the company website admin. The current version uses the HttpPostedFile SaveAs method to save the file to a temporary directory before uploading to the web server using FTP. I decided to make the new version use HttpPostedFile’s InputStream property to transfer the file in one go instead.

Seemed straightforward enough, but I hit a snag.

My first attempt at the code to upload the file looked something like this:

It seemed to work, but it turned out while the image file I was uploading ended up being the right size, the image was corrupted.

After reading a bunch of MSDN articles, forum posts, blog posts and StackOverflow answers, I discovered that the seek position needed to be reset before reading the stream.

So the code needed to be like this:


Useful .NET libraries for console applications

In the past couple of weeks at work I’ve being rewriting a .NET console application that imports data and runs as a schedule task on a server. I’ve had to work on few of these sort of apps as a web developer, so I thought I’d share my knowledge.

These type of applications aren’t particularly exciting to work on for a bunch of reasons. But they’re almost always very critical and are required to run correctly and reliably. Luckily there are some useful libraries that ease the burden.

Here are some that I’ve used in the past couple of weeks.

nLog –

Logging is very important for applications that are run as scheduled tasks because when it fails you need some way of determining why. nLog is very simple to use and rich with features. I’ve set it up to trigger an email on fail and also configured log file archiving.

FileHelpers –

FileHelpers is a brilliant library that simplifies the job of parsing import files. It takes some time to understand how to use initially, but it’s still much less time than writing the parsing code yourself.

DotNetZip –

Sometimes import files will need to be unzipped. DotNetZip seemed like the simplest .NET zip library to use of the bunch. It worked and didn’t require many lines of code to use – can’t beat that.

ndesk.options –

The data importer I was working on required some command line arguments to trigger the various different ways I needed to run it – type of import and different time spans. That’s where a command line argument parser like desk.options comes in handy. The way it works seems a little quirky, but it does the job.

How to remove duplicate Open With menu items in Finder

I often find that the Open With context menu in Finder has duplicate entries for some applications. The most reliable way I’ve found of fixing it is running the following command in Terminal and relaunching Finder ( > Force Quit… then select Finder and click Relaunch button).


Spring Cleaning for iPhone 5 – Organising Apps

iPhone 5′s new 4″ Retina Display has different dimensions and resolution from the displays on its predecessors, which means it’s time to look for new wallpapers and rethink how to arrange all my apps.

You can read about my thoughts on wallpapers here.

For this post, I’m going to explain how I organise apps on iPhone 5. It’s going to be very subjective., and there are probably better ways of doing it. But here goes.

Organising Apps

If you enjoy using your iPhone as much as I do, you most likely have a huge collection of apps on your phone. When your app collection gets to the point where it spans multiple home screens, it’s time to put a little thought into where you place each app. Needing to use the search to find an app or use Siri to launch, that’s a definite hint.

The Basics

There are main three areas you can place an app:

  1. in the dock
  2. on the first page of the home screen
  3. on subsequent pages of the home screen

Where you place an app should depend on how frequently you use it and quickly you need to find it.

The dock is the prime location for an app. It’s visible across all home screens. You will see it as soon as you press the home button to exit an app. The dock is limited to four apps or folders.

The first page of the home screen is the second best location. You can jump to it by pressing the home button when you’re on any other home screen or the search screen. A page of the home screen is limited to twenty apps or folders on iPhone 5, and sixteen on older iPhones.

Apps on each subsequent home screen page after the first is a swipe more difficult to get to than an app on the previous page. The likely usage rate of the app decreases as the page number increases. By the last page, most of the apps will be ones you consider deleting from your phone.

Finding apps on subsequent pages will also be more difficult because you don’t see them as often. That is why apps on these pages will require some additional logic to determine where they are positioned. For me, I group apps by their purpose – for example, camera apps and photo editing apps are grouped together.


I decided to have a separate section for folders because I’m a bit apprehensive about using them. They are sort of a hack to allow the user to fit more apps into an area. But because they shrink or hide icons of apps they contain, and add an additional tap to open and launch a contained app – they come with a heavy penalty to usability. For that reason, I don’t use folders in the dock and on the first page of the home screen.

Positioning of Apps on Pages

For apps in the dock and on the first page of the home screen, you should position the most important apps in the easiest position for your thumb to reach when you hold the phone one-handed. For me on iPhone 5, the best positions on the dock are the two middle ones, and as I hold the phone in my left hand, the best positions on the home screen are the left most position on the third row and the second from left position on the fourth row.

For subsequent home screen pages, I focus more on findability than accessibility and I try to group my apps into rows and lay out the apps from left to right with the most important row in the middle.


Here’s are my guidelines for organising apps:

  1. If you absolutely have to be able to find and launch an app quickly, you should place it on the dock.
  2. If you frequently use an app and would like to launch it quickly, place it on the dock or on the first home screen.
  3. Apps that aren’t on the dock or first home screen, should be grouped with similar or related apps so they can be found easily.
  4. Don’t use folders on the dock or the first page of the home screen.
  5. Position apps on the screen so that the most important apps are most comfortable to reach when using one-handed.

These are not set in stone and they may not suit everyone. But at least they show my thought process and help you work out your own way of organising apps.