Saturday, July 17, 2010

What are Amazon doing?

I just bought a book. It cost be £9.49 from Book Depository. Shipping is included in their price. Before buying it, I checked Amazon's site. They wanted £8.43 but they also wanted £4.98 to ship it to Ireland! The book was eligible for "super saver shipping", so if I was buying more than £25 worth of books, the shipping would be free but I wasn't so that's beside the point.

If Book Depository can do the whole thing for £9.49, there's no way on earth it is actually costing Amazon anything close to £4.98 to ship 1 book to Ireland. So I really wonder what's going on. Are they trying to discourage single-item purchases? Are they ripping off the Irish (why leave that to the Irish?) Does it really cost them that much to ship a book? Is Book Depository losing money on this?

I'd love to know what's really going on. I sent them a mail. I already bought the book from Book Depository but I figure there's no harm in encouraging some competition.

Monday, July 12, 2010

Letter to the editor: Why people protest against Israel and not Iran.

I'm a sucker for punishment, I'm sure they won't publish it but I wrote this because I haven't seen this point being made anywhere and I think it gives a pretty good answer to a commonly thrown accusation and even if they don't print it, I've been meaning to write about this for some time now.

Sir,

Eddie Naughton asks where are all the do-gooders protesting the death
sentence for Sakine Mohammedie Ashtiani in Iran (letters,
Jul 12th). The Irish branch of Amnesty International has a section
of their website devoted to Iran and are covering this case amongst
others, so the do-gooders are on the case.

As for why Iran and other states like it do not draw the same kind of
protests that Israel does, I would guess that it's because Iran does
not attempt to present itself as a modern, moderate, Western-style
democracy. Iran is not in the process of joining the OECD, it does not
seek approval from the West nor does it claim to have similar values
and morals to Western countries. So protesting outside its embassy or
criticising it in public is mostly a waste of time. Nobody expects any
better from them.

Israel on the other hand does all of these things. It wants to be part
of our club and that makes it vulnerable to bad press and peer
pressure. The Israeli government knows this and puts huge resources
into media and internet campaigns to defend its image - far more than
other states abusing human rights. Unlike in Iran, Israeli government
policy can and has been changed by public opinion, within the country
and without. They are listening. The USA, their main sponsor, is also
sensitive to such publicity.

In summary, people protest loudly and publicly against Israel because
it might actually work. People don't do the same with Iran and others
because it seems completely futile. Nobody has time to fight them all,
they're just fighting the battles they think they can win,

Iran is run by the religious and even if the last elections weren't actually rigged, the choice of candidates is controlled by the religious too. Holding a placard outside their embassy is pointless. Iran's problem seems most likely to be solved by an uprising of its citizens, at which point it will hopefully be a much more just and democratic place (it had a real democratic government in the past which was overthrown in 1953 by that beacon of democracy, the US).

Israel is controllable by its citizens and only able to do what it does because the USA currently approves and pays for it. All it would take is a moderate stance by enough of its citizens or an awakening of the US electorate to their massive subsidising of Israel or just to the reality of its actions. This all seems much more achievable and public action is a viable method.

It does not require a hatred of Israel or a hypocritical bias to explain why people focus on it. If anything, Israel is sick and in need of help (as was/is Northern Ireland). A peaceful, just Israel would be a great thing for Israelis, Palestinians, the region and the world. It would upset the plans of the radical Zionists and the fundamentalists who believe the land is theirs because it says so in their book. I'm not sure they can ever win that fight anyway so in reality, they'd probably be better off too. It would upset the plans of Muslim fundamentalists too.

So the reward could be huge and the goal appears achievable. I think that's why people choose to fight this fight and not the others.

Sunday, July 11, 2010

Why you can't have infinite data compression.

I was leaving a comment on this blog post and it got kind of long so I thought I'd make it a post (and got a whole lot longer!).

Even if you can squeeze a quart into a pint pot...

Compression methods make lots of files smaller. Zip can shrink text because they have lots of redundancy. In fact most things created by humans have lots of redundancy in them. Repeating something in a different way it helps us grasp understand more easily. Redundancy also defends against small errors. So if, in my first sentence, I wrote "compresion", with just one "s" you would still know that I probably meant "compression". Maybe I meant "comprehension" but from the title and the rest of the sentence you could rule that out.

It seems like maybe, if you were clever enough, you could somehow compress a file, then compress the compressed file and then do that again and again and end using lots less disk space (at the expense of doing lots of compression and decompression all the time).

... you can't squeeze 511 quarts into 255 pint pots.

To see why this cannot be done, no matter how clever you are, imagine you had a compressor that always made things smaller. Let's consider all possible strings with 8 or fewer bits. There are 511 (2^9 - 1) of them. If they all get smaller then they must all turn into strings of 7 or fewer bits. There are 255 (2^8 - 1) of those.

Now take all of these 7 bit strings and uncompress them. You have 255 inputs so you get 255 outputs, but that's not enough. You started off by compressing 511 things and you only got half of them back. Some of your input strings must have compressed down to the same output string. That's no good, you need to always get the original back. A compressor that doesn't give the original back is called "lossy" and while that can be great for pictures and movies where the human eye discards lots of the fine detail anyway, it's not the kind of compression that you need for legal documents or computer software.

What if I only compress the ones that get smaller?

It seems like you can still do better by only compressing the ones that get smaller and leaving the others uncompressed. The problem here is that while the strings get smaller on average, you now have to remember which ones you compressed and which you didn't. So now you have to add an extra bit to signify whether it was compressed. There are 256 exactly-8-bit strings and 255 7-or-fewer-bit strings which means at least one of the 8 bit is left as an 8-bit string. Now add the "was I compressed" bit and you get a 9-bit string. It got bigger! Actually it's a little bit more subtle than this because you might say that for an 8-bit, uncompressed string you don't need the extra bit, it obviously wasn't compressed but you must remember that some of the 7-bit strings weren't compressed either and so became 8-bit strings. You have to be able to tell them apart from an 8-bit string that wasn't compressed. Either way, you have 511 inputs and you don't want to mix any up so you need 511 outputs and in the best case, that requires strings up to 8 bits long.

Working at it from the ground up.

Another way to come at this is by thinking about what such a miracle compressor would do to short strings. First, consider the 1-bit strings. There are 2 of them, "0" and "1". Since this compressor must make everything shorter it's stuck already. So let's make an exception for 1-bit strings and say that they always compress to 1-bit strings. So what about 2-bit strings? Well, if it turned any of those into 1-bit strings we'd have a problem because the 1-bit outputs are already taken (for the 1-bit strings). So let's make an exception for the 2-bit strings as well and let them compress to 2-bit outputs. What about the 3-bit strings? Well, all the 2-bit outputs are already taken, so we'll have to make an exception for the 3-bit strings too... Eventually we'll make an exception for every input, no exceptions!

Back in the real world.

There appears to be a loop-hole in real-world computing. It seems you can always get a win-win solution by only compressing the files that compress well and applying the right method. So Zip your text files, PNG your images and don't compress anything that doesn't compress well. You always save space or break even. This seems to contradict what I wrote above. That's because it ignores the fact that filenames take up space. It only works because your computer has already allocated some number of bytes for the name you're going to give the file.. So even if you give it a really short name, the extra space is used anyway. Also, if you already had a really long name, adding .zip on the end may not be possible as it would exceed the size-limit on filenames. Some filesystems don't have a limit and only use as much space as the length of the name but then adding .zip takes up 4 more bytes.

Just being silly now.

If you use a filesystem that does not have a limit on the length of a file name then the following compression method "works". Convert the file you want to compress to a number (that's essentially what your computer does when you save a file anyway - the numbers are big, this blog post has about 6,000 letters in it so would be saved as a number with about 14,000 digits). Now compress this number by subtracting 1 from it and sticking a .z on the end of the file name. Now do that again and again and again. Eventually the number will be 0 and the file data will take no space on disk. When you want to read your file you just keep uncompressing it until all the .zs are gone from the file name. Great, now if only you could find a way to compress the filenames you'd be set...

Monday, July 05, 2010

I declare July 5th to be Dependence Day.

I spent July 4th in Mountain View, California (I'm visiting head office for two weeks). Apart from a very cool doodle on the Google homepage and hearing some fireworks as I sat in my apartment, it was just like any other weekend day I've spent in sleepy Mountain View. The official day off is tomorrow, so nothing was closed or out of the ordinary.

The name of the day got me thinking though. These days, the USA is no more independent than most countries, in fact it (and most other countries) are far more dependent now than ever before. So I am declaring July 5th to be Dependence day.

On this day we can celebrate (well maybe just acknowledge) our dependencies. First off, our dependence on brutal governments around the world to keep their people living in poverty and unimaginable pollution while selling us oil and raw materials at knock-down prices (hello Nigeria). And on countries that are exporting minerals stolen from their neighbour, mined by children and slaves, with all the care and humanity you would expect from such operations (Congolese coltan in your mobile phone).

We should also acknowledge the governments that make sure their workers cannot meaningfully organise for better pay and conditions. Like China, where any unions are run by the company and the state and not the workers. This article about a recent strike indicates that things may be changing but it includes this gem near the bottom

Many workers are asking for independent collective representation. Unions in China are usually funded by companies, staffed by management and answerable to the Communist party. During an earlier strike at the Honda plant in Zhongshan, union representatives fought workers, injuring two of them.
That sure is a militant union.

Without this setup we couldn't possibly have DVD players for €20 and other electronic devices that are cheaper to replace than to repair (e-waste is itself a massive problem, I'm not sure if ifixit.com is really the answer but fair play to them for trying). And of course all the cheap plasticky crap that we don't really need or want but end up with anyway. Stuff that may eventually make its way to the North Pacific Gyre and from there perhaps into the stomach of a soon-to-die albatross chick

As well as material dependence there is psychological dependence. Living in Ireland, I get to be relatively happy with my government's record on human rights and such-like. I'm not too happy with the US military planes landing at Shannon on their way to Iraq but we have a foreign minister that has attempted to visit Gaza and many TDs (in and out of government) who speak out against Israel's occupation and other issues. I get to rail against the US, UK, French etc. governments for their part in the exploitation of various people and places. If I don't think too hard about the origin of the things I buy, the power I use and the forces that keep the whole modern world ticking over, I can keep my conscience clean most of the time and I really couldn't do that without those foreign governments or for that matter the Irish government. Although it isn't directly involved, my government happily lies down with those who are, while only making a fuss about the more obvious bad-actors.

Happy Dependence day everyone.

Post Script

After writing all this I did a Google search for "dependence day", figuring someone had probably beaten me to all of this. I was half right. On the first page at least, all I could find was various right-wingers decrying the lack of independence within the US, the "over-reaching", "over-regulating" "nanny state", the dependence on health care and how the founders would be sick if they could see us now, blah blah. The usual libertarian guff. It makes me think of this video. So while I doubt this is really an original thought, it doesn't seem to be a common one.

Watcha doin?... Toilet. Daijoubu. Falling asleep in the bath.

Watcha doin?... Toilet

Sean likes to follow me to the toilet. He no longer tries to get a close up look into the bowl (putting his head right in the flight path) or grab onto the glittering stream. Now he runs in and looks up and shouts "Whatcha doin? [short pause] Toilet". I think it must be something he picked up in the creche because the phrase just suddenly appeared, shouted confidently on a regular basis. Now he uses it in other contexts. A fart results in a laugh followed by "whatcha doin? Chin chin". "chin chin" is Japanese for "penis" but clearly Sean has a slightly broader meaning for it or a horrible medical condition that we haven't yet noticed. I'm not sure he's even asking a question, it seems to just mean that something interesting is happening or he's just saying hello.

Daijoubu

"Daijoubu" is kind of Japanese for "don't worry, I'm OK", usually it's a response to someone asking you if you're OK. A few times a day, Sean will just suddenly say it without prompting. I turn around to find him upside down hanging off the couch or worse, half-way up the stairs and I can only wonder what awful tragedy he narrowly avoided.

Where's Riona for all this?

Why am I posting all this stuff about Sean and nothing about Riona? Riona has morphed from a cute and amusing, small animal into something much more like a small human being (yes I am in danger of anthropomorphising children). She isn't doing anywhere near as much funny stuff, stuff that betrays an almost complete lack of knowledge about the real world. She is, in fact growing up... but not too much.

For the 3.5 weeks I was in Japan, I think we pushed the kids too hard with trips out to this and that and a week in Okinawa. The result was frequent breakdowns from Riona and one total meltdown from Sean, who is usually the voice of calm and contentment in our family. Riona fought over ridiculous little things that were in hindsight, I think, protests at being dragged out here or there to meet some friends of ours. Sean's meltdown was on the way back from Kamakura, when he was just completely sick of being on trains and started screaming and screaming and screaming. I tried taking him for a walk in his buggy while still on the train. All that did was introduce a furious, screaming child to carriage after carriage of disapproving Japanese commuters. We had to change trains and Midori bought some sweets and just a single toffee square was all it took to return (poor) Sean to his usual happy, playful self. He spent the short ride home playing peepo with 2 slightly drunk business men.

The funniest incident with Riona was a fairly common case where she had a bath before bed and then didn't want to come out of the water. This time she was so tired and grumpy that she ended up falling asleep mid-protest. She was slumped in the corner of the bath (don't worry I was in the room with her). I took some photos of her but I'm pretty sure that posting them on the Internet will get me done for kiddie-porn. I'll just save them for my power-point presentation at her wedding.

Don't like dat vs jibun de.

This post might not be of much interest to anyone but me (moreso than my others posts).

About 2 months ago, Sean learned the phrase "don't like dat", usually accompanied by pushing "dat" away and sticking out his bottom lip. It's very funny to watch. It often actually means I've had enough - something he does like and was happily eating a few minutes ago will be declared "don't like dat" when he's full.

Children's language skills are very practical. The words and phrases they use are actually chosen not for their "real" meaning but for the outcome they produce. For Sean, if "don't like dat" results in dat being removed and something better replacing it (where something better might just be leaving the table) then who cares whether he really does or doesn't like it. The long term goal of communicating his preferences to us suffers a little but he's not really into long-term planning yet :) and up until now we've had to figure out his preferences from non-verbal cues anyway. So as long as we don't take him literally, this phrase serves its purpose perfectly.

Even for Riona, the word "why" is still just a button she can press to make me speak more about something. I often forget this and get frustrated with questions like "why is that a toilet?".

More recently Sean learned "jibun de" - "by myself" or as Riona used to say (or shout) "my do! my do!" (that's English by the way).

The problem is that both phrases now come out sounding mostly the same, so when you move some food onto his plate and he starts shouting at you, it's 50-50 whether he doesn't want the food or whether he does want it but wants to get it himself. For some reason I seem to get it right considerable less than 50-50. Poor Sean (for a while I thought maybe we should change his name to Poor Sean, it's not easy being small, adventurous and Riona's little brother).

Narrowly avoiding shaming myself again in Japan.

The last of a lot of things I wrote last Sunday in a Cafe.

A history of friction.

My trips to Japan, staying with the in-laws have not always gone terribly smoothly. I am allergic to their house and it brings on my asthma like nothing else I have encountered. Usually I only suffer if I play soccer on a really cold day or something but their house is my kryponite. It's quite old and Japan is incredibly humid. A friend bought a bamboo bag this summer and that evening (the day she bought it), the bag had a one-inch layer of fuzzy, fluffy fungus growing on part of it. Add to this the cat, dog, birds and other animals (which have never given me a problem elsewhere) and I get wheezy within minutes of entering the house. On every trip, after a few days I have had to struggle to the English speaking doctor who gives me a bag-full of drugs and inhalers which get me back to normal in about 2 weeks.

These near-death experiences do not make me a good house-guest and last time I was there, my lack of energy (and hence enthusiasm and politeness) caused some friction.

After coming back last time, my Irish doctor gave me a preventative inhaler which I suck on every day whether I feel like it or not. It's a remarkable thing. Whenever I get a cold now, I have pretty much no symptoms until I get a fever and feel like crap. No snots, coughs or wheezes.

So, for this trip to Japan I was prepared. And it worked. For the first few days, I did feel a tiny bit wheezy in their house, so I cut back my time in there and soon after I was better. After that I seemed to get a bit of immunity and was able to hang around without any problem. It probably also helped that we were there in the summer this time. As uncomfortable as summer there is, I much prefer stripping off to wrapping up (hope you weren't eating when that image hit you). I think no more winter-time trips to Japan from now one.

Disaster looms.

I was in Japan for 3.5 weeks (1 of them spent in Okinawa) and so far had been getting on perfectly well with everyone. On my last night, with Midori and the kids asleep early, I took a trip to the big second-hand book shop near the train station. It's part of a big chain called Book Off (I have lots of ideas for a competing brand - Book You, Book Me, Book That, What the Book?, Go Book Yourself With a Chainsaw etc.). I wanted to buy some teenage-level manga, many of which have the pronunciation alongside the Kanji and in fact I got one that I'm having good success in reading (it does appear to be some kind of teenage girl time-travel romance adventure but it's enjoyable enough so far even if I have to hit the dictionary for nearly every sentence).

I borrowed Midori's dad's bike and even though he always says "don't lock it, it's not worth stealing", I did, because I knew the combination and having the bike stolen would just be so embarrassing. What I didn't know was that Midori's mother's bike looks almost the same in the dark and has a different combination!

So an hour later, I'm outside Book Off realising what has happened. I phoned the house to find that they don't know the combination number, confirming my worst fear. My last day in Japan is going to involve getting Midori's mother out of bed and down to the station in the now pouring rain to unlock her bike. I'm to ring back in 2 minutes. I think perhaps her mother doesn't know the number anymore but does know what buttons to press and is going outside to press them on another bike and make a note of the numbers.

Screw you Japanese bicycle locks!

Japanese bicycle locks are for the most part laughable. Some have a key, some have a 10-digit pad and you press down the right 4 of them and push in the tab to open the lock. In both types you are just pushing a piece of metal through the spokes in the back wheel. You're not actually locking it to anything and the whole thing could be hack-sawed off or pried open in about a minute. I guess it just stops kids from jumping on your bike to get home from school quickly. Most of the bikes are of the "mama-chari" style, a Japanese abbreviation of "mamma chariot". I saw hundreds of bikes every day and I'd say maybe once per day I would see something like bike in Dublin. That is a mountain bike, hybrid or racer (road-bike). On the rare occasion I saw one, it seemed to have a bit of a beefier lock too but still nothing special.

Anyway, I was determined not to shame myself entirely after such a smooth trip and spent some time examining the lock to see if there was something simple I could do to open it. I remembered cracking a luggage combination lock years ago by just pulling on the lock and twisting each dial until it kind of stuck a bit. Then you know the dial is at the point where it's interacting differently with the... the whatever you call the bit of metal that you're pulling on.

Wow these locks are crappy.

So I tried variations on that without success. Finally I just tried pushing and pulling the tab and seeing which button reacted. I pushed that button and wiggled some more. After 4 buttons the tab pushed in and the lock opened! I couldn't believe it. Earlier, I had assumed that such a simple approach would not work and had tried other stuff. OMG these are really, really crappy locks. It took me 8 minutes to figure this out and now that I know how, I guess it would take me about 30 seconds to open another one.

So I phoned the house again and told Mr Inagaki the code. They had already found it by then and I don't think Mr Inagaki was really listening to me - after I finished talking he proceeded to tell me the code. I rode home in the cool rain with a little buzz of victory!

In the morning when I told my story over breakfast, only Mr Inagaki thought it was cool.

No ni sai - how to ruin your child's second birthday.

The first of a few random snippets on what Sean says and does that I find amusing. For some reason, Sean's stock-phrases are much more likely to be in Japanese than Riona's were, maybe because Riona had full-time daycare in Ireland for a while and Sean never had.

Sean is almost 2 years old and still does a little bit of breast-feeding, mostly in the middle of the night. Midori is trying to end this and sometimes stops his attempts and tells him "mo sugu ni sai" which means "you're nearly 2" ("ni sai" means "2 years old"). Sean now gets grumpy and starts saying "no ni sai, no ni sai!". Sometimes just for divilment we'll say "mo sugu ni sai" to him to wind him up and it works. All good, innocent, infant-bullying fun.

What might be a problem is that Sean is 2 on Jul 15th and he'll be in Japan for that. I'm not sure what Midori is planning but he'll at least have a cake and the family around him, all repeating that dreaded phrase "ni sai, ni sai, ni sai" and he'll have a big grumpy head on him, shouting "no ni sai! no ni sai!".

I wish I could be there to see it! Obviously, I wish I could be at Sean's 2nd birthday anyway but he'll have lots more birthdays and it'll be a long time before he has another where he gets upset by anyone who mentions his age.