Educating the world

Our blog has over 10,000 readers a month

The rules I live by

August 25th, 2014

Peter Tatchell guiding motto is:

Don’t accept the world as it is, dream of what the world could be, and then help make it happen.

Featured on BBC Radio 4 Midweek on 25 January 2012.

Maybe it’s because I had Peter’s quote in my mind that I spotted this quote from Eleanor Roosevelt:

When you have decided what you believe, what you feel must be done, have the courage to stand alone and be counted.

IMDB cast faces popup

August 8th, 2014

The Internet Movie Database is the best resource on the Internet for information about Films and Television. For the most part, their web site is great but some of the pictures in the cast list are a bit small and difficult to see.

Most of the time the actors and actresses profile photo is a pretty clear head and shoulders press shot which has been shrunk down to 32x144. There are, however, many not so famous actresses (and actors) whose profile photos are just grainy black and white photographs of them on set or shots of them in a film. After they have been miniaturized they are unrecognisable.

I really missed the Facebook style pop ups you get when you hover over someone's face. So I wrote a Greasemonkey script to fix it. Install the script and go to IMDB, look at the details of a film and hover over the image next to the persons name. The face will be enlarged with more detail and overlayed in the centre of the screen.



The current version of imdb-cast-popup.user.js is 1.1.

Install it and let me know what you think. If anyone would like to send updates I'll be happy to incorporate them here.

28 Aug 20141.1e4660cddfb7b1128269949d75c13ccfe
8 Aug 20141.0c5d33b72a4d1fb8ba53968957a9004ff

Hiring a professional developer

August 5th, 2014

Just had another business meeting where I listened to the customer talking about the amateur to he hired to work on their office application. Same old story about them taking ages and getting bored after only completing half the site. It reminds me of the old adage:

If you think a professional developer is expensive, wait till you hire an amateur!

Conditionally replacing line contents

July 17th, 2014

I answer a lot of Unix shell scripting questions for friends (I know, sad isn't it) but as I haven't written a blog article for a while I thought I document my thoughts in case the rest of world needs something similar.

Question

have a file of IP addresses, bit like this

192.168.20.0/24
192.167.20.254
10.0.2.254
216.200.119.0/16

basically if the line doesn't have a / in it, I want to add a /32 at
the end, can you do this in vi at all ?

I've been titting around with grep -v to do an inverse search, but
can't get sed to adjust the file in place etc. hence I think VI might
be better

Answer
There are many solutions to this kind of problem. Let's assume that the network addresses are contained in a file called file.txt.

If the order was not important then a really simple solution would be this:

$ grep -v "/" file.txt | sed 's>$>/32>' > out.txt
$ grep "/" file.txt >> out.txt

  • Filter file.txt and only give back the lines without a "/" in them. For each of those replace the end with "/32" and put the contents in the file out.txt.
  • Line 2 filters the file.txt, giving back the lines with a "/" in them and then append those lines to the file out.txt.

You will loses the order as doctored lines will appear at the top and undoctored lines will appear at the bottom. If the values were sorted you could just sort out.txt at the end and restore the order (eg sort out.txt > out.sorted.txt).

The trouble with editing the file "in place" is that there is a condition rule for each line. I'm not sure you could do it using vi or ed because you are not dealing with a range of lines in a buffer which is generally how those applications work.

I typically solve this kind of problem with a bit of awk. Awk was one of the precursors to Perl but I prefer it. Perl just became a monolithic mess of difficult to remember syntax for no real benefit over what awk already did.

$ awk '{ if ( $0 ~ /\// ) print $0; else print $0 "/32" }' < file.txt > out.txt

  • Take the file.txt as input, if the line contains a "/" print the line untouched else print the line with "/32" on the end. Do this for each line and put the output in out.txt.

The condition (in the if) is a regular expression match so that everything within the // is used in the match, in our case we are looking for a "/" so we must delimited it with a backslash \/.

There a little awk tutorial here that you might find useful:
http://www.grymoire.com/Unix/Awk.html

I'm going to New York, where should I go?

June 9th, 2014

I've probably had a months worth of holidays and business trips to New York over the last couple of years and have got to know the place pretty well. So I've compiled this list of cul'cha, tours and cheap things to do that I just roll out whenever anyone asks me what to do in New York City.

1) New York City Duck Tour

http://www.lovetoeatandtravel.com/site/us/ny/ny_tours/duck.htm
https://www.google.co.uk/search?q=duck+amphibious+vehicle+tour&tbm=isch
All the information I found about it said it has been discontinued but that was a couple of years ago. There might be something similar that has replaced it. Basically they drive you around New York pointing out the sights in an amphibious DUKW (pronounced "duck") vehicle then it drives into the Hudson and you take a boat ride along Manhattan Island then back the the start. It cost about $20 each but loads of fun.

2) The Staten Island Ferry

http://www.siferry.com/
Costs about $5 to get to Staten Island then it's free to come back. It takes you right past the Statue of Liberty and is about 20 times cheaper than a Statue of Liberty cruise. You can come back anytime so you can have a look around Staten Island. There's a couple of nice cafes once you get out of the ferry port.

3) Guggenheim Art museum

http://www.guggenheim.org/new-york
Really nice spiral staircase and there's usually something good on.

4) The Metropolitan Museum of Art

http://www.metmuseum.org/
Set on the edge of Central Park (the nice end). Lovely gardens out the back.

5) Fancy a run?

http://www.centralpark.com/guide/sports/running.html
Most of the joggers run around "Jacqueline Kennedy Onassis Reservoir" which is the largest body of water in Central Park. There is a path that goes all the way around with plenty of water fountains along the route. It's about 1.5 miles around so you shouldn't have a problem. There's plenty to see along the way.

6) Central park open air theatre

http://www.centralparknyc.org/things-to-see-and-do/attractions/delacorte-theater.html
The only problem is that tickets are like gold dust. They sell them on the day and people start queuing really early so check before you go.

7) Grand Central Terminal (Station)

http://www.grandcentralterminal.com/
You've probably seen it in films but it got renovated and cleaned up a few years ago to a very high standard. Plenty of posh bars, coffee shops and nice places to eat.

8) Greenwich Village

http://en.wikipedia.org/wiki/Greenwich_Village
Bohemian part of New York. Lots of art shops, music shops, eateries.

9) Film and TV tours

http://onlocationtours.com/locations/ghostbusters/
http://onlocationtours.com/tour/sex-and-the-city/

10) Basildon Room - Waldorf Astoria

If you have been to Basildon Park (just outside Reading, UK) there is a huge mirror in one of the rooms and the tour guides say that the sister mirror is in the Waldorf Astoria Hotel. Well it is, in the Basildon Room and if you ask nicely at the desk they will let you in to see it (for free). It's a nice excuse to get you into the hotel which is a spectacle in itself.

Well that's some of the things I've enjoyed doing on my trips to NYC. Have fun and let me know how it goes.