I think this room is going to be a bit of a mission, I have one wall with half a missing skirting board which has had its fireplace plastered up twice, one where the plaster is falling off much faster than the old wallpaper, and one outside wall which is damp and in such bad shape I actually had to go outside and check it looked OK from there. And this is is the smallest room in the house …
Author Archives:
Customising Screen-Profile Files
The tabs line is the one in the profile file which starts “caption always”.
caption always "%{wk}%H%{Bk}|%{Mk}%?%-Lw%?%{km}[%n*%f %t]%?(%u)%?%{mk}%?%+Lw%? %=%{Bk}"
I also altered the “hardstatus string” line, which holds lots of placeholders, to remove the clock – I run screen on my laptop inside KDE mostly, so I already know what time it is. Annoyingly this isn’t customisable via the menus but I edited my profile file to get rid of it – here’s the diff
29c29
< hardstatus string '%99`%{= kw} %100`%112`%= %102`%101`%114`%115`%108`%113`%119`%117`%118`%116`%106`%104`%103`%105`%107`%Y-%m-%d %0c:%s'
---
> hardstatus string '%99`%{= kw} %100`%112`%= %102`%101`%114`%115`%108`%113`%119`%117`%118`%116`%106`%104`%103`%105`%107`'
The only thing annoying me now is that screen seems to constantly redraw itself, so Konsole thinks there is activity in that screen, when there isn’t. Suggestions on stopping this or more ways you can customise your screen file are gratefully received – just add a comment!
Upgrading Subversion Server to 1.5
Some time ago I upgraded the subversion server to subversion 1.5, and the clients that use it are probably mostly on 1.5 as well. We haven’t had any compatibility problems between versions on this upgrade, which is good news since a few versions ago there was a release which caused any newer client to render the repo unreadable by any older client. Predictably someone in the office upgraded their client one day and it took us a good few hours to work out why subversion had stopped working!
The Subversion 1.5 upgrade doesn’t turn on all the 1.5 features by default, but will upgrade to 1.5 and allow older clients to continue to work with it. If you want to upgrade to the 1.5 features though, you’ll need to make sure that all users have clients of version 1.5 or later, and then upgrade the repo by running:
svnadmin upgrade
Once this is done you can start using the new merge tracking features in subversion – enjoy!
5 Ways to Make Friends 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
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
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
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
$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
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:
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!