11.27.07
Posted in rant, technology at 10:18 pm by coldclimate
I always come back to the power of Unix tools, and the ideology of using many small tools in stages to achieve a goal rather than crafting a monolithic solution. Tonight was a great example how how a little automation can save a huge amount of time.
My dad has a massive stack of Excel spreadsheets called Book1.xls, Book2.xls etc etc. Each is representative of a single day, and needs renaming to reflect this. Like any good Windows user, he was opening up each one, finding the line with the date in, closing the spreadsheet, renaming Book43.xls to 07 06 2007.xls, and moving on. Ironically he was working on his Mac for this as it’s for user friendly. So - prime from some automation.
Firstly, all of the books he has renamed already needed renaming in the format YYYY_MM_DD.xls so that they can be ordered easily. Step in a bit of ksh programming.
Firstly - copy them all off to one side, and work on the copy. It is very easy to cock up and cp -pr making knocking a copy off to one side easy.
I like working from a driver file, so I did an “ls *.xls > list.txt”, then start a shell script that loops through the driver list using “for i in `cat list.txt`” and split out the three bits of the file name by piping it through awk, and spitting it out of the other side in a new order. To do this I used “echo $i | awk -F” ” ‘{print $3 “_” $2 “_” $1}’. With a little more pipe magic, I used this output to mv all the files around and job done.
Next, and more interesting, renaming all those Book*.xls to YYYY_MM_DD. The Unix command strings pulls ASCII out of binary files, so doing “strings Book1.xls” gives back a whole pages of text. One of the lines has “rubbish rubbish Date: 9 September 2007″. This is excellent news, because we can use awk again, splitting by “:”, and then select out column 2 with “awk -F”:” ‘{print $2}’. This splits back “9 September 2007″ which we can then use with awk again, splitting by spaces this time with awk -F” “, and use the same trick as the first set of files to rename the Book1.xls to $3_$2_$1 (2007_september_9.xls in this case).
OK, so far too much detail in there for the cusual user, and I imagine there are a million and one neater ways to do these things if you ask a really good hacker, but the point I was going to make was this this is only possible because of the Unix philosophy of being able to plug together little tools in a million and one combinations. All I used here was ls (to list the files), mv (to move them), awk (to separate things out separating by different characters) and cat (to read out files). The whole job took about an hour (including all the time to work out how), and saved at least 5 hours. It would scale too, saving 500 hours for the same investment of 1, and it’s just not possible on todays dumbed down Windows world. Shame.
Permalink
11.13.07
Posted in randomosity at 8:41 am by coldclimate
I hadn’t planned to blog whilst away for fear of loosing my passwords to some Chinese hacker, but to be honest, I can change them, so fuck it.
My week in Hong Kong has been an experience, some good, some bad. The 4 hour train journey down to the flight was bad, as all cheap train tickets generally are, though at least I was not treated to too much Sharron and Tracy behavior. The flight was, well, long, but not terrible. The AV system crashed repeatedly, meaning instead of watching the 2 interesting films in their lineup of 40million, I watched the first 20 minutes of DieHard 4, 4 times, and finally the rest of the film. It was OK. Samson, the native Hong Konger in the seat next to me was present enough, especially considering the poor bastard had spent a week in Walthemstow on business.
HK airport is huge and sprawing, and reminded me very much of a shopping centre. A shopping centre with no signs, few shops, piped muzac that made me want to kill people, and eventually I blundered across the bus into town. So far, so good. The public transport here puts the UK to shame, completely, utterly, and embarrassingly so. Its clean, quick, cheap (2 quid for 40 minutes into town - and this is considered to be for washing the tourists!). Nathan Road where I was staying looked for all the world like Mega Tokoyo in films, and finally we got to “my stop”.
Youth hostels the world over are generally, well, ok. One or two are amazing (somewhere on Vancouver island I watches whales in the bay before a breakfast that would have cost the Earth in a hotel), some are downright terrible (place in the city centre in Belgium comes to mind), but this place is just frankly, weird.
Mirador Mansions is not a mansion, not a collection of mansions. It is in fact a 16 story building split into flats which would be considered pokey for a couple and impossible with a baby, not that it is in fact residential. Well, some of it is but mostly it seems to be a random collection of businesses, some of which are “hostels”. You want to open a laundry - no worries - there’s a space on floor 6. Jade workshop - step right in! Suit cutting business - go for it. The internet cafe I’m in is in the same building, as is what looked for all the world like, well, a BBQ pit restaurant.
Taking the one lift that runs to floor 13 (one does odd numbers, the other even) I get “checked in” for the grab total of 100 quid for the week, to an 8 foot by 6 room, complete with ensuite bathroom (aka. a sliding door with a bog and a shower). I’m knackered, jetlag sets in, and I will spent the next 2 days not sleeping here. Also - when you shower, the little drain floods, bringing with it the warm smell of rotting meat, probably from a butcher somewhere else in this crazy building. The interesting thing about the room is that it has a window which faces onto…. nothing! It’s onto an internal vent for the building, meaning you have no idea what the sun is doing, or the weather, it if any one of the four other rooms which face this vent turns on it’s lights, or God forbid, it’s air con, you get the full treatment of light and sound only 6 feet from your window. Excellent design that - nice one.
OK - despite my mutterings, it’s actually ok. I couldn’t get a hotel room, and this place will be fine as a pad to launch my assaults on this very strange town. It’s smack in the middle of TST too, and next to a metro station (the MTR is like the Tube, only a million times better), and apart from the street hawkers (more on them later), it’s actually quite a nice area.
Day one, and I’m feeling completely out of my depth., I’ve not slept, it’s hot and humid as a German’s armpit, and when I venture outside, it’s noisy, and packed, and everybody is trying to sell you something. I’ve got to hand it to the Chinese, they are lovely people, but your first impression wandering down Nathan Road of of 40 million shifty, slimy little Indian blokes, popping an arm round you waist and trying to get you into their tailoring shop, which is in fact, 3 streets away. That or they spit “copy watch! all rolex! Copy watch” at you, and then seem offended when you say no thanks. One bloke actually spat it me, it’s just about settled things with fists. HK government, get control, and attest these little shits, they are making you look terrible.
Day one was spent wandering around, slightly aimlessly, and getting my barrings. I was on the Kawloon side of HK, not HK island itself. That mean the ferry is south, the suburbs are North, and the bit in the middle is full of, stuff. Mong Kok (just north of me) apparently has 500,000 people in it’s quarter of a square mile. I can believe it.
I finally got up the nerve, and ventured into one of the noodle shops. Thinking of Antony Bourdains brilliant book, I got hussled into a seat at a table, pointed at what the women across from me was eating, and had some really tasty meat (pork? bacon cut oddly? who knows) and noodles, and it was great. I even got a thumbs up for my chopstick technique (get in - eat that Ave boys!) All told it cost me about 2 pounds.
I also go round a good few of the museums, and they are really a mixed bunch. HK Art Museum is, frankly, rubbish. The science museum rocks, completely. Everything is hands on, everything is good science, not dumbed down, just well written, and in three languages.
Day two, and I ventured onto the island, walked for miles and miles through markets, and temples, and vast soaring business districts and in the process, tore most of the skin off my little toe, and ended up with a blister the slize of a fifty pence in the middle of my foot, one the size of my thumb running round my heal, and various smaller blood blisters dotted about. My own fault, through I’m blaming the hot weather in my feet swelling and thus making shoes which fitted perfectly well the day before turn and attack. Still, good day, and feeling a bit more at home I return to the hostel to not sleep, read my book (finished one already) and avoid getting my feet wet in the shower for fear of the vile filth rising through the drains. Blisters are still intact however, so painful but not a problem.
Day three - turns out to actually be Day Four, because the date changed as I flew and I didn’t notice. Damn it.
Day four, and I head up the Peak, for what would be an amzing view, if it was not completely foggy., It’s still worth it however for the holding-onto-your-teeth-in-fear tram that chugs up the hill at 45 degrees, and then back down again. I’ve been on rollercoasters that weren’t as shit scary. Most street food is found, and I’ve beginning to get the hang of walking in and sitting down with older Chinese people who clearly think I’m lost, but then look faintly impressed when I slurp noodles and wantons annoited with chilli oil and this odd runny red stuff thats sort of cherry flavoured. It’s great and I love it until I am served the nasty of nasties, the thing I really didn’t want (after the prawn eggs), beef lung and live. The menu was translated as beef, and up to press it’s been some for of flesh not offal, however this time, I’ve drawn the short straw. I try it, but I’m not feeling th love, and end up moving it all to one side and just having the noodles and pak choy, which are excellent. I tired a mouthful of warm liver, but it was cold in the middle, and luke warm on the outside, and I was not filled with confidence.
Day Four also involved going to the beach in Repulse Bay, having navigated the busses to get there. It’s like a scene form James Bond, with chunks of lime stone rising out of a perfect sea, dripping with lush green vegetation, and topped with million dollar mansions which teeter on the edge f falling into the sea. I could live there, and I’d have a fucking diving board while I was at it. This is however where my blisters decide to pop and tear and my feet descend into hell. I buy some small plasters in th 7-11 (who knows why they have a strangle hold on this place but I’m not going to complain) and limp back to the hostel. After washing and “dressing” my feet, I seek refuge in the “irish pub” next door which is actually quite nice, and feel guilty at giving into the culture shock and wanting a pint and (sadly not forth coming) a pie. Get chatting to a very nice bloke who quit the IT industry to run a coffeeshop, and (one marriage later) now owns three.
Day five is where there is a slight problem. At some point during the last week, I’ve eaten something a bit dodgy (my money is on the warm lung/liver), and my body does not like it one bit. It lets me know by, whilst walking back to the hostel, making what I thought would be a quiet fart turn out to be very nearly shitting myself in the street. Not to go into too finer point, but there was a liquid escape, though not enough to run down my leg, quite. The next 24 hours are spent not going too far form the loo, and hating my room more than ever (having found a sort of peace with it in the proceeding three days). Fizzy arse gravy having subsided a bit I did venture up to the Walled City Garden, which is about the most peaceful and tranquil place on the Earth, and has lots of public toilets.
This morning, I woke, and having not gone to the night market with Coffee Shop Man last night for fear of limping about and then shitting myself, I resolve to escape early. A quick trip to the coffee shop up the road to use their internet connection (and have a maple syrup enfused coffee which, despite breaking every run I have about coffee) is actually very nice), move my light back 24 hours, book a new train ticket home, and realise that in 16 hours I will be back on UK turf. Normally this would feel like cutting and running, and frankly maybe it is, but it’s better than being holed up in a small room, missing out on the majestic HK (which really is amazing - honest), waiting to need the loo with 2 minutes notice. I’ve plodged about a bit today, bought a few presents, and some tea, and some lovely chopsticks, debated buying a whole crate of meat cleavers (90p each - looked excellent - not stainless steal so you can get them razor sharp) and shipping the home, and finished another book (total - 5 this week, thank God for the English language bookshop round the corner). I was goig to head to the airport early as it will likely have a chemist so I can buy some Immodium (I’m not going to try and translate with pictures my needs to the local chemist, and I don’t see any brands I recognise),, but have decided to hang around until 6 ish then taxi to the airport. Next update - either there, or back in Blighty, a day early, much wiser, and actually having had a great holiday.
Tips for coming here: stay in the most luxary you can afford, it will be worth it. Punch watch sellers in the face, maybe the fuckers will get the message. Eat everywhere that isn’t a tourist trap, especially the backstreet noodle/rice places, because the food is fabulous (if a bit risky
), go to the beach or better yet, become an evil genius and use it as your headquarters, world domination will follow.
Permalink