5 Ways to Make Friends at a Technical Conference

These are my top tips for getting along and meeting new people at a technical conference.

Take an extension cable

Conferences are notorious for having too few and too short power leads, and everyone needs to recharge laptops, especially in hands-on sessions like tutorial day. Having an extension cable will make you instant friends as you bring power to more people.

Join in the pre-conference hype

Follow the nominated twitter tag and log into the IRC channel if there is one. Find out who is staying in the same place as you or arriving at the same time, arrange to travel together or meet for a pre-conference drink to break the ice.

Attend the extra-curricular events

Don’t think for a moment that when the official schedule ends, you are off-duty for the night! Find out about any social activities going on – and if there is an informal track such as an unconference, make sure you attend, or even participate. This is a great opportunity to meet more people and see more talks in a much less structured environment.

Take business cards

Or if you don’t have that kind of job (or even if you do!) get some moo cards to take with you so you can pass on your blog/email address, name and twitter details to people you want to stay in touch with after the event.

Stay an extra day

The party starts when the conference ends, so hang around for 24 hours or so and join in :) Especially for the speakers (whose rooms are paid for) and those travelling internationally, there’s no need to rush off straight away. Some of the best times I’ve had at conferences have been after the main event.

Keep in touch

Write up your experiences on your blog (do you have a blog? If not, this is a great place to start) and tag it appropriately. Comment on other people’s and stay in touch with the new friends that you made at the conference.

OK, so technically this is six ways to make friends, but I won’t apologise for that :) What’s your top tip for conference attendees?

PHP 5.3 Feature: Late Static Binding

With the release of PHP 5.3 comes the functionality “late static binding”, a feature which I’ve been impatient to see for quite some time! This is something a lot of developers have been puzzled by in earlier versions of PHP 5, probably without being aware it had a name. In PHP 5.3 there is functionality for dealing with this situation so here’s an outline the problem and then a look at how to avoid it with PHP 5.3.

The issue arises because of the way PHP classes refer to themselves. Keywords like self are resolved at compile time, which means that where classes inherit from one another, self will always relate to the class where it is mentioned and not the class which is inheriting it. Many class hierarchies will have common functionality across classes but which need some form of “which class is this?” awareness, either to access the class name or a variable declared in the class so that a method declared in the parent can be used in all inheriting classes. Without late static binding, this will always resolve to the declaring class, leaving developers the choice between copy/pasting the same function into every class that needs it or turning their static method into a dynamic one, since $this resolves as expected.

It’s perhaps clearer to illustrate the problem by showing an example. Here I have a base class Record, which all my other classes will extend from (in the tradition of these things, its an over-simplified and not-terribly-useful example but I think it shows the point):

class Record {
    
    protected static $tableName = 'base';

    public static function getTableName() {
        return self::$tableName;
    }
}

So, I’m ready to write my first useful class, which will be my user class – it will have its own variables but can inherit the function since they’re identical.

class User extends Record {
    protected static $tableName = 'users';
}

So if we call the getTableName method against the User class – what would you expect the output to be?

User::getTableName();  // returns "base"

That isn’t what I expected when I first ran into this scenario. This is a pretty common thing to want to do, I’ve seen people have this problem when implementing active record patterns, when creating re-usable form widgets with their own templates, and in countless other applications. With PHP 5.3, the static keyword has been implemented to allow us to get the value of the class the code is actually executing inside rather than where it was inherited from. We simply replace the “self” in our Record class with “static”:

class Record {

    protected static $tableName = 'base';

    public static function getTableName() {
        return static::$tableName;
    }
}

This keyword evaluates differently and has awareness of its calling context – so if we repeat our call to the getTableName method against the User class:

User::getTableName(); // returns "users"

That’s better :)

This feature doesn’t make this problem go away – the self keyword still resolves to parent so as PHP developers we will still see this slightly unexpected behaviour where the parent values are returned. However there is now a solution to it in the shape of the new static keyword. Its a feature I’m delighted to see included and I’m sure it’ll be helpful in a wide range of applications!

Does this help you? Have you run into this behaviour before? And how did you solve it? Leave a comment!

PHPUnit with Zend_Controller_Action_Helper

I’m currently working on a REST service built in Zend Framework and I ran into problems very quickly – when I tried to write the first unit test for the first action in fact! PHPUnit was just dying when I asked it to dispatch() any URL which didn’t return HTML, it wasn’t even giving its usual output.

What was actually happening was I was making use of Zend_Controller_Action_Helper_Json, my service returns JSON and this action helper takes input, transforms it into JSON, sets the content-type correctly and tells ZF not to look for a view since we don’t need one. I thought this was pretty neat.

But look at the start of the declaration for the action helper:

class Zend_Controller_Action_Helper_Json extends Zend_Controller_Action_Helper_Abstract
{
    /**
     * Suppress exit when sendJson() called
     * @var boolean
     */
    public $suppressExit = false;
...

By default the JSON action helper will exit() – which of course when run from phpunit causes that to exit as well! There is the class variable there so it was simple to turn off – I just extended my class and changed the value of that $suppressExit variable.

class Zend_Controller_Action_Helper_ServiceJson extends Zend_Controller_Action_Helper_Json {
    public $suppressExit = true;
}

My tests now run successfully and I can build my application, hopefully next time I’ll realise what I’m doing wrong faster!

Ubuntu Netbook Remix on Aspire One

A while ago, actually quite a while ago in May, I put the Ubuntu Netbook Remix version of Ubuntu 9.04 Jaunty Jackalope onto my lovely blue Acer Aspire One netbook.

The way this works is that on another machine (or I guess on an existing OS on the netbook) you download a bootable USB key image. With some trepidation (not a whole lot, I did back up first), I put in the USB key and settled in to see how far I could get with the installation.

Well, a short time later I realised I’d finished installing and was really just fiddling! Straight out of the box the wifi worked, the hibernate worked, sound (in and out) worked, the webcam worked, and there is this great window handler thing which amalgamates title bar and task bar into one. There’s also a cute menu on the desktop – all in all its really neat:

The working hibernate in particular has really made a big difference, at home the netbook just gets used for short bursts and lives next to my bed, usually plugged in. When it comes into its own though is at conferences! I can flip this thing open, use it, and flip it shut, pretty much all day. The startup time is really small from suspend and so long as I’m only dipping in and out (at conferences, I’m mostly in talks so I’m only ever checking mail etc), the battery life easily lasts a day.

Thanks to the Ubuntu folks – this is one quality piece of software and now I love my little netbook even more. Anyone else using the netbook remix? Were your experiences as good as mine?

Whose Responsibility is Your Career?

There are 10 types of people in the world: Those who understand binary, and those who don’t.

I guess we’ve all seen this geek witticism, its a little piece of the fabric of the culture. Personally I split people into two groups along other lines: those that look out for their own professional interests, and those who don’t. I’m an optimist, so lets start out looking at those who do.

These people are self-starters. They have read relevant texts on their subject and depending on the type of industry they are from they either have blogs, news and syndication sites on their feed reader, or they subscribe to the relevant periodicals. You’ll see them at some of the events, sometimes a long way from home, and always “off their own bat”. They’ll be asking questions about how different technologies go together, about who they could approach with a particular question, and so on. If you mention web resources, they’ll go there and read what’s available. They might come back with follow-up questions. And they will be the first to also help another along his way, passing along the gifts that they have been given from those who went before and helped them to this point.

Then there’s the other kind of people. The kind that doesn’t have books of its own, that doesn’t interact with communities outside of work, and that “can’t” go to events because their employers don’t send them. I understand that money and time are both something that can be in short supply, yet I still have little patience with people who have this attitude. None of us can be everywhere that would be useful, but one event a year is do-able for most people, and in my opinion career development shouldn’t be free and effortless.

So – which kind of person are you? If its the first kind, what do you do to ensure you keep learning and keep growing? Post your stories in the comments!

PUTting data fields with PHP cURL

This is a little post about how to PUT multiple data fields using the PHP cURL extension. Why I wanted to do this in the first place is beyond the scope of this post, since its quite a long story. The curl command line allows data fields to be sent with a PUT request, and I wanted to do the same from PHP. Here is a snippet of code to show how I did it.

        $data = array("a" => $a);
        $ch = curl_init($this->_serviceUrl . $id);

        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
        curl_setopt($ch, CURLOPT_POSTFIELDS,http_build_query($data));

        $response = curl_exec($ch);
        if(!$response) {
            return false;
        }

I’m putting this here so I remember for next time – if it helps you as well then even better :)

New Bedroom Curtains

This weekend I took some time to make some curtains for the bedroom. Since we bought the house we’ve had some rather unattractive and slightly broken metal blinds. The room was otherwise OK though and we just kind of moved into it and worked on the rest of the house. I bought the fabric for the curtains soon after we moved in but I needed some help from my mum to actually make them as I wanted to do 2 layers and wasn’t sure how to proceed.

Window 1, before Window 2, before

Kevin’s mum Kath was visiting this week and while explaining to her why I couldn’t do this task myself, we kind of talked me round. Curtains are just straight lines after all so I dug out some crafty books and considered the task (thanks Kath!)

I had two layers of fabric, one plain sheeting and one floaty gauze – the idea of having floaty curtains but which do actually block the window. I measured the window and found that both were 74 inches high and were 56 and 44 inches across respectively. I do mean inches, our ceilings are 8 and a half feet high so most of our windows are taller than me! This of course makes curtains quite an undertaking, with 60 inch wide fabric and two curtains on the bigger window and one on the other, I had two 60 inch by 80 inch curtains and one 90 inch by 80 inch. By the time you have seamed edges and top, and attached curtain tape, that’s more than 30 yards of sewing and you need a LOT of floor to cut things out on. The wrestling was quite worth it though:

Finished Curtain 1 Finished Curtain 2

For reference, the curtains were quite easy to make (although they’re still unhemmed). The recipe goes something like:

  • cut fabric, lay out with right sides together
  • for the wider curtain, I joined half a width with a full width to get the size I needed
  • pin and then stitch down outer edges
  • pin and then stitch along the top
  • turn right side out (like a duvet cover!)
  • pin and then stitch corded curtain tape 5cm from top of curtain, along back
  • hang curtains
  • admire
  • Wonder how long til I get around to hemming them? My excuse is that curtains are supposed to hang for a while, to allow them to “drop” to their eventual length!

Presenting with a Netbook

I’ve been giving a few talks in the last few months and I’m increasingly realising that although I love my thinkpad, its overkill for anything where I don’t really need the hardware, or where I don’t want to be carrying a full-size laptop all day. So I’m increasingly taking just my netbook, which is an acer aspire one with 512 MB of RAM, and using that along with some xrandr skills and my much-loved Kensington Slimblade Presenter Mouse (its the multimedia version, has extra controls on the underneath).

Presenting Setup

The netbook is easily up to this job – it happily runs the open office presenter program, I don’t have the presenter view plugin installed on it yet but just use the screens mirrored and use the netbook screen to see the current slide rather than having to look at the screen. This saves me either having to look away from my audience or from being completely floored by slides WAY too big for me to read when I’m standing in front of them (I presented at the FOWA roadshow, great venue but slides so big I didn’t dare look round at them!). The netbook screen is small but font sizes on slides should be quite big and I’m kind of long sighted so I can read the text at a distance of 6 to 8 feet without an issue.

The presenter mouse has a little USB dongle and then controls for controlling the presentation, with a laser pointer and a button to turn slides to black – once I begin I don’t need to be back within reach of the computer at any point. Which is really useful if you get one of those awkward spaces where the dock for the laptop is in a corner you don’t want to be standing in (I see this a lot at the informal geek events). Just start it going and get into position – and present from there. Of course this relies on knowing the presentation well enough to not need your slides or notes or having a paper copy you can refer to.

Don’t be fooled that you need great hardware or particular equipment to give a talk – anything with a monitor socket to talk to the projector is good enough, and if you can get a remote of some kind then all the better. Other accessories that might help is a stop watch (or use the timer on your phone and put it somewhere you can see it), so you know how you are doing for time, and some notes on index cards that you can easily hold without rustling. Above all, take a step away from your computer and look your audience in the eye – they’re here to see and hear you.

PHPNW: Site, Tickets and CfP

The date for PHPNW was announced a few weeks ago as Saturday 10th October 2009, and now we’ve got all the official bits and bobs to go with it! In outline:

The website: http://conference.phpnw.org.uk

Tickets: http://conference.phpnw.org.uk/register. Early bird pricing until September 11th, student tickets available – look on the website for instructions on getting student tickets.

Call for Papers: http://conference.phpnw.org.uk/callforpapers. Speakers wanted! If you have something to share and you think you can do that coherently – then submit to us please, we’re always looking for new people, new talks, as well as the talks and speakers you’d expect to see at the bigger PHP conferences. If you’re not sure if something fits, feel free to contact us.

This is officially a one-day Saturday event, with a full day with two tracks of talks and an attendance of 200+ people. In reality its a whole weekend of geeking out in Manchester – with a pre-conference social on Friday night, the main event on Saturday, a conference social running on Saturday night and an informal set of sessions on Sunday morning for anyone with the energy to keep on going before everyone makes tracks to their homes.

If you’re going, thinking of going, went last year, or wishing you could be there – add a comment! I’m looking forward to meeting many of you at the event :)

Status Codes for Web Services

This the last entry in a mini series on points to consider when designing and building web services. So far there have been posts on error feedback for web services, auth mechanisms for web services, saving state in web services and using version parameters with web services.

Unlike the other posts in this series, this one is quite specific to one type of service – REST – since it deals with status codes, specifically HTTP ones. The ideas are transferrable however and other types of service can return statuses in a similar way.

There’s a few key things to think about when returning status codes. In earlier posts in this series these was discussion of using existing application framework to serve pages and changing the output mechanism accordingly. Usually a web page will return a status 200 for OK or also 302 for found, so this is fine when things are working normally. But when things aren’t going quite so well, its useful to give alternative feedback that can be easily picked up by a client application.

When things go wrong there are a couple of different schools of thought of how the service should respond. One is that if, for example, the user supplies data which fails validation, the service could provide the OK response and a message to the user to let them know what needs validating – exactly as we’d return information messages to a user filling in a form. To be considered restful however, the service should more correctly return one of the “400” status codes, which means that the client made an error. Interesting and useful codes* in this series are:

  • 401 Unauthorized
  • 403 Forbidden
  • 404 Not Found
  • 405 Method Not Allowed
  • 406 Not Acceptable
  • 408 Request Timeout
  • 417 Expectation Failed
  • 418 I’m a teapot

* I didn’t say they were both useful and interesting

Using descriptive status codes allows the client to get the headline of the problem without having to parse a whole request to find out whether it is good or not. HTTP already has this feature built-in, and so we make use of it (HTTP is pretty cool really, makes a great protocol for services!).

Where an error occurs on the server side – it is usual to return a 500 error or another in the 500 series. This lets the client know there is a problem outside of their control; it is useful to include information about whether the client should retry and when. Having a defined protocol for retries helps avoid the situation where a system comes back up only to fall over again with all the traffic from people retrying every minute (or other interval) – this is a real concern for systems that are under heavy load.

Status codes are like a headline to the calling entity about what happened, and are a valuable tool in the web service toolkit. For bonus points, leave me a comment and tell me which is your favourite status code :)