- Bromsgrove hockey 3xi vs Old Wulfs. Lost 11-2. #
- I'll never grow up…. (thanks @carolinegoodwin) http://twitpic.com/41dg39 #
- I'm sure that drinking one more beer will beat this cold into submission … #science #alcohol #germs #
- Ping me on @pingchat at ID: david-goodwin – Send text, photos, videos, and other media to my phone for free! http://pingchat.com #
- β@madeupstats: 40% of foreigners are racists*.
*Source: BNPβ #
- Yep, as predicted, Ann Summers are making the most of 'The Year of the Rabbit'. #
- …. Answer: soft play place. #
- Three guesses for what a "children's experience centre" is….. #
- 0b100000 aka 0x20 aka 2^5 aka 32. #
- β@madeupstats: David Cameron isn't out of touch: A third of his closest friends are unemployed (Heirs and landowners, mostly)β #
- Customer offered to pay me in beer. I declined, but he's still sending a case through. Result! #
- Walking. It's so slow. #iMissMyBike #
- The chain just snapped on my bike π It's only ~1 month old. Decathlon–
Luckily I was just arriving at my destination. *sigh*. # - β@birminghampost: Worcester hospital pays compensation to parents of stillborn baby http://bit.ly/fuFEVJ " #
- A mouse took a walk in a deep dark wood. A fox saw the mouse, and the mouse looked good….. "come and have tea in my underground house"… #
Automated snapshot backup of an Amazon EBS volume
I found the following Python script online, but it didn’t really work too well :
http://aws-musings.com/manage-ebs-snapshots-with-a-python-script/
EBS – Elastic Block Storage …
I had to easy_install boto, to get it to work.
I’m not sure the Debian python-boto package in Lenny is up to date.
Anyway, $server now has :
from boto.ec2.connection import EC2Connection
from boto.ec2.regioninfo import RegionInfo
from datetime import datetime
import sys
# Substitute your access key and secret key here
aws_access_key = 'MY_AWS_ACCESS_KEY'
aws_secret_key = 'MY_AWS_SECRET_KEY'
# Change to your region/endpoint...
region = RegionInfo(endpoint='eu-west-1.ec2.amazonaws.com', name='eu-west-1')
if len(sys.argv) < 3:
print "Usage: python manage_snapshots.py volume_id number_of_snapshots_to_keep description"
print "volume id and number of snapshots to keep are required. description is optional"
sys.exit(1)
vol_id = sys.argv[1]
keep = int(sys.argv[2])
conn = EC2Connection(aws_access_key, aws_secret_key, region=region)
volumes = conn.get_all_volumes([vol_id])
print "%s" % repr(volumes)
volume = volumes[0]
description = 'Created by manage_snapshots.py at ' + datetime.today().isoformat(' ')
if len(sys.argv) > 3:
description = sys.argv[3]
if volume.create_snapshot(description):
print 'Snapshot created with description: ' + description
snapshots = volume.snapshots()
snapshot = snapshots[0]
def date_compare(snap1, snap2):
if snap1.start_time < snap2.start_time:
return -1
elif snap1.start_time == snap2.start_time:
return 0
return 1
snapshots.sort(date_compare)
delta = len(snapshots) - keep
for i in range(delta):
print 'Deleting snapshot ' + snapshots[i].description
snapshots[i].delete()
And then plonk something like the following in /etc/cron.daily/backup_ebs :
for volume in vol-xxxx vol-yyyyy vol-zzzz do /path/to/above/python/script.py $volume 7 "Backup of $volume on $(date +%F-%H:%m)" done
Which keeps 7 backups for each volume with a time/date stamp in each description.
Twitter Weekly Updates for 2011-02-13
- Cat poo on the windscreen. :-/ #
- I leave Rowan with his mum and look what happens ! http://twitpic.com/3z4gdn #
- β@ChairmumMiaow: Bribed toddler to leave me alone to paint my nails by doing his π http://yfrog.com/h0wlytjj β http://twitpic.com/3z17ek #
- Bromsgrove 3 xi hockey vs bridgenorth … We lost 10-0 π #
- It's the weekly "where is everyone? We're 2 men down" pre-hockey match discussion … #
- I think http://creativespring.co.uk need some help with the SEO service they claim to offer. #fail #imageAsHomePage #
- β@moobert: ♥ yo ho ho by Captain Dan & The Scurvy Crew #lastfm http://bit.ly/86WlBβ #
- Why is a customer asking me to delete their emails for them? Shift+arrow key too much work? #whatAmIMissing #
- β@w00teh: on #Nokia #039;s choices: http://i.imgur.com/dMX1f.png #epocalypse #feb11β #
- β@madeupstats: Costing only Β£85 per year, Ugg Boots are statistically the most reliable and best value female contraceptive.β LOL #
- "The train clock in bed" … What does
My son dream about ? # - Wondering how common it is for people to mis-spell their surname when sending an invite to linkedin….. #
- β@chedderz: The best and most appropriate name for a car ever – spotted in my work car park – genius http://yfrog.com/h71pzudjβ #
- β@GeneHunt: I find myself looking down on women who insist on showing their cleavage.β #
- .@aypok's latest purchase: Sega master system scope 3d set …. #sega #geek #retro http://twitpic.com/3xq049 #
- Crap start to the day: Internet banking login card has magically stopped working. #lloydstsb I hate you. #
- What does it say about mr if I dream of eating whiskers cat food? The taste seemed quite vivid when I woke. Yuck. #
- Now I'm wondering where the nut, which was on the floor, I saw the other day has gone…. #bike #
- Guess I'd better get cycling…. Perhaps an albums worth. Ocean machine is worth it π #
- A bread free day! Whatever next? Let's just gloss over the chocolate work biscuits ('customer') & the costa hot choc & half gingerbread man #
- Jobcentre a'review': "Had a useless trainee and a woman with the typing speed of a toddler giving me bad advice!" (no, I'm not signing on). #
Twitter Weekly Updates for 2011-02-06
- Upgraded my iphone4 to iOS 4.2.1 and re-jailbroken; exceedingly quick and easy process – thanks to greenpois0n etc. #
- oooh, looks like Squeeze is very close… good luck #debian #
- β@GeneHunt: My girlfriend says I'm ignorant. ….. I've absolutely no idea what she's talking about.β #
- What sort of idiot walks around in the dark & head-butts a corner. Oh wait … #PleaseDoNotBruise http://twitpic.com/3wjig4 #
- Nearly midnight is perhaps the wrong time to think about upgrading and re-jailbreaking my iphone. Until tomorrow…. #
- http://www.youtube.com/watch?v=oJagxe-Gvpw 'World's worst hacker'…. #
- Hopefully I'll manage to do the Aberystwyth -> Kington bike ride this year at least, and maybe next year London -> Paris or something abroad #
- 10th anniversary Dyfi Enduro registration opens on 10/02/2011. Almost regretting being mtb-less now http://t.co/vA4QJpQ #
- Interesting experimentation with 4square's API this evening #PHP #4sq #
- Wish 'normal' people would stop using the disabled / baby change toilet. Lazy … Grr. Grr. #
- Year of the Rabbit. I bet Ann Summers will make full use of this for marketing …. #
- Yes apple, I'm obviously going to read those 50+ pages of t&c's you've asked me to agree to on my phone. #
- Call to back UK's hi-tech talent – http://www.bbc.co.uk/news/technology-12326688 (software / games ) #
- β@scottsigler: Time for Rocket Fuel. Recipe: equal parts strong coffee, sugar and Red Bull…" @stormysan @aypok u r wimps in comparison #
- Happy mailman day. #
- Note to self: when leaving windows open to air place of residence avoid leaving the fan heater turned on. #fail #
- I wonder what significance there is to the tiles on my bathroom floor becoming loose. #
- Looks like I have a sea faring new employee … http://twitpic.com/3v4var #
The Post Office
Earlier today, I went to the Post Office in Bromsgrove, to buy some Euros.
The conversation I had with the minion behind the counter is paraphrased as follows :
- Me: Hi, I’d like to buy $x euros, please?
- Her: How do you wish to pay?
- Me: By card? <<waves debit card at her>>
- Her: We’ll need proof of ID (Passport etc)
- Me: <<sighs>> Why?
- Her: It’s an anti-fraud thing, you don’t think like a criminal do you?
- Me: Errr? <<WTF?>>
- Her: If you’ve stolen a card, the first thing you do is try and withdraw money using it … blah blah blah fraud blah blah blah ….
- Me: But, it needs a PIN number to be used…?
- Her: It’s ok, <<gestures at the card reader infront of me>> – that acts like a cash point. You can withdraw the right amount of cash to pay for your euros using it…
- Me: <<WTF?>>
- Her: Now, just put your card in the reader and type in your PIN when requested….
- Me: <<types in pin>>
- Her: <<hands over euros>>
I know I’m often a bit dim, but I’m failing to understand the ‘process’. Wasn’t I meant to have proof of ID to buy euros using my debit card?
How is me “withdrawing” cash for her, any different to me paying by card – especially when the process from my point of view is IDENTICAL.
PHP Serialization & igbinary
Recently I’ve been trying to cache more and more stuff – mostly to speed things up. All was well, while I was storing relatively small numbers of data – because (as you’ll see below) my approach was a little flawed.
Random background – I use Zend_Cache, in a sort of wrapped up local ‘Cache’ object, because I’m lazy. This uses Zend_Cache_Backend_File for storage of data, and makes sure e.g. different sites (dev/demo/live) have their own unique storage location – and also that nothing goes wrong if e.g. a maintenance script is run by a different user account.
My naive approach was to do e.g.
$cached_data = $cache->load('lots_of_stuff');
if(!empty($cached_data)) {
if(isset($cached_data[$key])) {
return $value;
}
}
else {
// calculate $value
$cached_data[$key] = $value;
$cache->save($cached_data, $cache_key);
}
return $value;
The big problem with this is that the $cached_data array tends to grow quite large; and PHP spends too long unserializing/serializing. The easy solution for that is to use more than one cache key. Problem mostly solved.
However, if the site is performing a few thousand calculations, speed of [de]serialisation is still gong to be an issue – even if the data involved is in small packets. I’d already profiled the code with xdebug/kcachegrind and could see PHP was spending a significant amount of time performing serialisation – and then remembered a presentation I’d seen (http://ilia.ws/files/zendcon_2010_hidden_features.pdf – see slides 14/15/16 I think)Β at PHPBarcelona covering Igbinary (https://github.com/phadej/igbinary)
Once you install the extension –
phpize ./configure make cp igbinary.so /usr/lib/somewhere #add .ini file to /etc/php5/conf.d/
You’ll have access to igbinary_serialize() and igbinary_unserialize() (I think ‘make install’ failed for me, hence the manual cp etc).
I did a random performance test based on this and it seems to be somewhat quicker than other options (json_encode/serialize) – this was using PHP 5.3.5 on a 64bit platform. Each approach used the same data structure (a somewhat nested array); the important things to realise are that igbinary is quickest and uses less disk space.
JSON (json_encode/json_decode):
- JSON encoded in 2.18 seconds
- JSON decoded in 9.83 seconds
- serialized “String” size : 13993
Native PHP :
- PHP serialized in 2.91 seconds
- PHP unserialized in 6.43 seconds
- serialized “String” size : 20769
Igbinary :
- WIN igbinary serialized in 1.60 seconds
- WIN igbinrary unserialized in 4.77 seconds
- WIN serialized “String” Size : 4467
The performance testing bit is related to this Stackoverflow comment I made on what seemed a related post
Twitter Weekly Updates for 2011-01-30
- Hhh: β@madeupstats: Xprts hv wrnd by currnt trnds vwls cld bcm xtnct by 2050.β #
- Bromsgrove 3rd hockey vs khansa(?) (Warwick). We lost 3-1 π we were winning 1-0 at half time π #
- RT: @GeekStats: ~20% of Facebook users state their relationship status. 40% = "single"; 3% = "it's complicated" http://bit.ly/gnuFiH #
- It seems my turbo trainer doesn't wake toddlers up. This is good. #ExercisingInSecret #
- β@StormySan: Apparently the phrase 'Like a red rag to a bull' isn't appropriate to describe anger during PMS.β <- good thing Lyne in today #
- Beware Bromsgrove; I am slowly claiming back mayorship of the town centre. Competition will be squashed….. #4sq #
- My random PHP serialization performance note – http://bit.ly/hug5bY – igbinary vs serialize vs json_encode (result: igbinary is best). #
- Batman and superman are patrolling Bromsgrove today. Have no fear citizens. #
- Now, onwards to meet @zookx … Interesting that they're in a previous office of ours. Still – No excuse for failing to find them. #
- My minions accepted their payrise without fuss. Perhaps I'll try a negative rise next time and see if they notice. #evil #employer #
- I'm always slightly surprised when I come across a non supported / non LTS ubuntu release being used in production. #
- This morning has been mostly Linux sysadmin (virtual host setup, backup jobs, updating stuff). Sometimes the boss let's me code. #pray #
- Yes, in the end it's beautiful, so beautiful…. You are a puppet. I am a puppet. We are all puppets. #guessTheSong #
- .@bhamsouthpolice – βDonβt forget that our 24 hour tweet-a-thon starts tomorrow morning at 7.00am. ….β #
- Customer: can you backup server, here's the root u/p. Me: err I have a few questions first …. #Linux #support #sysadmin #
- β@StormySan: Ahhh, the first Monkeys call of 2011. Good start to the day :)β LOL-telephony #phonespam #
- I'm such a gentleman, lending women money so they can get home from a night out. #StretchingTheFactsALittle #
- β@madeupstats: Let's hope the Daily Mail doesn't get hold of this: almost half of Britain's schools perform below average.β Rotfl. #
- β@StormySan: !in_array($bitch, $99problems) #technologysongs
Twitter Weekly Updates for 2011-01-23
- Slave labour / someone likes cleaning. http://twitpic.com/3spmzo #
- I <3 chocolate rice crispy cake. #
- Turbo trainer found. Now what about the bike ? (volare elite esto mag something.) #
- Bromsgrove 3rds vs West Brom – lost 2-0. I played the second half. Meh. #
- Must learn to not leave home without my hockey stick when going to play hockey…. #
- It appears my body is unwilling to give up it's blood easily. #
- Blood donation o'clock. #
- "I will feel better having you there; that is what a relationship is; we average our misery" #house #
- We can get FTTC 'Internet' – 39/9 mbps down/up (~3x faster, ~2x price than now) but with BTInternet – think i'll stick with BeThere for now #
- Browsing a Samba share from OSX seems exceptionally painful, especially if OpenOffice is involved. Grr… #
- I've had enough of Dublin Core, OpenGraph and EGMS meta tags for this morning. Next ticket please. #
- Ah. The yellow pages is finally letter
box size. Took "them" long enough to figure that one out ! # - Who stole my minions and replaced them with muppets that listen to rap music all the time? #AliensAreHere #
- I was a bit surprised to see piles of 'snow' still in Tesco's car park earlier (Redditch). #
Javascript Linting…
Suffice to say, my minions write a quantity of Javascript. And testing it isn’t all that easy. While rummaging the internet, I came across @NeilCrosby‘s FrontEndTestSuite which aims to automate e.g. w3c validator checks and so on – there will be more on that later I suspect once I get it working.
Anyway, the first part I wanted to do is to run a Javascript linter on things…. as I haven’t really come across these before.
I’ve found two approaches :
Install JavascriptLint
see http://www.javascriptlint.com/download.htm –
Build instructions for the lazy – uncompress/extract the files from the archive, then :
- cd jsl-0.3.0/src
- make -f Makefile.ref
- cp Linux_All_DBG.OBJ/jsl /usr/local/bin
Usage looks a bit like :
jsl -process $file
As per the ‘help’ documentation, it returns different exit codes depending how things went (e.g. 0 – everything good; 1 – warnings etc).
Aside from the annoying compile step, this seemed the easiest to setup, and friendliest to use from the command line.
Mozilla’s Rhino & JSLint.js
This is the approach expected by Neil’s TestSuite above (more soon, perhaps).
Download the Mozilla Rhino thing – for me this is a simple ‘apt-get install rhino‘ YMMV.
- export CLASSPATH=/usr/share/java/js.jar
- java org.mozilla.javascript.tools.shell.Main /path/to/some/javascript.js
Again, this will give some sort of return error code if it can’t parse it – but it’s not yet running through jslint… which is what we really want.
Firstly, download JSLint.jsΒ via https://github.com/douglascrockford/JSLint/blob/master/fulljslint.js (click on the ‘raw’ button)…
- (Requires CLASSPATH thing from above)
- java org.mozilla.javascript.tools.shell.Main
- load(‘fulljslint.js’);
- to_test = readFile(‘/path/to/javascript/file/to/test.js’);
- result = JSLINT(to_test, null);
If ‘result’ is ‘false’ then you can inspect the errors via JSLINT.errors.
Next up, getting frontend-test-suite running, or something based upon it….
Twitter Weekly Updates for 2011-01-16
- Playing for the other team…. #hockey #
- Nails filed. Breakfast eaten. Hello Sunday…. #
- Only 3 doors left to open on @rowangoodwin's advent calendar. #festiveSpirit π #
- Bromsgrove 3rds 1:7 hampton Arden. #hockey π #
- Yawn. Yawn. Yawn. #
- Neighbours – STFU. Kthxbai. #
- Not sure why Bromsgrove council feel the need to build a new leisure centre – the current one is fine and only just been refurbished #
- I can't help but think the Bromsgrove standard is a little optimistic with it's 'cinema in Bromsgove' headline. #
- I'll soon be deaf unless these burglar alarms STFU. #Bromsgrove #electric #fail #
- I should pull my finger out and run, before hockey training. Need to meet some zombies while armed with hockey stick -> awesome evening π #
- The parenting manual probably says:
"Rule 57: Do not feed toddlers mince pies after 7pm.". Oh well. @RowanGoodwin had two… # - Off to the sidemoor SHED meeting. Community allotment(s) and err something. #
- RT @GeneHunt The girlfriend's mother was taken ill. I acted swiftly and rushed off to find a pen and paper to write for an ambulance. #
- Interesting presentation by @akrabat concerning the changes coming in with ZF2… nice to see many new faces at #phpwm meeting this evening. #
- I'm at fat fighters. #
- Ditched Microsoft's crash prone OSX remote desktop client; replaced with CoRD; thanks @cordapp #
- I nominate @GeneHunt for a Shorty Award in #humor because he makes me smile, and glad I'm a man π #
- RT @GeneHunt My ex used to get upset if I used her toothbrush. If anyone knows a better way to get dog crap off my boots, I'm all ears. #
- RT @GeneHunt I love defenceless animals, especially in a good gravy. #
- Sleepless in Bromsgrove #NewMovieNames #