Exception Handling - Promises vs Observables

A friend of mine was studying Promises in JavaScript. I mentioned how Promises swallow exceptions and continue execution by default.

I have recently been following RxJS and decided to knock up an example to find out how exceptions are handled differently in Promises versus Observables.

In the JS Bin below you will find the Promise swallows the exception thrown and we continue onto the Observable.

Read More

Babel transpile ignoring native Javascript

I was thinking today that we want Babel to ignore transpiling native JavaScript available in Node.js.

You could whitelist or blacklist what you want Babel to transpile and a few people list options in the comments here.

Babel 6 now does nothing by default, but there doesn't seem to be any Node.js version specific presets mentioned on the Babel page.

Read More

Are Google Dropping the Ball with Android

I've been using Android phones for a while now. Lately however, it has been a pot of boil and trouble. Lollipop issues, Kit Kat issues, Hangouts and Chrome issues spring to mind. It's time to try something else as outlined below.

Nexus 4 Problems

I have a Nexus 4 which was running great on Kit Kat. I made a fairly early move to Lollipop and was hit by early mover issues like many others. Okay, this is somewhat expected with a new release.

Read More

Moving to a MacBook from Windows

Yes, MacBook to PC, or OS X to Windows makes more sense, but whatever you want to call it, I finally caved in and bought a MacBook (well a few weeks ago now).


Well every other developers seems to have one in all the videos I watch, so I decided I better have one too... just kidding. Well, kidding about the reason, but seriously, it is a sea of MacBooks in most online videos I watch.

Read More

npm Set Visual Studio Compiler Version

Node.js or io.js will sometimes require a C++ compiler to build packages for you. On Microsoft Windows you can use Visual Studio. The newer free Visual Studio Community or the older (and also free) Visual Studio Express editions should get you going if you don't have a commercial copy of Visual Studio.

To check the compiler npm is configured to use try:

npm config list

Read More

Visual Studio 2015 RC Hanging on Android SDK install

My Visual Studio 2015 install was still going after about 3+ hours on the Android SDK. It seemed like it had hung.

To figure out what is going on, I looked in the %temp% directory and there is a file called AndroidSDK_SI.log. Opening this log I could see that the install was still happening. The problem was how long it was taking. It sped up significantly after I stopped Star Citizen updating!

The Visual Studio installer could really do with a better feedback mechanism to let you know that something is still actually happening. Some animated dots aren't very convincing after several hours. Even an advanced GUI option to display the output of the currently executing log file in a text box would be useful. The Android SDK log was quite useful as it showed percentage of the download, download speed and estimated times.

Read More

Redirecting Users Based on their Country IP Address

I can't sleep, so it's time for a rant about redirecting users based on their country IP address.

Just because I am in a country, does not mean I want to be shown a site in that countries language! Okay, some of you might be thinking this sounds perfectly reasonable, because most people in country will be able to read that language. Well, I am here to let you know you are wrong ;)

So what is the correct solution to choosing which language to show your website visitors?

Read More

Best Large Archive Format to Extract Files

So sometimes you just want to extract some files from a large archive. It might be a bit late now, but tar.gz is probably not the best archive format for huge archives and removing specific files. It can take a long time to find the file you want and extract it.

Formats like zip (and 7z?) know where the file is located in the archive and can extract it quickly (compared to tar.gz). In the comments of this article some people talk about the length of time tar.gz can take, eg 4 Gig file, 25 minutes.

According to this StackOverflow article, zip, 7z and dar (in non solid mode), can also extract files more quickly from a remote source. They have a list of files and can archive in segments to allow extraction without requiring the whole archive to be unarchived. tar by itself does no compression and harks back to the days of tape drives (tar is short for tape archive) where this is not really important as they use sequential reads.

Read More

WordPress Relative URL - Why use Absolute URLs?

So you want to know why WordPress uses an absolute URL when creating a link within your own WordPress site? When WordPress stores an absolute URL in the database, it makes it harder to create test or development versions of your site. I normally solve this by making the site name point to the server I want (perhaps another article on this). Another alternative is to run some database scripts to change your site name in the database stored URLs.

Some reasons for WordPress absolute URL usage in favor of relative URLs can be found in an answer for this StackOverflow question quoting a WordPress lead core developer.

  • Performance may be better as there is processing involved to construct a WordPress relative URL.

  • the root URL (ie /) can change depending on your setup of WordPress. Changing relative URLs is more error prone.

  • Internally WordPress requires absolute URLs in certain areas and processing this is considered a potential area to introduce programming bugs.

  • Some plugins do not handle relative URLs correctly. SEO Guru Yoast is also quite vocal about relative URLs and issues they have caused himself and also for his clients including:

  • Duplicate Content of your test server

    • an accidental link to a test environment version of your site can lead to duplicate content issues by accidentally indexing your test site.
  • Spider Traps

    • a relative link ./oops instead of ../oops, can cause a recursive link like /page/oops/oops/oops/ etc. Best not to annoy Google ;) Also see our upcoming article about trailing slashes on URLs. https://example.com/test is a different URL to https://example.com/test**/**

Read More