Wednesday, 7 December 2011

Rummaging and Pilfering

I've written about Travelodge before, in the previous context I was doing some training for work in London and didn't want to cost them too much money so chose Travelodge. This time I was also conscious of money - not because we're cheap but because I'm almost a stereotypical Yorkshireman - again I'm doing some training for work so Travelodge it was. After all, not all Travelodges can be as utterly crap as the one in London I stayed in last time can they?

You know where this is going don't you?

I'm in the process of giving up smoking but in the meantime I'm reducing my consumption by the use of e-fags from Totally Wicked and as a result the paraphernalia involved gets quite bulky, what with charging equipment for USB, mains and 12V, spare-parts and various e-liquids. So I keep it all in a lovely hessian bag, which I guess is a re-purposed hand-bag curtesy of 'er-indoors.

Thing is that each and every evening I've come back to rest my head after it being crammed full of SalesForce Developer Stuff and the bags been interfered with.

The first time I guessed it might have been knocked over but this evening a zip was left open and the nice needle I use to fill up the e-liquid container was missing... I can only guess why they want a blunt hyperdermic needle!

Needless to say I'll definitely not be going for the cheapest option next time, a little bit of privacy isn't too much to ask for is it? Thankfully I'm with Jeff Jarvis in regards to privacy these days and so live my life in the full expectation that it's lived fully in public... bloody boring too!

Humph!

Wednesday, 23 November 2011

No wikipedia allowed!

Got this wrong and it cost us the wipe out round last night in the pub quiz at The Green Dragon.

If you know without checking wikipedia then I'll be blown!

Who counts the journalist Sheena McDonald and Princess Margarita of Romania amongst his ex-girlfriends?

Hint: It's not Russell Brand (which is who I thought it was, sorry chaps!).

Thursday, 10 November 2011

Walter Zorn's ToolTip

Well blow me!

Walter Zorn's tooltip is and was the bees knees in terms of tool tips and I used it extensively when I was doing my dissertation to provide context sensitive help to users. I tried to use it again recently but couldn't find his site despite it coming near the top of searches for tooltips. Then this morning I was looking for a similar thing to use at work but hopefully based on jQuery and I cam across this site (Walter Zorn’s ToolTip with a JQuery Twist).

I found a reference to him being dead on and then found this on his site:

Walter Zorn, the author of this homepage, died in 2009.
We, his familiy and friends decided to make this page available as a static page again for the friends of his homepages.
Please, be aware, that we didn’t create this homepage or any of its content, and therefore we are not able to give technical support.
Walter made the source codes publicly available under the LGPL license, so we expect that any usage of his programs will be in accordance to this license. Walter Zorns copyright notice must be untouched at all times, and must not be removed.

What a bugger! I had a brief emial conversation with him about his tooltip and he struck me as a really nice bloke, R.I.P. Mr Zorn!

Monday, 24 October 2011

Just don't ask...


0 @M1@ INDI
1 NAME Josef /Fritzl/
1 SEX M
1 FAMS @U1@

0 @F1@ INDI
1 NAME Rosemarie /Fritzl/
1 SEX F
1 FAMS @U1@

0 @F2@ INDI
1 NAME Elizabeth /Fritzl/
1 SEX F
1 FAMC @U1@
1 FAMS @U2@

0 @F4@ INDI
1 NAME Paula /Fritzl/
1 SEX F
1 FAMC @U1@

0 @F5@ INDI
1 NAME Doris /Fritzl/
1 SEX F
1 FAMC @U1@

0 @M2@ INDI
1 NAME Gabriele /Fritzl/
1 SEX M
1 FAMC @U1@

0 @M3@ INDI
1 NAME Joseph /Fritzl/
1 SEX M
1 FAMC @U1@

0 @M4@ INDI
1 NAME Harald /Fritzl/
1 SEX M
1 FAMC @U1@

0 @M5@ INDI
1 NAME Sepp /Fritzl/
1 SEX M
1 FAMC @U1@

0 @F3@ INDI
1 NAME Kerstin /Fritzl/
1 SEX F
1 FAMC @U2@

0 @M6@ INDI
1 NAME Stephan /Fritzl/
1 SEX M
1 FAMC @U2@

0 @M7@ INDI
1 NAME Felix /Fritzl/
1 SEX M
1 FAMC @U2@

0 @F6@ INDI
1 NAME Lisa /Fritzl/
1 SEX F
1 FAMC @U2@

0 @F7@ INDI
1 NAME Monica /Fritzl/
1 SEX F
1 FAMC @U2@

0 @M8@ INDI
1 NAME Alexander /Fritzl/
1 SEX M
1 FAMC @U2@

0 @M9@ INDI
1 NAME Kind /Fritzl/
1 SEX M
1 FAMC @U2@

0 @U1@ FAM
1 HUSB @M1@
1 WIFE @F1@
1 MARR
1 CHIL @F2@
1 CHIL @F4@
1 CHIL @F5@
1 CHIL @M2@
1 CHIL @M3@
1 CHIL @M4@
1 CHIL @M5@

0 @U2@ FAM
1 HUSB @M1@
1 WIFE @F2@
1 MARR
1 CHIL @F3@
1 CHIL @M6@
1 CHIL @M7@
1 CHIL @F6@
1 CHIL @F7@
1 CHIL @M8@
1 CHIL @M9@

Thursday, 20 October 2011

Accessing RDS using HeidiSQL

Whilst looking at family-tree type things yesterday at work (it was for a work-based project, honest!) I remembered that my boss was looking at a way to administer our database on RDS. After reading shed loads of documentation, which said that it couldn't be done or that you needed to jump through loads of hoops I managed it.

Basically what I had to do it connect to it via one of the instances we already have running on AWS.

When we log into RDS we use this command on one of the instances running in order to get access to the mysql commandline:

mysql -u [username] -p[password] --database=[database name] --host=[location of RDS instance]

So for instance when we use puTTY to log into our Development instance we issue the above command to get into the RDS instance - there doesn't seem to be a direct way of accessing it.

HeidiSQL can understand that work-flow so in the Session manager of HeidiSQL create a new Session and call it "RDS" for example.

On the Settings tab select SSH tunnel as the Network Type, enter the host variable from the command detailed above into the Hostname / IP field (i.e. [location of RDS instance]). In our case User is [username] and Password is [password]. We'll keep Port as 3306, keep the Compressed client/server protocol tickbox ticked and enter [database name] in the Databases field.

Next click the SSH tunnel tab. Locate plink.exe on your hard drive or download it (handy link on the tab itself). The SSH host + port is the instance you just copied the command from. So for us it's [some subdomain].[some domain].com, port 22. Username is [not necessarily the same username as above] (the username you use to access the AWS instance). Leave the Password field blank and locate your ppk file (which you converted from your initial pem file using PuTTYgen.exe a while ago). Leave the Local port as 3307.

Click Save and then Open and Bob's your Uncle and Fanny's your Aunt!

Happy browsing of the DB!

Saturday, 15 October 2011

Of demented cats and rapid mice

So her indoors is nigh on always late home from work, which drives me up the wall TBH, she's canny though and keeps track of all the time she's late and takes a day off here and there when the time owing accrues to allow it.

She took yesterday off and did a grand job of servicing the engine on the boat.
Now the cat thinks we're just too stupid to be able to breath let alone hunt so every-so-often he decides to take pity on us and deliver us a mouse (if we're lucky) or a rat (if we're unlucky). Yesterday he decided her indoors needed some exercise while she was knee deep in the engine and covered in oil and goodness knows what (I'm not the most mechanically minded person, as you can tell), so he manages to find an old mouse outside, drops it by her, and saunters off so he can sit in the warm by the fire.

Her indoors looks aghast at the mouse and the cat. The cat takes no notice as he's fallen asleep already but the mouse decides that humans aren't his favourite mammal so buggers off under the fridge.

I get home and feed the cat and after her indoors gets back from visiting a friend we discuss the impending dementia of the daft bloody cat, deciding that we'll leave him be until he starts pissing all over the place.

The evening progresses and off to bed we go but the cat decides that he'll pee where he normally pees, i.e. the engine room, and ends up falling between the boards looking for his litter tray. Once we extricate the daft bugger from between the planks I throw him out and try to settle to sleep.

Sure enough I soon hear the pitter-patter of feet but I figure it can't be the cat as I've not heard the cat flap go. That's it, it must be a bloody great big rat! Lights go on and I look all over, find the cat asleep on his cushion by the fire (bugger knows how he got back in, he stomps about like a baby elephant most of the time).

I'm getting ready to go back to bed when her indoors says she's seen the rat/mouse in the bedroom and it's heading in my direction!

Righty-O, says I, no mouse'll get the better of me!

I stoop down and catch the poor little bugger in my hands, he looks into my eyes, ponders what I'm about to do, pisses himself (unbeknownst to me) and bites down with all the force his little jaws can muster on the bit of flesh between my fore-finger and thumb!

I let out a girly shriek and feel the warm liquid dripping down my arm and beg her indoors to open the front door so I can fling the rabid wild animal outside and try to get some relief before I bleed out (that there mice must have pissed it's own body volume as I'm not joking about the amount of liquid dripping all over).

Mouse thrown I inspect the damage, no blood except where it's welling out of two holes in my palm but I'll be buggered if I get Weil's disease so her indoors goes all nurse and swabs my wounds with antiseptic.

In the meantime all this fuss has upset the cat so he decides that the cushion is no longer good enough and nicks my place in the bed. His ire at being gently moved knows no bounds and he spends the remainder of the night dancing a polka on my head.

Monday, 3 October 2011

Had the need to send a set of hex colour codes to a method which used them to create a chart using Google charts. The initial list was too short so that some of the colours ended up being repeated and the data became difficult to read. I pottered around the code base and "borrowed" some functionality from the boss. The following code is what I used to test it. By all means copy and paste it into a blank file and give it a try. Works a treat!
 <!DOCTYPE HTML>  
 <html>  
  <head>  
   <title>Palette Playing</title>  
   <script type="text/javascript">  
    var palette = "000000,0000FF,00FFFF,00FF00,FFFFFF,FF0000,FFFF00,FF00FF";  
    document.write(palette.split(',').splice(0, 4).join(','));  
   </script>  
  </head>  
  <body>  
  </body>  
 </html>  
This will produce "000000,0000FF,00FFFF,00FF00".

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);
?>

Sunday, 10 July 2011

R.I.P News of the Screws

So this week the news has been full of the News of the Screws phone hacking thing. I'm not overly sure that such misuse of the term "hacking" is appropriate — from my somewhat limited understanding it was merely a question of investigators using the default passcode to listen to a mobile phone users voice mail…?

Whether that deserves the application of the term "hacking" rather than simply being "sneaky" I'm not too sure, neither am I sure that the victims of the alleged hacking aren't overly sensible — surely if everyone was given the same pin when issued a debit/credit card they would take the first opportunity to change that there pin wouldn't they? Not 100% analagous but I think it's similar enough to bear consideration.

Anyway… so News International decided to sweeten things by closing down the News of the Screws early (what's the betting that the Sun on Sunday was going to be launched soon anyway — and what's the betting that it'll have a similar roll to the News of the World as well?), not least because they're trying to take over BSkyB and want to avoid any hint of scandal as well as show proper contrition.

That does leave us with something of a quandary about privacy though… not too long ago the news was full of super-injunctions — the method by which the rich and/or famous were able to keep their actions out of the press — and the furore that that evoked when made public. Now we've got allegations of investigators using underhand/sneaky methods of obtaining information which anyone else could obtain if they had a total dis-regard for the privacy of others and a morality bypass.

We've also got the promise that the coalition will launch an enquiry — does anyone else see the link here?

Admittedly I'm something of a conspiracy-theory aficionado but wouldn't it be interesting if we threw the baby out with the bath-water when the enquiry returns suggestions that privacy be upped a notch, thus doing away with the requirement for super-injunctions?

What if, by our own carelessness, we ushered in stricter privacy laws in order to protect those of us who're too trusting or not technically savvy enough to change their pin?

I don't know about the legality of the phone "hacking", though I suspect it isn't particularly legal, but I do know that the next time our Dear Leader has a meeting with — just as a for-instance — Rupert Murdoch or — another for-instance — Rebekah Brooks then I'd like to be told! I dare say though, that in the future such reporting might be considered illegal and we'd all be the poorer for it being so.

I'm not defending the News of the Screws (though I did sort of enjoy reading it on a night-shift) but I am wary about what this might lead to — if anything I really, really don't want legislation to be created as a result, rather I'd like less legislation. I'd like people to be a little more aware of their responsibilities in regards to their own security. I'd really, really like News International to lose all investment and market share — I for one am thinking of boycotting anything which advertises in those outlets, I'd suggest that others do as well, I just need a register of who advertises with them now…? (Just hope it's not Tesco or I'll starve!)

Buying anything from News International is something I'll also avoid now! Thankfully I don't buy a paper but what else do they do?

Sunday, 26 June 2011

Chased by a herd of cows

I've mentioned before the penchant 'er-indoors has for things that make odd, often random, noises here. Thankfully there is no longer a killer machine in the bathroom! Ohh no, I'm safe from being annihilated by Summer Glau (imagine me rubbing my thighs and leering wickedly right about now)... now I've got to contend with being chased by cows!

For some reason, only know to 'er, she decided that it'd be useful to have the SatNav moo when the car is going over the speed limit!

I've given up trying to understand quite why she does these things... perhaps it's because she's just had a speeding ticket (that makes 2 now)? As I say, I don't want to know why she did it, I just want to know how to turn it off as, whenever I'm in the car, it sounds like I'm being chased by a herd of cows - a herd of cows actually in the car!

Yesterday though I solved the problem, yesterday I realised that it only moos when you go over the limit, it doesn't keep on mooing while you're over the limit, just when you go over a given threshold. Happy days are here with consistant speeding!

Either that or I could keep within the speed limit?

Saturday, 4 June 2011

So on Wednesday I went to empty my loo. Once or twice a week a put a full cassette of waste on the back of my bike, sling my pannier on my shoulder, and ride 20 minutes or so up the river bank and empty our effluent into the sluice at Jesus Green. 

I've been doing this for more years than I care to remember and now we've 3 cassettes I can afford to be a little blasé about my routine. Wednesday though I had only a little amount of stuff to put in the pannier so thought that it'd be a good day to empty the cassette. 

Anyway I got there and found the door to the sluice open. This is annoying but fair enough as the lock has been broken for a while and after phoning the Cambridge City Council and complaining about it once to be confronted with it being replaced with a lock which no one had a key to I've come to the conclusion that, at the end of the day, it's better to have a door which won't lock than a door which won't open. 

I do though, every time I go past and notice it swinging open, use a dog end to wedge it shut. Not the best solution I know, but security through deception is better than no security at all.

I emptied my loo but nothing went down the sluice (that might not be the correct phrase - coming from the world of nursing as I do though - it looks a lot like a sluice in a hospital), but it wouldn't go down! Not only would it not go down but it started bubbling and splashing all over the shop! I've not got the most robust nature when it comes to bodily fluids at the best of times but I challenge anyone to be relaxed at a pot of shite bubbling and splashing! 

I've got a thing whereby I choke if anything constructs my chest or neck, even to a minuscule degree so I'm doubled up and dry heaving from the pannier being around my shoulder and then these's some sort of gelatinous bubbling monster growling at me from the pan smelling like we've been eating dead things for the past half week! Not nice!

So I leave the sluice without rinsing out the cassette - which I like to do so that we're at least pretending to be hygienic - and phone the Cambridge City Council again to suggest that someone unblock the sluice. They assure me that someone will do so and take my phone number. Come the end of the day and no phone call so I check anyway. Guess what? Still a bubbling brown mess in the pan (what had I been eating?) and a handwritten note from another boater saying that s/he too had phoned the council at 14:00hrs and been assured that the problem would be resolved in a couple of hours. It was 3 hours later when I came past.

I pay my mooring fee and I welcomed the Cam Conservancy when they visited boats with the Environment Agency and talked about the importance of not emptying effluent into the Cam. I've been faithfully emptying mine into the sluice, as I've already said, for more years than I care to remember. Cambridge attracts an awful lot of visitors on boats and the boating community is a vibrant part of life in Cambridge. you'd think that making it possible for locals and visitors both to not put our shit in the river would be an important thing for the Council to understand. 

Guess not.

Saturday morning and I've been up there again with a full cassette and nothing happening! I've come back with it full because, frankly, I can't be doing with heaving again. Strawberry Fair is on today and I want to save my heaving for the beer tent later on! 

Perhaps I'll phone again on Monday and suggest that when they unblock the loo they might want to look at fixing the lock so that random piss-heads wandering on Jesus Green can't decide to shove random crap down the sluice and block it again... At least I assume that that is what happened!

To an extent I'm all for the big society but after clearing  shite professionally for donkey's years I draw the line at unblocking drains filled with shite and goodness knows what other shite (see what I did there?). Running the risk of getting a needle-stick injury at my age is no fun at all.

We've a cassette and a half empty so I'm hoping that it'll be fixed by the end of next week or I'm not sure what I'll do. Perhaps I should start flinging it in the river or throwing it at the coaches using loudhailers outside the boat at 06:00hrs? Perhaps it should join the cow crap all over Stourbridge Common... I could even dry it out on the roof and burn it when it gets cold on an evening?

Anyway, rant over. I'll keep you updated.

Friday, 27 May 2011

100%

100% on LEGO® Pirates of the Caribbean The Video Game. Now what to do?

Can't play Plants vs. Zombies anymore as 'er-in-doors has taken my iPad away to play it!

Guess that means I'll have to code now, that and investigate the coolness that is Node.js! Think that I'll try and get it to parse XML based web services and throw out JSON...? That'd be cool, especially if I could do some caching on the server... ho hum!

Thursday, 5 May 2011

Travelodge - City Road, London. Not Priceless

A room that smells of piss, a bath only big enough for my feet, a room key that wouldn't work, 'orrible young people and ladies of negotiable affection being in the - I use the term loosely - hotel, not having my phone charger, taps that give me a shower when I want to turn them off, boarded up slums outside my window, utter shite on the telly, and internet connection form the darkest days of dialup, one of the nastiest pubs and a Tesco's Express outside... all these things, and so many more, make this quite possibly, not in the least priceless.

At least I'm not paying for it... ;-)

That and the Tesco's Express selling pre-mixed JD and coke, minus the calls from work as something died yesterday, means that I'm not an overly happy camper!

Still, the AWS Deep Dive training means that I'm not terminally suicidal!

Tuesday, 3 May 2011

CSS shorthand

There's all sorts of CSS shorthand available online and I get confused easily. This is what is meant by the differing formats of CSS shorthand:

  • .someClass { padding: [top], [right], [bottom], [left] }
  • .someClass { padding: [top], [right & left], [bottom] }
  • .someClass { padding: [top & bottom], [right & left] }
  • .someClass { padding: [top, right, bottom & left] }

So we can have 1, 2, 3 or 4 entries after the property, this is represented in the list above by square brackets, these can be whatever your chosen values are (e.g. px, em, % etc.)

Monday, 4 April 2011

Castles in the air

In a previous life I was a psychiatric nurse. whilst I was doing my training I came across a cool quote to do with neurotics, psychotics and psychiatrists. I'll repeat it below. It's attributed to Jerome Lawrence, a famous American author and playwright.

"A neurotic is a man who builds a castle in the air. A psychotic is the man who lives in it. A psychiatrist is the man who collects the rent."

Now in a previous life my Dad was a structural engineer. One of the things he used to say about his job was that when architects came up with a cool looking design for a building the structural engineer would take those pretty pictures and make sure the finished, pretty, building wouldn't fall down.

What, you may be wondering, is what my old man's and my previous jobs has to do with what I'm doing now in terms of being a developer...

Well, I'm tasked with making things work, I'm not always privy to the decisions that go into why they should work, but I have to make them work!

This is lovely!

I get told to do something, sometimes I get told what techniques to use to do that thing - more often than not I get to decide what techniques I get to use.

So I go off and to that thing. If it's a web-app I get to decide on what mix of server- and client-side technolgies to use... being something of a fan of ajax I usually plump for JavaScript.

I use JavaScript just so long as it doesn't slow me down too much. I'll write a script that takes every element of a page which needs content and get it dynamically, until I'm making something silly like 150 ajax calls, and then I'll realise that the server would be better off making those calls before the page ever reaches the client. PHP on the server is an order of magnitude quicker than JavaScript on the client!

Thus I get to my theory of gradual optimisation. Do something so that it works - it might not be pretty but it'll work - and then squeeze every last bit of it until it's a lean, mean, web-app. That'll often mean making changes to the page structure so that the bits that were filled in dynamically are removed if there's nothing to process but hey-ho!

Friday, 4 March 2011

Random Minute Generator

Had a need to turk some numbers for putting into a DATETIME field in MySQL so came up with this little script for generating a set of minutes:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
  <head>
    <title>Random Minute Generator</title>
    <script type="text/javascript">
      window.onload = function addNumbers(){
        for(var x = 0; x < 217; x++){
          if (document.createTextNode){
            var myNumber = Math.floor(Math.random()*60) + 1;
            if(myNumber < 10){
              myNumber = "0"+myNumber;
            }
            var myText=document.createTextNode(myNumber);
          }
          document.getElementById("myDiv").appendChild(myText);
          var newLine=document.createElement('br');
          document.getElementById("myDiv").appendChild(newLine);
        }
      }
    </script>
  </head>
  <body>
    <div id="myDiv">
    </div>
  </body>
</html>

Do enjoy if you use it and perhaps leave a comment...?

Thursday, 3 March 2011

mod_expires on Ubuntu Server

I love Firebug, it's really the only reason I use Firefox rather than Chrome as my main browser.

I particularly like Google's Page Speed add-on for Firebug - except that I always ended up scratching my head about the "Leverage browser caching" messages I heard. This hasn't been a major problem as I've usually been working on a shared server - so couldn't do anything about it. After setting up an Ubuntu Server in EC2 however I realised that I could do something about it. After having a quick search around I found this post on Absolutely Tech which led me to this post on Absolutely Tech which enabled me to install mod_expires.

Basically the process I used was to check to see if mod_expires was installed using phpinfo(), after realising that it wasn't I did sudo a2enmod expires followed by sudo /etc/init.d/apache2 restart. Now I can cache all the images on my site by adding this to .htaccess in my root directory:

# Turn on the Expires engine
ExpiresActive On
 
# Expires a week after client accesses the file
ExpiresByType image/jpeg M604800
ExpiresByType image/gif M604800
ExpiresByType image/png M604800
ExpiresByType image/x-icon M604800

Job's a good'un!

My next job is to check out Google's mod_pagespeed.

Thursday, 27 January 2011

HTML Entities Decoder

So I was looking for some some lyrics... can't actually remember why now TBH. When I found them the site I was on refused to let me copy them so I thought I'd be clever and check the source... only to discover that the individual characters in the lyrics had been converted into their respective HTML Entities.

Arse!

I copied the lyrics anyway and googled for a way to convert HTML Entities back into characters and found a site that did what I wanted but with an overhead of having to do a Captcha... no fun!

So I wrote my own, the result is the HTML Entities Decoder. It uses jQuery and a nifty JSON object to do the calculation so I don't really feel the need to control access - enjoy!

Friday, 21 January 2011

Activated charcoal knickers... please!

'er indoors, who very rarely is, has the most gad awful wind!

I'm not saying this just to be rude; I feel like I've got to justify myself as I've often been accused of smelling like a skunk - she takes the biscuit. Not only does she smell like a skunk she smells like a skunk crawled up there a month or two back and died due to the existing smell, adding it's own distinctive aroma to the original stench.

I'm saying this because, thanks to my insomnia, I was up at 03:30hrs working, I finished what I was doing at about 06:30hrs and decided to get a little more sleep.

I might have said this before but the feel of getting into a nice warm bed and spooning next to a lovely warm body is just about the best thing in the world to me.

I was loving it this morning as it'd got a little cold while I was up and the throw was atop the bed as well as the monstrous quilt but then...

A quick eruption of gas were not only heard, but felt on my upper legs. I'm not sure why - perhaps it's some sort of masochistic streak or something - but I wafted the quilt in order to sample the bouquet. How I wish I hadn't!

I remember as a kid getting into my parents bed when I was little on a Saturday morning and being somewhat comforted by the smell of my parents. This wasn't that smell!

This smell was almost indescribable in it's vileness, in fact it was indescribable! Imagine the worst smell you've ever smelt and double it and you'll be getting close!

As I'm gagging she starts to chortle and says, "You shouldn't have put your cold legs on mine"! She took no notice of my reasoning about reasonable force and continued to giggle!

Quickly clamping the quilt down I decided that that was that and I wasn't disturbing the quilt again as there was no way I was going to submit myself to that again! I was going to submit to voluntary cataplexy or some sort of self-induced sleep paralysis rather than risk a waft of that evil smell again. I was trying to calculate how long before the stench had either evaporated or been absorbed by the bedding (or eaten it's way into my pores) when a further two eruptions occurred! I wasn't aware that I could grab material that hard but there was no way I was going to relinquish my hold on the quilt, there was no way that more of the miasma was going to escape when...

"I'm getting up now, are you stopping there?", and it - and her - escaped!

Helped me get back to sleep for an hour though, I'm only grateful that I woke again at all!

Friday, 14 January 2011

What've you got installed?

A colleague running OS X asked me to run this command on my Win 7 machine today in order to test an audit idea he had: WMIC product > wmic.txt, after a fair old wait I had a nice text file with a list of all the software installed on my machine... how cool!

Thursday, 13 January 2011

I'm hurt!

Dilbert.com

Simple backup of a directory on Ubuntu Server

So I set up an Ubuntu Server instance but need to backup my development folder on a regular basis. I've got SSH access so can access it via PuTTY and FileZilla. In PuTTY I use tar -cvf [YYYYMMDD].tar [directory]/, when it's done I use gzip [YYYYMMDD].tar and then use FileZilla to copy across the resulting [YYYYMMDD].tar.gz file.

Now I just need to remember to do this at the beginning and end of each day!

Or:

#!/bin/bash
# declare DATE variable
theDATE=$(date +%Y%m%d)
tar -cvf $theDATE.tar www/
gzip $theDATE.tar

Thursday, 6 January 2011

XSS and the BOM (“”)

So I was working on a script to get the Latitude and Longitude from postcodes using Bing. I set up a simple page with a box where a postcode could be entered, Upon a button being pressed the postcode is checked using the fantastic UK Postcode Validation JavaScript by John Gardner. I then used jQuery to query Bing but ran into problems thanks to ajax restrictions on cross site scripting, I got over that using a PHP proxy on the same domain that basically echoed the XML that I wanted originally. Thus:

<?php
  header ("content-type: text/xml");
  header ("charset: utf-8");
  $bingURI  = "http://dev.virtualearth.net/REST/v1/Locations/UK/";
  $apiKey   = "?o=xml&key=yourKeyHere";
  $file     = file_get_contents($bingURI.rawurlencode($_GET['postcode']).$apiKey);
  echo $file;
?>

All well and good except that there was a rather odd set of glyphs () at the beginning of the echoed XML… after a fair bit of searching I discovered that it was the BOM, whatever it was I didn't want it! After a little more searching I found this PHP function from Philipp Michels:

<?php
function rmBOM($string) {
  if(substr($string, 0,3) == pack("CCC",0xef,0xbb,0xbf)) {
    $string=substr($string, 3);
  }
  return $string;
}
?>

Which worked a treat and allowed the XML to be parsed properly!

The result is here: http://drmsite.com/postcode.html.

Wednesday, 5 January 2011

Setting up Ubuntu in the cloud with ElasticFox, PuTTY and FileZilla

My mornings work! YMMV, worked for me at time of posting!

  1. Install PuTTY and PuTTYgen from http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html.
  2. Install FileZilla
  3. Fire up Firefox and install ElasticFox.
  4. Re-start Firefox and feed ElasticFox your credentials.
  5. Generate Key Pair on the KeyPairs tab. Download the file and fire-up PuTTYgen.
  6. In PuTTYgen hit Conversions » Import key. Select the downloaded .pem file then hit Save private key, hit Yes and save the .pkk file where you'll remember where it is.
  7. In ElasticFox hit Create Security Group (green plus on the left-hand side) on the Security Groups tab. Give it a name and a description and select "I will authorise protocols for this group as needed", hit Create Group.
  8. With your new group selected on the left-hand side hit Grant Permissions (green tick on right-hand side). Select SSH from the drop-down, select Network and enter 0.0.0.0/0 then hit Add. Repeat but select HTTP from the drop-down, again add 0.0.0.0/0 as the Network address.
  9. Still in ElasticFox hit the Images tab and enter "20101225" in the top-left text-box. Select the "ami-339ca947" image then hit Launch Instance(s) (green start-up on top pane).
  10. Select your Key Pair in the KeyPair option and move over your Security Group to the right using the arrows below - but other ones apart from yours on the left.
  11. Hit Launch.
  12. In the Instances tab right-click your instance and select Copy Public DNS Name to clipboard.
  13. Fire up PuTTY, crtl-v into Host Name, on Category pane select SHH » Auth then browse for you .pkk file. Finally go back to Session on the Category pane, enter a name into Saved Sessions and hit Save.
  14. Click Open on PuTTY and if all went well then there should be CLI. Login as "ubuntu".
  15. Type sudo tasksel --section server like it tells you to. To select something move with the arrow keys and select using the spacebar. Select LAMP server and let it roll.
  16. ctrl-v into the address bar of a new FireFox tab... It works!
  17. Fire up FileZilla and hit Edit » Settings.... On the Select page: pane hit SFTP, then Add keyfile... button. Browse to and select your .pkk file again, hit OK.
  18. Next go File » Site Manager..., hit New Site, give it a name and then ctrl-v address into Host: textarea on the right. Server Type: is SFTP, Logon Type is Interactive and User is ubuntu. Hit OK.
  19. Select your site from the drop-down beside the little Site Manager icon on the top left under the menu strip. Navigate to /var/www and you should see the index.html file.
  20. 'nuff said, have a coffee and a fag!

M255 Results

These came mid-December but I forgot to document them:

Course M255 Object-oriented programming with Java End Date: October 2010
Scores OES: 63 OCAS: 92 (Substitution applied)
Result Grade 3 Pass

Not too bad but the exam was a let down Sad smile

Sunday, 2 January 2011