The move to Android: One Week In

Up until last Friday, I had been an iPhone user. Got the original iPhone, and upgraded to the 3GS when renewal time came. However, this time round, I've decided to sample the waters of the other side instead of blindly upgrading.

I got myself a shiny new Sony Ericsson Xperia Arc on Vodafone (UK), meaning a change in handset manufacturer, OS and service provider. These are my experiences so far.

This is NOT a direct comparison of iPhone vs Android (though there are comparisons to make). I'm not fanboy baiting and not picking sides. Just calling what I see.

The device

First thing, the build quality isn't that great. My old 3GS felt bulletproof enough that dropping it yielded only a passing "bugger". The Xperia, due to it's frankly obscene thinness, feels like a mistimed twist would snap the thing clean in half.

However, the HUGE screen makes a welcome change, the camera is a bajillion times better and the battery is no worse than the 3GS (certainly no better though).

What I love

  • The screen is amazing. Clear, bright and gorgeous.

  • The notification bar. Seriously, this thing is a revelation and I can see why Apple have shamelessly copied it wholesale in iOS 5.

  • Contacts, calendars, Apps, settings, EVERYTHING synced. My iMac, Macbook Pro, GMail and phone now all share the same database of contacts. And Android's way of linking a contact against their Twitter / Facebook account is just sexy.

  • Freedom. Freedom to put whatever I want on here. No need to pay for ringtones.

  • Over the air updates. Android 2.3.2 hit my device today, a 45MB download and update which the phone handled all on its own without intervention from a computer.

What I dislike

  • Typing. The Android default keyboard tries to do waaay too much. Far too many buttons, I frequently miss keys and end up having to undo large portions. That said, the ability to see multiple choices of word to autocorrect my hamfisted typing to is very welcome.

  • Syncing from a Mac your photos / music etc is a bit of a pain. There is a utility from Sony Ericsson, but it's not great, and Photos need to be done manually using the phone as a disk drive.

  • The default skin that Sony Ericsson have on the device isn't the prettiest. But that can (and will) be changed with rooting the device.

What I hate

  • Nothing so far!

 

Ultimately, I'm loving the change to Android. It still does everything my iPhone could as well as some extra bells and whistles. Ultimately, this makes me feel much better about making the decision based almost as much on the philosophy of the OS manufacturer as the device itself.

Right tool for the job, and for me, my little Android is doing everything I could want! Let's see what tempts me in 18 months time.

---------------------------

Just as an afterword, if only the carriers could catch up! I ported my number from O2, and when the number transferred, Vodafone sent me the new internet settings via SMS. The only problem was that they didn't work! They set the default data network as GPRS and not my contract WAP, meaning I had no data services for days until I figured it out.

RuntimeException, Twig and Kohana

I use Twig with Kohana to do my templating, and came across a mental and really annoying error today.

I catch the exceptions thrown by the Request class (this is Ko 3.0.10 code) and depending on the environment, will either output or let them die quietly.

One of these catch-cases is if Twig can't find the template it's looking for. Well, it turns out there's a bug in Twig/PHP which allows for an uncatchable RuntimeException to sneak out.

See the following:

<?php

//
// If you're using Twig with Kohana, and setting up a way of catching Exceptions throw, you'll
// probably be doing something like this in your Bootstrap.php
//
try
{
        $request = Request::instance();
        $request->execute();
        echo $request->send_headers()->response;
}
catch(Exception $e)
{
                
        if($e instanceof RuntimeException)
        {
                echo 'Template Missing! ' . $e->getMessage();
                exit();
        }
...
}

//
// The above doesn't work! You need to do
//
try
{
        $request = Request::instance();
        $request->execute();
        echo $request->send_headers()->response->render(); // Notice the render?
}
catch(Exception $e)
{
                
        if($e instanceof RuntimeException)
        {
                echo 'Template Missing! ' . $e->getMessage();
                exit();
        }
...
}

Script on gist.GitHub

In the above, we have a simple try-catch pair, which detects the type of exception and dumps out a simple debug string.

If you do the first way, you'll get the uncatchable RuntimeException. This is because when you do "echo $request->response" you call the Kohana_Twig::__toString() function. And buried in the bowels of this function is a 'throw new RuntimeException'.

THIS DOESN'T WORK!

Usually if you try and throw an exception in __toString, PHP will yell at you. But somehow this function sidesteps it.

So to fix the problem, you need to call render() explicitly. This removes the __toString step and allows you to catch the Exception correctly.

So whose bug is it? Well, kinda both. Kohana Twig shouldn't throw an exception where it can occur in __toString. BUT, PHP should moan that you're doing it! So kinda both and kinda neither.

I won't tell you how blue the air turned when hunting for this one.

kMailQueue - A Mail Queue for Kohana 3.x

Been a while since posting!

Today, I'm bringing you another of my sexy open source modules for Kohana 3.

This time round, it's a Mail Queue. I love mail queues, they allow you to see exactly how much email traffic is passing through your site, and you can simply turn them off if you need to go into stealth mode for a while. They also can help a lot with load balancing, since you control how many mails go at any given time.

kMailQueue

kMailQueue is a simple but powerful module for Kohana 3.x which allows you to set up your own queue. Simply add the module, point a cron at a URL and you can start adding to the Queue.

Features:

  • Configure how many emails are sent in each batch. (Your cron can control how often a batch is sent).
  • Restrict access to the queue through IP address and/or passphrase
  • Assign a priority to emails, to allow some to jump the queue.
  • Works with Kohana 3.0.x and 3.1.x

If you're interested, head over to the GitHub project. And don't forget to Fork Me Baby!

On finding inner Peace with Apple

Those who know me in real life will probably have been subjected to a rant or two about Apple.

In the old days, it would be the boilerplate "OS X is so much better than Windows" malarky. Recently, it'll be the hipsterish "Apple is becoming evil and taking over the world" line.

At my place of work, we use Mac's and we build iOS apps, which means conversation about Apple is never too far away. And I have increasingly found myself ranting and raving about these topics until I'm blue in the face.

But I recently had a week off, and went outside for a while. And do you know what? None of this matters.

Here's the dialogue I had with myself;

Old Alex: Apple are evil.
Zen Alex: Stop buying their products then.
Old Alex: But I genuinely enjoy working in OS X.
Zen Alex: Then continue to do so, but move off of iOS when your contract runs out.
Old Alex: But what if Apple lock down OS X like they have iOS.
Zen Alex: Then don't upgrade, jailbreak or simply move OS.
Old Alex: ... Crap.

When you stop to think about it, the tech industry is a ridiculously partisan place to live. You have your Apple diehards, your Windows fanbois and the Linux evangelists. But any web developer worth his/her salt will use all three OS's on a daily basis.

Even the companies that have become idolised are not as partisan as we are. Guess what, Apple has Windows machines in their building (how do they test the Win versions of iTunes or Safari?). Microsoft has a whole business unit dedicated to writing Mac software.

The point I'm laboriously crawling towards is this; you are never locked into an ecosystem unless you want to be. Don't like Apple's way? Move. Think Google owns too much of the worlds information? Use Bing and WebOS. Standing on a soapbox moaning about it changes nothing. Buying a competitors product does.

So I'm retiring my own soapbox. I'm finding inner peace. I'm shifting focus from the distraction of childish format wars, to what really matters; writing the best software possible with the tools I enjoy using most.

Just don't get me started on PHP vs Ruby.

Companies still don't get the Web.

I love my inflammatory titles. Disclaimer: this is a rant more than a blog post, and does contain rudies.

Here are a few reasons why companies, banks and such are still failing with regard to the internet.

Password Strength

A strong password contains numbers, letters AND punctuation. For a great example of nice secure passwords, take a look at the ones that cPanel generates for you. A glorious mix of symbols.

So answer me this please; why does the financial sector continue to insist on not using punctuation?

I had to change my 3D secure password the other day, and figuring this was my most sensitive password, decided to use cPanel to generate a nice difficult one. Pasted it in, and was told that it couldn't contain punctuation.

What the fudge. There is absolutely no discernible reason WHATSOEVER to not use punctuation in passwords. You guys should be hashing them in some way before storing them right? Right?

You can only view this page in IE

I use IE here, but I've seen them saying Firefox too. Fuck. That. Shit. This to me goes against the very core principle of the internet; accessible to everyone, everywhere, whatever they're using. Christ knows we waste enough development hours ensuring that client websites work in no less than seven separate browsers (IE6, IE7, IE8, IE9, Firefox, Chrome, Safari).

The worst offenders here seem to online applications forms. I've seen them on job applications, loan applications, even simple booking request forms.

90 times out of 100, the offender is ActiveX Controls. For some reason, a perfectly simple application form needs them and so they lock out everyone who isn't using IE on Windows.

It's lazy coding, and in the context of the data-world we live in, outright discrimination. To misquote Rasmus Lerdorf; "if ActiveX Controls is the answer, you're almost certainly asking the wrong question".

 

Personalisation is to be Feared

I love my webhosts Site5. They're quite well priced, the servers are speedy enough and the usage fair. But do you know what stops me from moving hosts every time I start thinking about it? Their Twitter presence.

The other night I wanted to ask a simple question; is PHP 5.3 support turned on. To open a support ticket seems like overkill; it's really just a general enquiry. Email? Well, I could do, but I have to find the right address to send it to. But I know I follow Ben Welch, one of the guys who work there. So I Tweeted asking him. A little later, I get a reply with an answer. Perfect. One happy customer, determined to stay with Site5 for a bit longer. I feel like I know the guys at Site5, they aren't a faceless corporation who just take money out of my account.

We now live in a time where we're more socially open than ever before. People on the other side of the world can read my thoughts and rants on Twitter, blogs, Facebook etc. We're accessible to more people, in more places, from different walks of life.

Why not carry that over to your company? It's a hell of a lot harder to get angry at a pleasant person, with a nice profile picture and timely responses on Twitter than it is to get riled over a faceless name on an email that doesn't seem to want to help.

On the flip side, if I can follow one of the company on Twitter and ask them a few casual questions about a product, I'm going to be more inclined to do business with them, since I've formed a relationship. It's the old idea of "I know Rob from SuperAwesomeWebDevs, he'll look after me".

 

So, how about you? What do you think companies continue to get wrong about the Internet?

MAuth - Kohana 3 auth module

Recently I've been working on some cool open-source doohickeys and this is one I'm particularly proud of.

MAuth - ORM agnostic, multi-instance aware, granular permissions

MAuth is a new Auth module for Kohana, simplfying the process of creating login / account processes, as well as permissions.

The big features are:

  • ORM agnostic - MAuth has drivers for both Jelly and Kohana ORM and it's super easy to write them for others so you can roll whatever ORM you want to.
  • Multiple configurable instances - You can have several, completely separate login systems (say admins, and customers) with their own separate configurations and even working on different database tables. All through one library. (They can even use different ORM's if you're that crazy!)
  • Package system for doing permissions, assign general 'packages' of permissions to users, and then make changes on a per-user basis.

The goals of MAuth were to make it super easy to create a powerful, simple to use, and above all granular permissions system that's easy to extend. It's mostly all class based, and so has a very small database footprint.

If you want a simple, extendible and flexible permissions / authentication module for Kohana 3, go take a look!

I've made sure there's a great set of documentation with it, so take a look at the guide/ folder in the repo with Kohana's userguide module.

I'll probably write a nice big tutorial in the next week or so on how to use MAuth, and I intend to develop the hell out of this module (it all came about from wanting it for a project I'm writing anyway). Feel free to submit feature requests, bug reports and the like over on the Git Repo.

Enjoy!

Learning Regular Expressions in PHP

I'll admit it, I'm a regex nerd. I love those little blighters and they've saved me on countless occasions.

For those who don't know, a Regular Expression, or regex for short, is a way of finding patterns within strings. If you've ever seen a url or email address be magically turned from text into a hyperlink then you'll have seen one in action.

Regular_expressions
http://xkcd.com/208/ Comic from XKCD showing how regex skills can be used in everyday life.

So, you want to learn regular expressions?

PHP uses both eregi and Perl Compatible (PCRE) regular expressions. As of PHP 5.3, the eregi library is deprecated, so always make sure you're learning the PCRE style of regex.

Here are some awesomely great resources to help you learn regex's in PHP;

PHP Manual
Kind of a no-brainer, but the manual has all you need to know about talking regex's in PHP.

Regular-Expressions.info
I once spent a very nerdy and lonely weekend working methodically through this website. It is brilliant. The syntax, the modifiers, everything is covered here. Use it.

Reggy
If you're lucky enough to be on OS X, then Reggy is an absolute godsent. Simply type your Regex in the top box, and the text your running it against, and Reggy will show you exactly what is being matched.

The Regex Coach
If you're on Windows, I've heard good things about this little bit of freeware that lets you test out your regexs. 

My own tips
My tips for working with regexs are the following;

  • Start small, build simple ones and work up.
  • If possible, always use someone else's rather than your own, they've probably done more research than you. This is especially true of emails and urls.
  • If all else fails, escape stuff using \ 

Hope that helps someone!

 

The age of the degree is over?

So, if you're in the UK it's kinda hard to miss the huge government spending review that's been taking place, huge swathes of cuts across public spending ayadayadaya.

For me, one of the more troubling announcements was that of tuition fees for Universities. I graduated in 2009 from University of Westminster, and left my university experience with ~£25,000 worth of debts, around £9,000 of which were tuition fees.

That number absolutely bloody terrifies me. I pay around £80 per month towards repaying my student debt, which means that it'll take roughly 26 years for me to repay my debt (assuming I stay on the same salary, unlikely but bear with me). 26 years. In 26 years time I'll be 48, hopefully married with kids and a mortgage, and yet still paying off that cheeky end-of-the-week dominoes bought with student loan money.

Now I can deal with that, it was part of the terms that came with going to University. But I have to tell you, the money involved really did make me think twice about going.

So what are the students sitting their A-levels now going to think? Universities able to charge up to £10k a year in tuition fees alone.

Let's do some maths.

£10,000 per annum x 3 year degree = £30,000
£14,000 in total maintenance loan.

Grand total; £44,000 to do a three year degree.

More maths, how long to repay?

Assuming £80 per month repayment (it will inevitably be more than this);

Repayment time = 45 years. You'll be paying some of it off with your pension.

---

This is all fairly alarmist I know, but I am certain that prospective students (or parents) will be doing these same sums. And I reckon we'll see a large proportion simply choosing not to go to University.

But there may be a silver lining to all this.

I'm a web developer. My degree is in Photographic Science. I learned my web dev skills on my own, self-teaching.

Imagine what would happen though if business stepped in and started accepting interns from Sixth-Form leavers? Train them up within companies, get them comfortable with the company practices, methodologies and missions. You can shape these bright and eager kids into exactly the kind of workforce that you need for your organisation.

Let's take a simple example, I run a software company that specializes say, C++ programming. Instead of waiting for a Computing Science graduate to come along (and then inevitably un-teach them bad habits from their studies), I could simply take an A-Level student who studied say Maths and IT / Computing and get them trained up from day one.

The benefits are shared by everyone. Since they aren't a graduate, they will command a lower salary, saving you money. The kids are earning a wage whilst learning, saving them plunging into near bottomless debt, meaning they have more disposable to spend on cars, houses, insurance. And at the end of the day, you get a young, enthusiastic employee.

I've always felt like the graduate talent pool was supremely underused, but I'm starting to think it stretches further than that. Especially in technology industries, I know kids of 14 - 15 who can code a hell of a lot better than Comp Sci graduates. Isn't it time we started using them?

Anyone who's thinking "Doesn't this sound like a Modern Apprenticeship?" I award you an internet cookie. Apprenticeships are a fantastic, age old, idea for training up people. Maybe other industries need to start thinking about using them too?

----

I've never run a business, so feasibility of this is a bit of an unknown, and I'm aware that training someone comes at a cost. This is not a hard and fast plan, but an idea that I'm casting out onto the interwebs. Let's see if anyone agrees.

Dear Interactive Adverts,

You suck.

Babbies

There seems to be a trend of these annoying interactive ads appearing on the internets and it's doing my nut.

I, like most people, enjoy reading peoples stupid and funny Facebook posts, and Lamebook.com is one of the better sites for doing such. However, they (or more likely their ad network) are now serving up these interactive monstrosities.

There's a number of things ball-bustingly annoying about them;

  1. Sound. Sound on the web is disruptive. Remember the days of the Midi file embedded on the page? Well, these days having sound on a website is considered a bit of a faux pas, but do you know what's worse? Sound you can't turn off. And these adverts have that by the bucket, see this as an example and try and turn the damn sound off;
    http://c3.openx.org/f8271906a7dde2c07e0ec79cd010ca50.swf
  2. The whole concept of them is flawed. I already don't particularly want to be looking at your advert already (for a number of reasons, usually because it doesn't apply), but now forcibly making me find it on the page and use it is just pissing me off for no good reason. More often than not I don't ignore ads because they're there, I ignore them because they aren't relevant, and no amount of soothing voiceover work will make me change my mind.

Ad producers are always looking for new ways of encouraging engagement, and this seems like a logical (if horrific) step. But I think that the people placing these ads on their sites should think long and hard about what they're doing.

Back to my example of Lamebook, where I would quite happily spend an hour or so a day perusing their content (and in doing so looking at their advertising), if one of these ads comes on, I'm off the site in a flash, and unlikely to return for a day or so, hoping that the ad will have gone away.

Net result = Strepsils and E45 cream have a bad reputation in my head, and Lamebook loses out on page impressions.

So, was it all worth it?

Eurogamer 2010

Little off topic, but every now and again I'll be posting stuff on gaming, a favourite hobby of mine.

Today, I had the pleasure of once again of going to the Eurogamer Expo in London, this year accompanied by @tnolde (Tim Nolde) and @gingoreilly (Chris Janes) both of them game devs. This post is just a summary of what was seen and done!

Assassin's Creed Brotherhood

I'm a big fan of the AC series, but I have to say I was a little worried about this one. Whilst I love romping around the glorious settings of the previous two games, for me the most interesting part was the overarching plot of Desmond Miles. So a game about Ezio, a character we were told had played his part, didn't pike my interest as much as it could.

Well, I can't say my fears are allayed, because Ubisoft was showing off the new multiplayer functionality at Eurogamer.

But the multiplayer itself is good!

This was a gamble, with Assassin's being lonely, solitary creatures, so the idea of you careering around a map stabbing other players seemed a little off, but it's fun! You're randomly (as far as I could tell) assigned a target to find (another human player), and using a compass type device at the bottom of the screen, you track them down and try to kill them. All this should be done before the person assigned to kill you skewers you in the back. And it works well, you're encouraged to be stealthy and not just sprint at opponents, and the nagging feeling that someone is about to land on your head with a hidden blade keeps you on your toes.

My only slight gripe is that it's kinda hard to tell when someone who is hunting you is close by, there's no visible warning, and more often than not I'd pull off a perfect kill, only to be killed immediately afterwards by the dude behind me.

Little Big Planet 2

The sackboys are back and doing much the same as before! The levels look great and seem quite varied, and I'm informed that the toolkit for making your own has improved vastly. All in all we had fun playing it!

Kinect vs Move

Both Microsoft and Sony were showing off their new motion control toys, so me and Tim decided to conduct a little experiment. Both had table-tennis style games running, so we played both to see how they compared.

Kinect went first, and to be brutally honest, we weren't that impressed. Partly this was due to the hardware, 1-1 tracking it is not. The shadow of ourselves on the screen had trouble keeping up sometimes, and on occasion wouldn't register the movement at all. However, considering it was set against a background of milling people, we were impressed with the tech. The game itself however was dire, no matter what frantic flailing you did, there was no control over the ball at all, and me and Tim resorted to making vaguely misogynistic 'spanking' gestures in front of ourselves to play.

Move however was much more impressive. The paddles on the screen seemed to keep up with our movements much more cleanly and quickly, and the game was realistic enough for us both to bugger up the first few shots as we got accustomed. It did however start to wander into uncanny-valley, because the movements we're making are so close to the real movements made to play ping-pong, my eyes were expecting to get a proper read of depth so as to time the swing correctly. With a 2D display, I didn't get this, and found timing very difficult. Maybe coupling up with a 3D display this will improve, but read on about my thoughts on that.

Gran Turismo 5 (in 3D!)

The game that has been in development for goodness knows how long was playable, and like you'd expect, very pretty. The cars are modelled to within an inch of their lives, and the tracks are realistic looking enough (though Chris was keen to point out what he termed 'billboard trees'). Again though, being brutally honest, it looked like any other racer you've played recently, except that judging by the number of crashes, it's got a steeper learning curve.

The kicker however was playing this game in 3D. Sony were showing off their new 3D TV's, and Gran Turismo was a good candidate (the game has 3D support baked in). Our verdict?

Meh.

Sure it made the HUD pop out a bit more, and the depth of field increased a bit, but it didn't aide immersion anywhere near as much as it should have. In fact, it made you feel faintly dizzy after a while. Definitely not worth the £3k or so for the kit.

 

We played a few other bits and pieces and watched a fair few more (Gears of War 3, Fallout, Killzone 3 just to name a few), and overall enjoyed the day. Getting to grips with the motion controllers was fascinating, and in this first round, it seems like Playstation Move is the one to watch, but who knows what will happen when the big studios unveil their masterpieces.

So thanks Eurogamer, we shall be returning next year, as long as the crazy-hot Train to Game girl will be there wandering around again!