Monday, March 10. 2008
ZCE prep - and dumb tests
This week I’m going to take the first of my PHPArch.com’s ZCE prep test – then I’ll read the book and see they they expect me to know.
Going for the Zend Certification is something I’ve been thinking of doing for a couple of years, and especially now that it covers PHP5 – and increasingly good practices and security topics. It’s not that I need to get the ZCE, I’d go for it , for the intellectual challenge if nothing else. It’s also the closest thing I would have to a professional qualification since I completed a HNC computer studies in 1992 – and that was just 1/day week day release over the course of a couple of years.
Of course, it’s not the first PHP test I’ve taken – last year, just before the PHP London 2007 conference, Allegis had come along to the PHP groups’s early-February meeting, to plug their services (and they got business from it, one guy interview the following day, a Friday, and started work on the Monday) – but they offered to have anyone that wanted to do the Brainbench test, paid for, by Allegis.
At the time, I had just started a couple of days before at a job near Covent Garden, but then left it after a week for a better gig (where I still am now, some 13 months on) – but I took Allegis up on the offer, and finally got the results at the conference. I never did get a copy of the exact numbers, but I was told the headlines, so these may not be exact, but they are certainly in the ballpark.
- Time: 28 minutes (apparently this is very good)
- Score 4.73 (out of 5.0)
- Better than 98% of other test-takers.
I’m told that the harder the questions you answer, the harder the next questions get – so getting from 4.0 to 5.0 is a lot harder than getting from 3.0 to 4.0 – if I’m wrong about that, then please let me know.
The thing is, the Brainbench tests are open-book – they pretty much have to be, you take them at home, though they are against the clock. I can certainly appreciate the logic of it – after all, which serious developer doesn’t have an internet connection and a quick bookmark to http://php.net (and I’ve look at the other language sites – php.net is by far the best), or at least a copy of the documentation around (.CHM file or just a bunch of HTML pages – or, like I do, a weekly rsynced copy of the php.net manual!). Just as well I did, the tests I’ve seen always throw in some pointless questions like how to use LDAP, or how to connect to an Oracle database. I’ve never used either of them, so I don’t bother to learn them – but if I did need them, I’d figure it out in a few minutes reading – or, more likely, I’d have some kind of library, like the Zend Framework which did the hard work for me – plus, I’d only end up writing that kind of code once anyway before I threw it into a function and forgot the minutiae.
It saddens me when people are too dumb to do well on such a test though – how hard is it to read the manual, at least well enough to know where to refer to for more advice?
The ZCE is a closed book exam – or, as I call it (for all the reasons the brain-bench is open-book) – unrealistic. If I can’t recall whether the $haystack or $needle come first in in array or string search – it’s but a moment to look it up.
Even though I’ve listed my scores above, I don’t bother to promote myself with them on my CV – indeed Allegis is the only company (recruiter or not) that know them – they did pay for it after all. Because I can get those kind of scores with what I consider so little effort (about half-an-hour’s worth in fact), then either the test is bad, or 98% of the other people that gave taken that test are. Frankly, I’ve got to think it’s mostly the latter.
Keep reading my posts, and I’ll tell you want you need to do to ace your tests – and not look a fool when it comes to developing something I might set you.
Sunday, March 9. 2008
svn checkouts vs exports for live versions
That first link, 'how to release new versions of websites', suggests checking out a version of the site as a working copy, (it's certainly something I've done before now), but then it goes on to use the 'svn switch' capability to move between versions (of course, they are also doing in in TortoiseSvn, and there for the live web-server is likely to be running Windows, no way I'd run a server on Windows - not even for testing). There is however some trouble with revision switching - especially on a busy site that has to keep running even while the new version is being put into place. While SVN does atomic commits - the new code goes into the repository all at once, or not, it's harder to do the all at once part on a non-transactional file-system - such as a webserver. The bigger problem is that rolling back will also take time - and in an emergency, the time taken to do something is crucial.
Here's what I do - Whenever I want a new version to go live, which might be from every couple of days to as often as a couple of times per day, I'll update run the script below with the specific revision number to export (and a date/time, but that's just for easy reference). When it runs, it also symlinks the given version as 'dev' - which is part of the path to the site 'dev.example.com', wham, instant new version, and I can trivially delete the symlink and on the same command line symlink the older version (with 'rm dev && ln -s 1234.20080102 dev'). After a quick wander around the newly checked out version, maybe run a set of unit tests, just for security, it's just as easy to put a similar 'live' symlink into place with a new link.
If there is ever a problem, rolling back to a previous live version is just as easy. Other configuration changes are made within the code on the apache servername, or the machine's own hostname (more useful for CLI scripts, generally run from cron).
There are some downsides - with a complete checkout of a 40-some megabyte website (it's mostly the Zend Framework and other libraries from which I use a number of files, though rarely all), it takes a little while (not too long, it's a gigabit link between the repository and the main webserver) and there are also some potential caching issues (Etags are usually based on the file inodes), but as we plan to move to a multi-machine cluster - and the images aren't being served from Apache, but a dedicated image webserver, that's not a significant issue - and even on Apache we don't have Etags enabled (Yslow from Yahoo also suggests that).
REV=1914
REVDIR=$REV.20080214.1914
REPOSITORY=svn+ssh://username@svn.example.com/var/svn/SITEURL/trunk
IMAGES=$REVDIR/htdocs/i
STATIC1=$REVDIR/example.co.uk
svn export --revision $REV $REPOSITORY $REVDIR
mkdir -p $REVDIR/tmp/templates_c
chown -R www-data: $REVDIR
chmod -R 777 $REVDIR/tmp $REVDIR/htdocs/cache/
chown -R nobody: $REVDIR/tmp $REVDIR/htdocs/cache/ $IMAGES $STATIC1
dos2unix $REVDIR/bin/*sh $REVDIR/bin/*php
chmod 755 $REVDIR/bin/*sh $REVDIR/bin/*php
# chmod -x all the non-directories in images
find $IMAGES -type f -perm -a+x | xargs -r chmod --quiet -x
find $STATIC1 -type f -perm -a+x | xargs -r chmod --quiet -x
ls -l $IMAGES/* | grep -- "-x"
# make the latest version available at http://dev.example.com
rm dev && ln -s $REVDIR dev

Comments
Wed, 28.10.2009 20:56
Multiple workers running is no t a problem – Beanstalkd will keep the jobs separate even if multiple ones are reser [...]
Wed, 28.10.2009 19:47
Is there any way to run more t he 1 worker (bash script) at a time?
Fri, 26.06.2009 01:13
Hi, What kind of beanstalk client library do you use or h ave you written your own? Is i t in PHP space or a C ex [...]
Mon, 22.06.2009 22:28
Hi, Good post. I am also pl aying with beanstakd and I am waiting for the rest of your p osts. Greetings, Alf [...]
Mon, 24.03.2008 19:30
Sun, 16.03.2008 23:45
Sun, 16.03.2008 21:31
Although example shown was usi ng Windows (my desktop) there is no reason why this can’t be used on Linux or as we [...]