Author Archive

O2 iPhone SMS Delivery Reports

Apple’s release of the iPhone 3GS finally convinced me to leave my 10+ year long T-Mobile and Nokia loyalty for the unchartered territories of O2. I’ve not been disappointed at all with the jump, but one feature I didn’t realise I’d miss until it was gone was SMS delivery reports. O2 claim on their website;

The ‘delivery report’ function is not supported on our network. If you’d like to receive delivery reports, you can enter *0# followed by your text message and then send the message as you usually would.

Which I must admit is pretty clunky to have to remember each time but it does the job I suppose.

After a bit of digging around I’ve found a list of codes for other networks and countries which I’ve posted after the jump… Read the rest of this entry »

Tags: , , , ,

No Comments


Google Voice!….. Denied!

I was so excited to receive the email inviting me to sign up for Google Voice this afternoon I didn’t read any further than the sign up link, but after logging in was presented with this:
Google Voice... DeniedBah! For those who don’t know what Google Voice is and can’t figure out why I was so excited, check out the full feature list here; single phone number for your texts, mobile and landline calls, answer and make calls from anywhere, voicemail transcription to your google account to list but a few, so hurry up Google!!!

Tags: ,

No Comments


Site5 Web Hosting

Over the past few days I’ve been moving my web hosting to site5. Things seem to be going well so far and fingers crossed the Wordpress transfer of this blog has been relatively painless.

Tags: , ,

No Comments


C#’s Null-Coalescing (??) Operator

Although I’ve always been a big fan of the ternary operator, kudos goes to the Refactoriser (you know who you are!) for pointing me in the direction of an even more effective way of obfsuca^H^H^H tidying up my code; the ?? operator.

The null-coalescing operator (to call it by its more catchy name) allows you to provide an alternative value in the event that the reference type object (or nullable value type) you are trying to access evaluates to null. So instead of having to do something like this:

            int? myNullableInt = null;
            int myInt;

            if (myNullableInt == null)
            {
                myInt = -1;
            }
            else
            {
                myInt = (int)myNullableInt;
            }

You can do this in-line:

myInt = myNullableInt ?? -1;

Apologies for the heavily contrived and quite pointless example, but at least it gets the syntax down and should make it apparent how useful this operator can be when dealing with a mixture of nullable and non-nullable types.

Tags: , , , , , , ,

No Comments


Making a function call on another thread using the C# Dispatcher class

There may be a situation when you need to execute a function on a different thread, such as ensuring that calls across the interface between a multi-threaded dll and its single-threaded user are made on the same, single thread. To achive this, you can use the target thread’s Dispatcher object as follows:

  1. Create a delegate of the function you wish to be able to call:
    public delegate void MyDelegate(int i, string str);
    public class TargetThreadClass
    {
        public TargetThreadClass()
        {
            MyDelegate del = new MyDelegate(this.FuncToExec);
        }
        public void FuncToExec(int i, string str)
        {
           // Do something
       }
    }
  2. Within the target thread, create an instance of a Dispatcher object and set it to the thread’s current dispatcher:
    Dispatcher UserDispatcher = Dispatcher.CurrentDispatcher;

    Then pass this dispatcher, along with the delegate into the source thread.

  3. Then to call FuncToExec on the target thread, use:
    UserDispatcher.Invoke(del, new object[] { 123, "arg string"});

    Where the first parameter of Invoke is the delegate itself and the second an array of the delegate’s parameters (if any), in this example the delegate takes an int and a string.

Tags: , , , ,

2 Comments


Time Machine Error: “The backup volume is read only” on NAS (DNS-323)

I wrote a while back here about how I’d set up my D-Link DNS-323 NAS to allow Time Machine backups from my two macs. All has been going well up to a few days ago when I was greeted with this dialog on my MacBook after an automated backup attempt:

Time Machine Error

Nothing has changed on my DNS-323 config-wise and my Mac Mini’s Time Machine still works fine, using exactly the same network share as my MacBook and the same username and password so I’m more than a little confused by this!

There are literally hundreds of google search results pointing to forum posts discussing this but they all seem to suggest the same thing; after trying the obvious (Use Disk Utility to repair the drive, done… Power off the drive and mac and restart them both, done….) just reformat your drive. I really don’t want to do this so I’m going to keep trying. Will report back my findings, but has anyone out there resolved this issue without a reformat?

Maybe this is the reason Apple turned off support for ‘unsupported’ network volumes afterall? I really hope not.

Tags: , , , , , ,

2 Comments


DoshTracker Update #3 – First beta site live! Design change discussion.

It’s severely limited in functionality, but I’ve replaced the temporary holding page with our first beta. At the moment it’s little more than a layout prototype, but forms the foundation for everything else.

While I was messing about with the google maps integration, I discovered that the original ‘window’ based design (as used on the holding page, see below) was too confusing when displaying multiple windows and relied on the browser being maximised on a reasonable sized screen to be usable.

Original Window-based DoshTracker design

Because of this I’ve moved to a new design which you can now find in its place. The page is split into three panels;

Top Panel: Horizontally along the top. Contains the site logo, and a potential space for site messages and future advertising, this content is fixed to the user regardless of the state of the other dynamic panes.

User Navigation Panel: Vertically on the left hand side. Contains a dynamically generated tree based on the currently logged in user’s data, so will contain entered notes, note hits and profile information. Clicking on the tree nodes will create new tabs in the ‘Main Window’.

Main Window: The remainder of the page contains a tabbed view. Some tabs are fixed and contain general information (Welcome text, instructions, etc..) and some will be dynamically generated by user actions and can be closed. Some typical tabs envisaged are:

  • Welcome screen (fixed) – Welcoming the user to the site, site news.
  • Instructions (fixed) – How to use the site.
  • Statistics (fixed) – General stats on the site, total number of notes, total value, top ten users, notes, tracks, etc.
  • Register / Login (fixed) – To allow a user to register a new profile or login to an existing one.
  • Contact Form (fixed) – To allow a user to send comments and feedback to the site admin.
  • Note Entry (dynamic) – To allow a user to enter a new note into the system, will then display confirmation and previous hits for that note if found.
  • Note View (dynamic) – Displays details (location map, distance traveled, condition comments, etc.) for a selected note.
  • Profile Editor (dynamic) – To allow a user to view and amend their stored user profile information.

The tab panel supports scrolling as it is likely that the number of tabs may exceed the width of the screen.

The colour scheme is also under review, the blue ‘DoshTracker’ colour is ok, but the grey components are in the default extjs theme and so I plan to write up a new stylesheet to make it look more co-ordinated before the site goes fully live.

There are lots of additions to the site which are being developed in parallel so please return regularly, check out the development log on the site and this blog for more updates.

Tags:

2 Comments


DoshTracker Update #2 – Ext JS and Google Maps API Integration

Shea Frederick on the extjs blog has produced a component which extends Panel and integrates with the Google Maps API here allowing you to display google maps anywhere you can use a Panel, that includes windows, viewports and layouts. This is great for the DoshTracker development as I can use this code to form the basis of the mapping displays, saving me a lot of code hacking and fiddling.

The issues I am having at the moment revolve around Google’s geocoding of UK postcode data. For those who don’t know, geocoding is the process of turning an address into longitude and latitude location information which can then be displayed on a map. It can be a bit hit or miss, especially in the UK where the physical area covered by a single postcode can vary widely but prior to Google providing this feature in its API, the only way of achieving this was to buy a horrendously expensive license from the Royal Mail (who own our postcodes, apparently?!?!?) making this an unfeasible option for DoshTracker.

It appears that the results you get back through the API functions are sometimes different to those you’d get typing in the same postcode into maps.google.com, a fact that they confirm in their original press release when they state that “(the) geocoder is not using the same resources as maps.google.com and may not return the same results”,  but hats off to them anyway for providing the feature in the first place. For privacy reasons, I don’t intend on displaying either the full postcode or a map at a sufficient zoom level to work out the precise location of notes entered into the system, so it may be that the accuracy provided by Google will suffice, but I’m designing the system to allow me to use other geocoding services in future.

In order to do this, I’ve separated the geocoding from the actual map display. A lot of code I’ve seen so far calls the geocoding functions when drawing the map in order to set the map center dynamically. This is unnecessary for me as DoshTracker will be using maps to display previously entered locations and so I plan to only geocode the hit’s location when the new note or hit is added to the system and then to store that information in the database. This not only reduces the number of calls to the Google Maps API (reducing the chances of me exceeding their acceptable policies) but also means that I can substitute the geocoding component in the future with only minimal code changes.

I’m just ironing our a few bugs in the display but I’ll be adding a new tab to the DoshTracker homepage over the weekend to allow you guys to test the geocoder. I’ll be logging the geocoded results to a database for use in the eventual system so please feel free to geocode all of your common locations and let me know what you think. I’m particularly interested in feedback on the map zoom level and the accuracy of the results you get.

Update (13/03/2009): The most up to date version of this component is now being hosted here at Google Code.

Tags: , , ,

No Comments


Creating Excel .xls spreadsheets with PHP

A web-based statistics system I’m developing for a client needs the facility to dynamically generate Excel spreadsheets. The system runs on a Linux platform with a typical Apache, MySQL and PHP install and is hosted on a virtual server at a commercial hosting company so access to anything Microsoft or COM-like wasn’t an option and I only had a basic PHP install available. Most web searches come up with solutions that rely on PEAR (such as the Spreadsheet_Excel_Writer module) but my hosts’ PHP didn’t support PEAR and they wouldn’t let me install it.

Finally I came across Johann Hanne’s port of the Perl Spreadsheet::WriteExcel module on his website and it’s working brilliantly without any additional dependencies! Although his documentation is a little thin on the ground, he does provide some example scripts to get you going and as it’s a direct port, you can still refer to the original Perl documentation. In particular the reference pages on cell number format strings here and here were most useful when tweaking the output.

Creating a simple spreadsheet in PHP is as simple as importing the writeexcel classes and setting up a new workbook and worksheet:

require_once "class.writeexcel_workbook.inc.php";
require_once "class.writeexcel_worksheet.inc.php";

$fname = tempnam("/tmp", "simple.xls");
$workbook = &new writeexcel_workbook($fname);
$worksheet = &$workbook->addworksheet();

…then use the write($row, $column, $token) function to put values into cells:

# Write some text
$worksheet->write(0, 0,  "Hi Excel!");
# Write some numbers
$worksheet->write(1, 0,  3);

…and tidy up and return it, in this example through the browser, but you could always copy the file from the /tmp folder to somewhere more permanent and do what you want with it:

$workbook->close();
header("Content-Type: application/x-msexcel; name=\"example.xls\"");
header("Content-Disposition: inline; filename=\"example.xls\"");
$fh=fopen($fname, "rb");
fpassthru($fh);
unlink($fname);

…and there you go, automatically generated Excel spreadsheets through PHP.

Tags: , , , , ,

No Comments


My Big Ben photo in Schmap London Sixth Edition


I’ve just been sent an email by the guys at Schmap to let me know that my Big Ben photo on Flickr has been selected for inclusion in the newly released sixth edition of their Schmap London Guide. You can find the page with my photo on here.

Schmap produce free travel guides for destinations all over the globe containing maps, useful links, guided tours and reviews for shops, hotels, restaurants, bars, sights and attractions.

They are available both online through their website, with specially optimised versions for mobile devices such as the iPhone, iPod Touch and mobile phones or through their Schmap application which comes in both Windows and Mac flavours.

I’m chuffed to have had one of my photos selected for their London guide, there’s a hell of a lot of London photos on Flickr!

Thanks guys!

Tags: , , , ,

No Comments



SetPageWidth