The T-Files


Sun, 08 Dec 2013

Bad air

Air quality in Shanghai is a problem, especially in winter, and it seems to be getting worse. Last Friday, the index exceeded 500, which is where the scale stops. Going outside was strongly discouraged, Kai had to stay at home and could not go to school. Cissy was quick to make travel arrangements to get us out of the city, in two parts.

Part one was a bus trip to a hot spring and mountain resort in Lin'an for the weekend. That did not completely work out as planned, because during the six hours we were sitting on the bus (there was a traffic jam to go along with the smog, the former being not the cause, but a likely consequence of the latter), the air quality index in Shanghai dropped back to around 180 ("unhealthy"), while it remained at around 400 ("hazardous") at the hot springs and the hotel. Speaking of hot springs in China, I suppose it had to be expected, but it was still a bit of a shock to find people smoking cigarettes in the actual water. Fortunately, once we got into the mountains on Sunday, the air freshened up. We saw a lot of monkeys and a scenic spot that has recently gained popularity after Yao Min chose it to take wedding pictures.

Part two will see Kai spending his three-week winter holiday in Germany. Neither Cissy nor me can just disappear from work on such short notice for so many days, so we will take turns accompanying him, with an overlap conveniently timed for Christmas.

Sun, 27 Oct 2013

Salesman-in-the-middle attack

ISP in China are very aggressive in shoving advertisements down your pipe. Maybe that's an unfair generalisation (but there are not many ISP here), and most likely it's unfair to call out China on this (from what I hear and read, ISP and telcos world-wide are not especially beloved), but I am getting really annoyed. In addition to the Great Firewall making the International Internet experience crappy, China Telecom seems to be bound to make the Chinese Internet experience as unpleasant as they can, too.

For a long time, there has been hijacking of mis-typed domains: When you put in a website address that does not exist, should be getting a DNS error. What you get instead is a page generated by your ISP with a selection of "helpful" links and banners. This breaks the Internet only in very subtle ways, and is common bad practice world-wide. Fine. Here in China, this page also opens a good number of pop-ups. Fine (especially since I don't get to see them since most of my browsers have Javascript turned off except for white-listed sites that I got to approve).

But what recently started to happen is that the ISP (it has to be them) starts to intercept regular HTTP traffic and injects extra ads into the pages from time to time. This is implemented by wrapping the whole page into an iframe and using that to place a popup banner over the site you wanted to visit. This is terrible enough on its own, but of course it also breaks some sites that don't expect to be presented that way. For example, sometimes you cannot scroll down anymore. Fortunately, the ads are not shown every time (yet?), so a reload fixes things.

Sat, 26 Oct 2013

Shanghai Barcamp Fall 2013

My third Barcamp. Yet another venue, this time quite convenient for me. Still in Puxi, but right next to the river and the big bridge.

  • Current State and Future of Cloud Services in China – Vikrant Rathore
  • Demo of a measuring bottle cap that works with liquids, pills and powder
  • Customer Experience vs. User Experience - Paris Young
  • Programming your brain to live your dream life - Fionn Wright
  • From energy monitoring to smart home automation
  • Seven things I learned outsourcing an iOS app
  • Fast Java Development using Dropwizard – Alan Stafford
  • Avoiding Employment Hell: A legal/HR guide for laowais - Molly Huang
Mon, 30 Sep 2013

Broken Bad

All bad things must end. What a ride! Those last six episodes show how to end a TV drama in style.

Why couldn't LOST be like that? Or the X-Files? Probably because those guys did not plan out everything from the beginning and just made stuff up as they went along.

In case you're wondering how I am watching this: There are a couple of high-quality and totally legitimate streaming sites in China that have a number of popular US TV shows, often within hours after they aired in the States (complete with Chinese subtitles and Cadillac commercials). We're also watching Big Bang Theory, Sherlock and Elementary that way.

Sat, 14 Sep 2013

Torrential rain

We we just coming back from a customer meeting yesterday when it started to rain. The downpour was clearly too much for the drainage systems and even main roads were flooded very quickly. My boss has (had?) a very nice, very fast BMW 335i, and that turned out to have good sides to it and bad sides.

For one thing, on a day with almost knee-high water on the road, an SUV would have been preferable to a relatively low sports car. On other hand, when the engine died in the middle of a busy crossing in the middle of Shanghai, having a properly built body paid off: No water leaked inside, as opposed to the Passat trapped next to us, where they had water coming through the closed door. Speaking of water, trucks, busses, and fast-driving Land Rovers made quite some waves, and the body of the car was bouncing around a lot. We were afraid it might actually float away, but it was just riding on its suspensions and the wheels remained on the ground at all times.

While state-of-the-art engine and electronics are generally a good thing, it seems to me that simpler cars fare better when things start to break down. When the engine cut out, we had no way to unlock the breaks. Those are automatically engaged when the car stops moving (according to the manual, we could have peeled open the gear shift cover and jam a special IKEA-like key into an emergency override, but the toolbox was stowed away in the unreachable trunk). As a result the car could not be pushed. It could have been towed, as they did with half a dozen of other cars at our crossing. They even had special trolleys to put under the locked rear wheels, which they did manage to fit under most cars, but the tow truck operator had to give up on ours because of the low-riding wheels that he could not even see properly under the water. We had to explain that situation to each of the three shifts of traffic policemen that took turns to guard the scene.

With the battery dead, you cannot operate the windows anymore. Fortunately, that did not happen without warning (the dashboard complained of "excessive drain") so we could put them into a half-opened state that would let in an acceptable compromise of fresh air and rain water.

After about six hours, the BMW service guy arrived, unfortunately by himself and without his truck, that was busy shuttling around town. He was unsure it was us he was looking for, because the water (or something) had ripped off the license plates. By that time, the rain had almost stopped, and the water level had gone down enough to open the doors and step outside. Traffic conditions had also recovered enough to take a taxi back home.

On a final BMW note: This is going to be an expensive repair.

Sat, 07 Sep 2013

Peter S. Beagle: The Last Unicorn

The unicorn lived in a lilac wood, and she lived all alone. She was very old, though she did not know it, and she was no longer the careless color of sea foam, but rather the color of snow falling on a moonlit night. But her eyes were still clear and underwearied, and she still moved like a shadow on the sea.

She did not look anything like a horned horse, as unicorns are often pictured, being smaller and cloven-hoofed, and possessing that oldest, wildest grace that horses have never had, that deer have only in a shy, thin imitation and goats in dancing mockery. Her neck was long and slender, making her head seem smaller than it was, and the mane that fell almost to the middle of her back was as soft as dandelion fluff and as fine as cirrus. She had pointed ears and thin legs, with feathers of white hair at the ankles; and the long horn above her eyes shone and shivered with its own seashell light even in the deepest midnight. She had killed dragons with it, and healed a king whose poisoned wound would not close, and knocked down ripe chestnuts for bear cubs.

The edition I have also includes a coda called Two Hearts. Written and set four decades after the original novel, it gives Schmendrick, Molly, Prince Lír and the Unicorn a chance to meet again for one last time.

Mon, 02 Sep 2013

06:48

Kai's school bus leaves at 06:48 every morning.

Sun, 01 Sep 2013

Kurt Vonnegut: Slaughterhouse-Five

1

All this happened, more or less. The war parts, anyway, are pretty much true. One guy I knew really was shot in Dresden for taking a teapot that wasn't his. Another guy I knew really did threaten to have his personal enemies killed by hired gunman at the end of the war. And so on. I've changed all the names.

I really did go back to Dresden with Guggenheim money (God love it) in 1967. It looked a lot like Dayton, Ohio, more open spaces than Dayton has. There must be tons of human bone meal in the ground.

2

Listen:

Billy Pilgrim has come unstuck in time.

Billy has gone to sleep a senile widower and awakened on his wedding day. He has walked through a door in 1955 and come out another one in 1941. He has gone back through that door to find himself in 1963. He has seen his birth and death many times, he says, and pays random visits to all the events in between.

He says.

Billy is spastic in time, has no control over where he is going next, and the trips aren't necessarily fun. He is in a constant state of stage fright, he says, because he never knows what part of his life he is going to have to act in next.

Sat, 24 Aug 2013

First Calendar spam

A new pattern: An invite to a meeting via Google Calendar.

BEGIN:VCALENDAR
PRODID:-//Google Inc//Google Calendar 70.9054//EN
VERSION:2.0
CALSCALE:GREGORIAN
METHOD:REQUEST
BEGIN:VEVENT
DTSTART:20130822T160000Z
DTEND:20130822T170000Z
DTSTAMP:20130822T153753Z
ORGANIZER;CN=walidmrs.habiba@yahoo.com:mailto:walidmrs.habiba@yahoo.com
UID:88b9fs4r7a4g1bdducp4or7444@google.com
ATTENDEE;CUTYPE=INDIVIDUAL;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=
 TRUE;CN=thilo;X-NUM-GUESTS=0
CREATED:20130822T153747Z
DESCRIPTION:Hello\,\n\n\nCompliment of the day to you. I am Mrs.Habiba Wali
 d\, I am sending this brief letter to solicit your partnership to transfer 
 $27\,500\,000. I shall send you more details and procedures to follow when 
 I receive a positive response from you.\n\n\nBest Regards\,\nMrs. Habiba Wa
 lid\nView your event at http://www.google.com/calendar/event?action=VIEW&ei
 d=ODhiOWZzNHI3YTRnMWJkZHVjcDRvcjc0NDQgdGhpbG9AY3Bhbi5vcmc&ctz=America/New_York&hl=en.
LAST-MODIFIED:20130822T153748Z
LOCATION:
SEQUENCE:0
STATUS:CONFIRMED
SUMMARY:FROM MRS. HABIBA WALID
TRANSP:OPAQUE
END:VEVENT
END:VCALENDAR
Mon, 12 Aug 2013

Rafting and Hiking in Anji County

A four-hours bus ride from Shanghai, but still quite a few fellow city people there.

Rafting in Anji County

Thu, 08 Aug 2013

Ryan North (Ed.), Matthew Bennardo (Ed.), David Malki! (Ed.): Machine of Death

A collection of stories about people who know how they will die.

This book, unlike most others, started its life as an offhand comment made by a bright green Tyrannosaurus rex.

Much better than you'd think after that introduction.

Sat, 27 Jul 2013

Moving out

Our landlord had a special present for my birthday last week: A twenty-five percent increase in rent. Inflation only happens when you take part in it, so we are moving out next month.

Please invalidate your address book entries.

The timing is a bit unfortunate. Kai will be going to the German school's kindergarten from next month (the week after we move), and that will mean a one-hour-one-way ride on the school bus every morning (and another one back in the afternoon). We'll have to see how that works out. I've never had to take a bus to school, people tell me it's not that bad, but it certainly means getting up quite a bit earlier than everyone is used to. So we are mulling the idea of moving closer to the school, not right now, but maybe after a year if we still like the school and they actually finish building those extra subway stations that would bring the school at least a bit closer to civilisation.

The two weird things about the new apartment are that we will be neighbours (five floors up) to Cissy's parents (which of course is convenient to a dangerous degree, eliminating 90% of my daily commutes, one has to wonder if I'll ever leave the house at all), and that the two couples currently living in there are also being forced out by their landlady (our new landlady) demanding more money (so it seems we are taking part in other people's inflation after all).

Fri, 12 Jul 2013

Tim Powers: Declare

The young captain's hands were sticky with blood on the steering wheel as he cautiously backed the jeep in a tight turn off the rutted mud track onto a patch of level snow that shone in the intermittent moonlight on the edge of the gorge, and then his left hand seemed to freeze onto the gear-shift knob after he reached down to clank the lever up into first gear. He had been inching down the mountain path in reverse for an hour, peering over his shoulder at the dark trail, but the looming peak of Mount Ararat had not receded at all, still eclipsed half of the night sky above him, and more than anything else he needed to get away from it.

The Wikipedia page about Kim Philby explains that he "was a high-ranking member of British intelligence who worked as a double agent before defecting to the Soviet Union."

However, it fails to mention the supernatural aspects of his life, and the secret war waged by the really secret services hidden behind the various countries' secret services against each-other and against certain higher forces. Fortunately, Tim Powers fills in the gaps in the official biographies with this report from the perspective of a British agent and his missions in Paris (1941), Berlin (1945), Mount Ararat (1948), Beirut (1963), Mount Ararat again (1963) and Moscow (1964), an effort that was honoured with the 2001 World Fantasy Award for Best Novel.

Sat, 06 Jul 2013

Me wearing other people's glasses

Me wearing other people's glasses

Part twenty-one: Ingo

Sun, 09 Jun 2013

Me wearing other people's sunglasses

Me wearing other people's sunglasses

Part twenty: Jutta

Tue, 28 May 2013

Robert Silverberg (Ed.): Legends II - New Short Novels by the Masters of Modern Fantasy

The first Legends anthology, which was published in 1998, contained eleven never-before-published short novels by eleven best-selling fantasy writers, each story set in the special universe of the imagination that its author had made famous throughout the world. It was intended as the definitive anthology of modern fantasy, and -- judging by the reception the book received from readers worldwide -- it succeeded at that.

And now comes Legends II. If the first book was definitive, why do another one?

The short answer is that fantasy is inexhaustible. There are always new stories to tell, new writers to tell them; and no theme, no matter how hoary, can ever be depleted.
Eleven novellas by eleven acclaimed authors (in the order I read them):
George R. R. Martin
The Sworn Sword (A Song of Ice and Fire)
Neil Gaiman
The Monarch of the Glen (American Gods)
Tad Williams
The Happiest Dead Boy in the World (Otherland)
Robin Hobb
Homecoming (Realm of the Elderlings)
Orson Scott Card
The Yazoo Queen (The Tales of Alvin Maker)
Robert Silverberg
The Book of Changes (Majipoor)
Diane Gabaldon
Lord John and the Succubus (Outlander Saga)
Anne McCaffrey
Beyond Between (Pern)
Raymond E. Feist
The Messenger (Riftwar)
Elizabeth Haydon
Threshold (Symphony of Ages)
Terry Brooks
Indomitable (The Wishsong of Shannara)
Sat, 25 May 2013

Huffman Coding

When you sign up for something on the Internet, there is often a web form asking you for your country of residence.

That is a pretty long list. Fortunately, your browser will let you type the first letters of a country to select it. Unfortunately, that still does not work too well.

You need to press four keys for China:

C Cambodia
H Chad
I Chile
N China
And you need to be quick about it, for if you take too much time marvelling at these exotic places you are presented with and wondering what percentage of visitors hails from there, the browser will cancel the sequence and you'll get
C Cambodia
H Haiti
I Iceland
N Namibia
You can also repeatedly press C, and that will get you a tour of
Cambodia
Cameroon
Canada
Canary Islands
Cape Verde
Cayman Islands
Central African Republic
Chad
Channel Islands
Chile
China

Every such drop down menu should put the country the web site thinks you are in at the very top, and the six countries that make up the 95% of its visitors should get their own little list after that. Only then as a last resort the full alphabetical listing (including a repeated second entry for the countries in the short list).

Sun, 12 May 2013

94.242.237.93

Well, that's what you get for putting up a completely unprotected wiki that anyone can edit anonymously.

Installed a simple CAPTCHA plugin as an anti-spam measure, will see how that works.

Sat, 11 May 2013

Rust

Mozilla is working on a prototype for a next-generation web browser engine, and in order to make it easier to write complex, high-performance (but still maintainable and bug-free) software like that, they are working on a new programming language to go along with it.

A few decades down the road, it seems that the hope of hardware improvements making the performance costs of automatic memory management as offered by high-level languages like Java, C#, Perl, Python, Ruby, Javascript acceptable for everyone is not going to pan out. At the same time, having to manually manage your pointers in C or C++ remains a constant source of bugs and security problems. So what we get in Rust is "memory-management as a first-class language construct": You have to decide where and when you want to allocate memory for your objects, you have to work with pointers, and you have to understand how those pointers work. But the compiler understands them, too, and makes sure that you only handle them in safe ways.

I had a taste of this concept with Objective-C's Automatic Reference Counting, which follows a similar approach, but Rust is much more thorough. It is, after all, a whole new language designed for this, not something bolted on to an existing system.

The simplest way to allocate an object (a struct) is to allocate it on the stack.

let x = Point { x: 1, y: 1 };

If you assign this to something or pass it to a function, you would be making a copy of the whole thing every time.

let y = x;  // makes a copy
foo(y);     // makes another copy

One way to get a cheaper way of passing the data around is to make a pointer.

let y = &x;   // pointer into the stack
foo(y);       // pass the pointer around

This is called a borrowed pointer, and Rust imposes a number of limitations on what you can do with the pointer, and what you can do with the variable it points to. This makes sure that you won't get into a situation where pointers have become invalid.

Another way to pass data around is to put it into a box in heap memory. That obviously becomes necessary if you want that data to survive the current stack frame (i.e. function invocation). But it is also necessary if you want to create recursive data structures like trees, which, lacking a fixed size cannot be allocated on the stack.

There are two types of boxes, owned boxes and managed boxes. An owned box exists as long as its owner exists. Ownership can be transfered, but there can never be more than a single owner at the same time.

let x = ~Point { x: 1, y: 1 };  // owned box allocated on the heap
let y = x;   // now y is the owner, and x cannot be used anymore

Managed boxes are also created on the heap, but they enjoy garbage collection and can have multiple owners. Rust's memory model is tightly integrated with its concurrency model, which is built on lightweight "tasks". Each task gets its own stack, and garbage collection also happens task-locally. As a result, managed boxes cannot be used to share data with other tasks (neither can borrowed pointers, communication always necessitates ownership transfer).

let x = @Point { x: 1, y: 1 };  // managed box allocated on the heap
let y = x;   // now both x and y point to the same thing
Mon, 29 Apr 2013

iPad mini Accessibility

Cissy returned from her business trip to Singapore with two white iPad mini, one for herself and one for her parents. In the process of helping them set it up, I noticed that they had a bit of a hard time making out the smaller on-screen elements. So we took a look at the built-in accessibility features. The two most promising options in the Vision department are "Zoom" and "Large Text". Large Text increases the font size, but it only works for text (and not for other elements like buttons), and only in applications that support this feature. Zoom on the other hand works everywhere: Double-tap with three figures to get a 200% magnification of anything. This is handy, but it requires some getting used to, because you cannot see the whole screen at once anymore and have to zoom in and out (or pan around) all the time.

But what works really well is running iPhone apps in "2x" mode.

iPad has a compatibility mode that allows it to run iPhone apps, either centered in their original size (i.e. taking up only about 20% of the screen), or blown up at 200% to fill most of the display. This feature almost certainly only exists to give iPad a head-start back in the day when there were no native apps for it, and has not received much attention from Apple ever since. For example, it looks more pixelated than it really has to. But on the other hand, whereas very few apps are designed with accessibility support in mind, a lot of energy goes into making apps work well on the iPhone, and most of those are quite usable if you just increase them in size, especially on the iPad mini (it does look unwieldy on the full-size iPad).

Of course, this only works for iPhone-only apps. Apps with iPad support will show the version optimised for the tablet (which may be sub-optimal if your vision is poor). So I think it would make for a good addition to the Accessibility settings to have an option to run apps in iPhone mode, essentially turning the iPad into a big iPod touch.

Speaking of Accessibility settings, a lot of people in China (maybe even the majority) have enabled AssistiveTouch on their phones. This gives you a software home button that you can dock to any side of the screen and tap to get a popup menu with common commands.