Monday, 1 August 2011

Tooth sucking isn't helping

(Cross posted at the Arcus Global Blog)

The IT Crowd premiered when I had no TV nor any interest in one, I still have no TV but I do get DVD box-sets every now and again to watch at home. After getting the The It Crowd I was really quite excited but the audience at home simply weren't as in to it so it's still there sitting on a shelf waiting…

The few episodes I watched though brought to the fore of my mind the idea that management hate IT — this was certainly the case in my previous job where I heard that the IT department objected to having to support OSX as the infrastructure they were supporting was generally Microsoft-based. But the manager in question had seen some colleagues at a conference using a shiny new MacBook and had simple had to keep up — but without appreciating that they'd have limited access to the infrastructure that they were used to without the IT department having to invest a significant amount of time and effort.

To an extent the infrastructure encouraged by Arcus is agnostic so such issues would be lessened but the principle remains.

To an extent that isn't really what I'm trying to discuss. Most reasonable managers would listen to the concerns of their IT department and act accordingly, assuming that the IT department made their concerns plain to management rather than adopt a bunker mentality and simple Keep Calm and Carry On. The BCS seem to have an approach where they encourage IT staff to become much more involved in the strategic side of business rather than simply being an amorphous mass where requests are met with utterances which are either arcane in nature or follow along the lines of the teeth-sucking my wife meets when she goes to the garage (why the mechanics don't do the same to me is a mystery, I only learnt to drive a couple of years ago where she's probably been driving for longer than they've been alive).

A recent IT World article highlights this discord with the headline “Why businesses move to the cloud: They hate IT”. Strong stuff ehh?.

A colleague, Louis, discussed this with me last week, and the article in IT World refreshed it in my mind. IT departments need to be ever-so-much more strategically and politically minded, something which isn't overly easy for people who're used to talking to computers rather than people. To an extent I'm lucky: I moved from talking to people to talking to computers — but then again I find computers to be just as outrageously frustrating and mind-blowingly lovely as people.

The figures are frightening though, over two thirds of business managers say they keep funds to one side so that they can provision IT without the input of IT departments. The article goes on to say that if IT departments aren't careful then they run the risk of being left maintaining hardware and legacy systems rather than playing with cool new Cloud stuff. Being left in the dust rather than flying in the clouds (Sorry, it's a Monday morning and the purple prose it just oozing out here).

It's an interesting shift though isn't it? I guess at one point the business decided that having all this IT stuff provisioned internally was just cheaper than relying on some outside agency which they had no control over, now it may well be that that isn't totally the case anymore - the control might not be there but the cost saving certainly seems to be (I'm about to start work on a tool that'll illustrate these savings in a very real way). There was also an interesting paragraph which I can only assume was directed at IT departments:

“If they wait so long researching cloud that their whole end-user constituency drains away from them to external IT providers, however, they lose the chance to maintain security and reliability at levels they prefer and justify their salaries for next year.”

I think we're living in interesting times, I guess your approach to change dictates whether this is a blessing or a curse.

Friday, 29 July 2011

PDO mysql_num_rows equivalent

So I'm re-doing a web app using PDO rather than the built-in MySQL stuff as there seems to be a possibility that the MySQL extension will be gone before too long.

Thing is I do a lot, and I mean a hell of a lot, of checking to see how many rows are returned after a SELECT... and PDO doesn't support mysql_num_rows.

So after looking around I discovered that if I alter my SQL I can check on one line thus:

$dbconn->query("SELECT COUNT(*) FROM `something` WHERE `condition` = 'something'")->fetchColumn()

Which'll give me the number of matching records. I can then check that against a condition and carry on... or not as the case may be.

Monday, 25 July 2011

Throwback

Neanderthal child

My Aunt Joan has always said I was something of a throwback, she said I was like a Viking or some other sort of big, gruff warrior type of geezer - though she always said I was a gentle giant type-thing as well. Looks like all us non-africans are to some extent according to this article I found on disinformation which discusses this article on io9 by Alasdair Wilkins.

Except that I'm a throwback to a later period in history, which can only be good I guess... unless it means that everyone else has evolved further... ahh well, at least I'm not dragging my knucles along the ground!

Rule 34

So I got my present job on the back of an interview. It was an interview that was more like a conversation and I found myself interrupting Lars and him interrupting me as we discussed various technologies or approaches to programming. I got off my bike at The Judge School after listening to WHOURKR (which I'd discovered via Transmission Zero) and I was hyped and sweating buckets thanks to cycling to the beat and being really quite excited. We got to talking and it was like I was entering a whole new world, a world where people didn't actively listen to me when I was rattling on about this IT stuff which got me so excited.

Reading Charles Stross is ever-so-much like this. I find myself having to put down my iPad (running Kindle) and just laughing aloud at the way he's inserted some techno-speak into my head, and inserted it without having to go through the loops of having to explain it to me as I already grok it.

My Ma loves his books too, particularly the Laundry series, and I guess he must do the same there as she's an avid reader of thriller and crime novels so I guess she gets the references to spy novels on an instinctive level as well - I too have read my fair share of John Le Carre and I get it too!

Rule 34 though, the follow up to Halting State, is superb! I guess I shouldn't really be reviewing it as I've not quite finished, but there was at least two moments last night where the iPad went down and I just had to sit back and appreciate how he'd got into my head.

Well done Sir!

Wednesday, 20 July 2011

PHP float to money and back again

So I've a need of converting a float from a MySQL query into a currency value so it'll print nicely. THis works a treat:

$dosh = number_format($float, 2);

But bringing it back into the table means I searched and found this way:

$float = (float) str_replace(',', '', $dosh);

Seemed to work a treat TBH ;-)

Sunday, 17 July 2011

Progress Bar written in PHP using GD and TTF fonts

So I had a need of a progress bar to show the user their progress through a series of pages filling in data. I'm sure I'd seen something similar before but I wanted to do it myself - what's more I wanted to use the type-face that I'd used for the rest of the site.

The following script can be called whatever you want but does require a few parameters in it's calling. The parameters are width, height and percentage. The width and height are the dimension of the required image in px.

It does require that a typeface be discoverable - it might be best to have the typeface in the same directory as the script, at least that works for me. It's a little down and dirty and doesn't do any checking - which is should really, especially for the existance of the correct GD library and the correct parameters etc...

<?php
  $percentage = $_GET['percentage'];
  $width = $_GET['width'];
  $height = $_GET['height'];
  $progress = imagecreate($width, $height);
  imageantialias($my_img, true);
  $black = imagecolorallocate($progress, 0, 0, 0);
  $white = imagecolorallocate($progress, 255, 255, 255);
  $grey = imagecolorallocate($progress, 204, 204, 204);
  $lGrey = imagecolorallocate($progress, 221, 221, 221);
  imagefilledrectangle($progress, 0, 0, $width, $height, $black);
  imagefilledrectangle($progress, 1, 1, ($width - 2), ($height - 2), $white);
  imagefilledrectangle($progress, 1, 1, (($percentage/100) * ($width - 2)), ($height - 2), $grey);
  $text = $percentage." %";
  $font = 'Gothicb.TTF';
  $font_size = 12;
  $text_box = imagettfbbox($font_size, 0, $font, $text);
  $text_width = $text_box[2]-$text_box[0];
  $text_height = $text_box[7]-$text_box[1];
  $x = ($width/2) - ($text_width/2);
  $y = ($height/2) - ($text_height/2);
  imagettftext($progress, 12, 0, ($x + 1), ($y + 1), $lGrey, $font, $text);
  imagettftext($progress, 12, 0, $x, $y, $black, $font, $text);
  header("Content-type: image/png");
  imagepng($progress);
  imagecolordeallocate($black);
  imagecolordeallocate($white);
  imagecolordeallocate($grey);
  imagecolordeallocate($lGrey);
  imagedestroy($progress);
?>