On the bright side…

So I’ve been a bit of a Negative Nancy in my last few blog posts. I think it’s time to lift the mood a little with some good news. The following image:

… Means that I am officially able to enter the US! Huzzah!

Additionally, everything else from my last emo post has since been resolved, so I’m feeling pretty good right about now!

Apple: A hate story

To date, I have owned two iPods: An iPod video (5th Generation), and an iPod Touch (2nd Generation). I am going to start this post with a disclaimer: I like many things about my iPod Touch. It is lightweight, has a good battery life, and does most of what I need from it. Apps are cool too. If given a choice, I would probably buy it again, and when I get another MP3 player, there is a good chance it will be another iPod.

That said, I have some major gripes with iTunes, and to a lesser extent, the iPod. Here they are, in no particular order:
Read the rest of this entry »

Windows Phone 7 Beta tools

In my experimentation with the Windows Phone 7 developer tools, certain things have been a little hard to find information on. Here’s some of the best resources I have found, along with little nuggets of good information I have discovered and want to document.

Resources

Also keep in mind that the Windows Phone 7 SDK is based mainly on Silverlight, so many resources that apply to Silverlight can be readily applied to WP7.

Checking internet connectivity

It’s suggested in several places that Windows Phone 7 developers should test for internet connectivity in their internet-connected applications, as it is not a guaranteed resource (and of course, respond accordingly if no connection is available). However, there are few places that document how to actually do this. In the Beta version of the tools, the correct way is by testing the result of the following function:

// Available in the System.Net.NetworkInformation namespace
bool connected = NetworkInterface.GetIsNetworkAvailable();

Note that this has changed from the CTP version of the tools.

Creating a scrollable region

Another seemingly under-documented feature is how to create a region that scrolls using the typical finger scrolling action. Fortunately, this is as simple as wrapping your controls in a ScrollViewer element:

<ScrollViewer>
    <!-- Insert controls here -->
</ScrollViewer>

This gives you scrolling momentum for free, along with a little position scrollbar that appears as you scroll. Very easy!

MySQL backups causing problems

Lately I’ve been getting the occasional error from my WebFaction instance – alerting me that a running MySQL query had been shut down because it had been running for too long and was slowing the system. Here’s the offending SQL query:

SELECT /*!40001 SQL_NO_CACHE */ * FROM `phpbb_search_wordmatch`

Very mysterious. The offending table is one relating to my phpBB instance. I did not have any further information at hand to work out what was going on, and so my first port of call in attempting to resolve the issue was to adjust my phpBB search settings. However, a few days later, the error occurred again – back to the drawing board.

My next step was to inspect the source code of phpBB. However, I could not find anything that would produce SQL like the above statement.

And then it occurred to me. I started receiving the error messages about the same time as I set up a Cron database backup job. Sure enough, all the errors were coming through at around the same time of day, coinciding with when the backups were scheduled to run. A quick web search confirmed that running mysqldump against very large tables was a typical culprit for long-running SQL statements.

Once I knew the source of the error, the fix was very simple: Because the table in question is just an index table for the purposes of searching posts (i.e. not essential data to backup), it was just a case of adding –ignore-table=db.phpbb_search_wordmatch to the mysqldump command line in my cron job. Now, the search index table is skipped in my backups, resulting in smaller, faster backups, and no more error messages!

I couldn’t find much information about this problem specific to phpBB or Webfaction, so hopefully this helps someone else out!

Dark Visual Studio 2010 theme

Looking for a refreshing change in colour? Getting sick of coding against that glaring white background? Look no further!

I’ve decided to upload my Visual Studio 2010 Fonts and Colors settings for public consumption. The colour scheme is loosely based on the Railscasts TextMate theme. Here’s a couple of screenshots to give an idea of appearance:

(Click to view larger).

To install:

By default, the theme uses Consolas size 12. You can adjust these settings easily by opening menuĀ Tools -> Options and finding the Fonts and Colors section under Environment.

Note that Visual Studio is a prick, and has something in the order of 100 different colours that can be set. I have only set up colours for things that I am commonly doing, such as coding in C#, HTML, or XAML. Every now and then you might come across a colour that looks funny against the dark background. This can of course be modified by hand in the Color settings by tracking down the appropriate item in the colour list.