Wow, just so cool!
Dominic Myers writes about all sorts of stuff to do with HTML, CSS, JavaScript and a fair chunk of self-indulgent stuff. Thoughts and opinions are all his own, and nothing to do with any employer.
Monday 31 January 2011
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
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!
- Install PuTTY and PuTTYgen from http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html.
- Install FileZilla
- Fire up Firefox and install ElasticFox.
- Re-start Firefox and feed ElasticFox your credentials.
- Generate Key Pair on the KeyPairs tab. Download the file and fire-up PuTTYgen.
- 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.
- 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.
- 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.
- 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).
- 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.
- Hit Launch.
- In the Instances tab right-click your instance and select Copy Public DNS Name to clipboard.
- 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.
- Click Open on PuTTY and if all went well then there should be CLI. Login as "ubuntu".
- 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. - ctrl-v into the address bar of a new FireFox tab... It works!
- 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.
- 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.
- 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 theindex.html
file. - '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