Friday, July 19, 2019


So I go to work this morning, and just as I get to my desk, our car emails me to tell me I forgot to lock the door. I had parked by the outside wall of the parking garage and the key fob has a fairly long range, so fortunately I could walk over and lock it from the ground without having to climb two floors.

The future has a way of creeping up on us without noticing.

LED lights is another revolutionary change we don't even think about. But it's almost as big a change as going to electric bulbs from gas and oil was a century ago.

Apparently the future still includes propeller aircraft and disembarking right onto the runway. This makes me irrationally happy.

Friday, June 28, 2019


Fifty years old. That's almost half my life gone. Half? Our first 15 years are spent learning how to be a human, then how to be an adult. I've spent thirty-five adult years so far, and I can likely expect to have another thirty to forty. That's enough time for at least another whole new career, by the way.

The second half of our lives is not the same as the first, though. Our joints wear out. Our immune systems get weaker. Old sins catch up with us. Heart disease, cancers, neurological issues, autoimmune diseases — the list of things that can get you will get longer every year.

When I started running a year ago, it wasn't just an idle whim. I'm already feeling the effects of ageing, and I can see the writing on the wall as well as anybody. I need to take my health seriously right now if I want to stay healthy and active the next few decades.

The secret of long, healthy lives isn't secret at all, of course. We know how to live long and stay healthy. Exercise, eat mostly plants, eat and drink in moderation, don't be sedentary, have an active social and intellectual life, get regular check-ups and never ever smoke.

In addition to running I've stopped drinking heavily. I had a lot of fun partying in my 20s, and I bounced back quickly from a night out. But I'm not really enjoying it any longer, and I certainly don't "bounce back". If I drink one evening the whole next day is wasted. I still enjoy a beer or two on a weekend — but I no longer drink more than that.

And yes, regular check-ups have become part of my normal life. Blood tests, dental care, EKGs and ultrasounds. I had a gastroscopy last month and it's time for my every-few-years colonoscopy next week — not exactly the anticipated event of the year, but it's a low-risk, low discomfort insurance against some very nasty high-risk conditions.

(I can get some) Satisfaction

On the other hand, it's often claimed that life satisfaction gradually drops from a high in your 20's to its lowest in your 40's. But as you continue to get older it rapidly rises again, and by the time of retirement satisfaction will surpass your 20s to reach the highest level it will ever be. I can easily believe it.

I'm certainly in a good place right now. I have an interesting, varied job that I look forward to every morning; I and Ritsuko have a close relationship and fun daily life together; and I'm free from the stresses and doubts of my younger self. Yes, I'm happier and more content than I have been in many years, and perhaps ever.

We have both marked some noteworthy milestones this year. Rather than giving each other individual gifts we decided to splurge, and got ourselves a new car as a joint birthday gift.

2019 Prius. It's blue. It's also very comfortable. And blue.

It's a 2019 model Prius, with more functions, more extras, more automation — and more computers — than you can shake a sizeable stick at. Many things, such as automatic windshield wipers and the connected Android app, are surprisingly practical. Some things — self-parking — aren't really. Some, such as the ability for the car to post updates on Line, we haven't even enabled yet.

From one perspective it's fair to say a modern car really is a complex computer system that just happens to be mobile. You have half a dozen serious computers and perhaps hundreds of microcontrollers, all connected through a hardened internal network that handles real-time data traffic in harsh environmental conditions. The wheels and engine are almost incidental.

With all that said. my favourite function — by far — is the seat ventilation. A couple of fans connected to the AC blow air through holes in the leather seat and back. This keeps your back cool and dry no matter how hot it gets. For the first time ever I can get to work in summer without my t-shirt sweaty and damp after an hour in the car. A small thing, but so very much worth it.

Tuesday, June 18, 2019

Bonsamatic Dot Com

This is a long and slightly geeky post about refreshing my home server. But I also add in a bunch of mostly irrelevant Osaka photographs, so feel free to scroll past the text and look at the pictures. They are, by the way, taken with the excellent Fuji GF670 folding camera on Kodak Ektar 100 (color); and with the Pentax 67 on Ilford delta 100 (black and white).

Nagai station, Midosuji line, Osaka.

I've had a small server at home for some years now, first only using my desktop for an RSS reader, then setting up a dedicated machine with its own public IP address. I've upgraded it once since then, but kept the installation pretty much the same. I never got around to getting a proper hostname, so I always accessed it directly through the IP address.

In March, the drive suddenly developed an issue ("suddenly" - it was five years old already) and the server went offline. I couldn't do anything about it from here in Naha, but as we planned to spend the Golden Week holiday in Osaka I decided to rebuild the whole thing when I got there. I would have to replace the failed disk, and I wanted to add more storage. Also, while the software worked it felt unreliable and difficult to maintain.

Sleepy. Amemura, Osaka.

Set up the Hardware

I got an SSD to replace the faulty drive, and an external USB hard drive for bulk storage. The computer itself - a six year old Intel NUC with 8GB of ram - is still fine, and more than fast enough for a server like this.

I installed Ubuntu server (using our TV as a monitor). The only tweak I had to do was to use NetworkManager instead of Systemd to set up my network; Systemd lacks support for PPPoE connections that I use to get my public IP address. plug in and format the external drive, and the hardware was ready.

Connecting. Shinsaibashi, Osaka.

The Web Server

I didn't want to keep the messy server set-up I used previously. To set up a real web server with a proper domain and secure connections we need the following things:

  1. A web server. I'll use Nginx.
  2. a fixed IP address. I already buy one from our internet provider.
  3. A domain name. This is the name we want for our server; something like "", "" and so on.
  4. Set up encryption with SSL. The internet is a dangerous place these days, and we want all communication to be encrypted.

I installed Nginx from the Ubuntu repos as the main web server. It's fast, light on resources and straightforward to set up. Also, it's really well suited for redirecting requests to other applications, which is exactly what we'll want to do. I created a quick web page just to have something to look at.

Up until now I had used the IP address. I was the only one using the server so that worked, sort of, but it's ugly and clumsy, and I can't get a real SSL certificate (used to encrypt the communication between server and clients) without a domain name. Domain names are cheap, so there's really no reason not to get one for myself.

Crepe L'Oriant. Minamisenba, Osaka.

Domain Name

There are many, many domain name sellers around. They range from expensive business oriented full-stack providers to cheap sellers with hideous websites, sketchy business practices and lousy reputations. In the end I went with Namecheap, for no better reason than that they're on the FSF recommend list and their website doesn't make me want to gouge out my eyes with a fork.

Buying a domain name is very simple, and the setup is, again, fairly straightforward after a bit of googling. I got after my plant watering project a few years back. I point the "" subdomain and "" to the server, redirect "" to "" and everything else to an error page.

For the SSL certificate I use the amazing (and free!) "Let's Encrypt" provider. It's, again, recommend by the FSF, and let's you set up a reliable and secure certificate for your site with very little pain. You add the "certbot" repository, install the script for your webserver (so "python-certbot-nginx" in my case) and run the script with parameters for the domain names you want to use ("" and ""). The script then automatically configures your web server to use SSL encryption properly.

Let's Encrypt does another, clever, thing: It is set to expire in only 90 days. Sounds like a bad thing, I know, but it also let's you renew very easily by just running that script. The script sets up a periodic job that automatically checks if it's time to renew every so often. The clever thing about it is that the short expiration period forces you to set up automatic renewal, and to make sure it actually works. With a long expiration date it would be easy to neglect setting up automatic renewal, and to forget renewing it at all.

We have everything we need: a web server, a way to reach it (as ) and proper encryption to keep the conenction secure. We even have a small place-holder website, just to have something to look at.

HEP5, Umeda. Osaka.


I'm using my server for a few different things. It is the backup target for my other computers, but this is very simple: I run "rsync" on the machines to the external disk on the server. All I need for that is a working SSH connection. I also use it for my git repositories. But again, a working SSH server - included by default in any linux distro - and git is all I need. Trivial.

Neat architecture. Nagai, Osaka.


Nextcloud is a very useful "personal cloud"-type application. It gives you remote storage on the server that you can synchronise to your desktop and smartphone (there's apps for both Android and iOS), and you can share data with others using a browser or an app, very much like Dropbox. You can use it to upload pictures from your phone and share with others. But it's much more than that.

It has a large selection of "apps" you can install that add more functionality. The "Notes" application, for instance, lets you write and synchronise notes anywhere; I can work on blog posts like this one from my work computer, my desktop, and my smartphone (I'm using it right now). There's also calendar apps, email clients, image gallery viewers, collaborative editing tools and lots of other stuff.

One thing that's particularly interesting is "Nextcloud Talk". It's a full chat and video call application (using WebRTC) in your browser or using a dedicated Android app. On the Google app store it's cheap and will support the developers; but it's open source so you can also download it from F-Droid for free if you like. I haven't tested it a lot, but it seems to work well enough so far.

Complicated! Nagahori, Osaka.

Installing Nextcloud is intimidating. Like most web apps it is a complex beast with many moving parts. If you get something wrong it may refuse to work; or worse, will leave gaping security holes open to the internet. Fortunately Ubuntu has "snaps", self-contained packages with all the programs and configurations an app needs.

The Nextcloud snap contains nextcloud itself, along with PHP, MySQL and all the other bits and bobs it needs. Installing nextcloud becomes as easy as "snap install nextcloud", then edit the Nginx config so "" points at the nextcloud app.

I have one minor issue: Snaps are sandboxed and secure — this is a good thing — but it means that I can't give the Nextcloud snap access to the external drive. That's still OK, as I'm not storing any large data sets in Nextcloud, but I would have preferred to use the external drive for storage.

Very retro. Kobe.


I still use RSS to follow blogs, news and comics. You can simply use a standalone RSS reader without a server if you want, but then you can't synchronize the feeds across different devices. You can also use an online service (Feedly looks nice) if you like. For various reasons I prefer to host my own. Up until now I've been using "Tiny Tiny RSS" as an RSS server. I used the web client on my computers, and the TT-RSS app on my phone. It worked well enough.

But the Tiny Tiny RSS developer doesn't inspire confidence. He doesn't do releases at all, and is actively hostile to people packaging it for distributions. Instead you clone his repository whenever you want to update and trust that it doesn't break anything. The developer himself is rather abrasive and the forums are unfriendly. I really don't want to continue to rely on this software.

Fortunately Nextcloud has come a long way, and one of the apps is "News", a full-fledged RSS server and webapp, with an Android mobile client. The app itself is trivial to install: look for "News" from the list of available apps, click "install" and you're done. If you have a list of feeds in OPML format from another reader, you can import them from the settings. It works quite well on both web and mobile, and I'm not missing anything from TT-RSS. I do wish there was a "recently read" category, but that's just a quibble.

Midosuji line, Osaka.

And From Here

Setting up this server was fairly painless; much easier than the last time I did this. It took perhaps one full day in total, and that included a lot of googling and playing around. A lot of my time was spent figuring out the right domain name settings, and even that wasn't difficult, just time consuming. I also spent a lot of time double-checking that I really understand what all the Nginx and Let's Encrypt configuration settings actually do.

Next I want add some actual content to the website (I don't need a site, but now that I have one I might as well use it for something). Also, I want to test the Nextcloud Talk service a bit more; as Google is killing Hangouts this fall it might be a decent alternative for keeping in touch with family and friends.

If you have any ideas of what else I could use this server or the website for, please tell me! I feel this has a lot more potential for use.

Work is over. Relax. Nagai park, Osaka.

Sunday, May 19, 2019

- One Year On

I have been running for a year now. My goal was to make this a regular habit, and I think I've succeeded. I run four times a week, for a total of 35-40km. Usually I run three times over lunch on weekdays, then a longer run on the weekend.

When I started I doubted that I would persevere for more than a couple of months. I thought I would hurt, I would get bored and I'd soon make excuses not to go out running any more. But running turned out to be quite fun and very satisfying.

Distance I run per week (green bars) and the average Polar "running index" (red line).

I believe the image above sums it up nicely. I went from complete beginner to 35-40km a week in about 6 months. The "Running Index" is a proprietary index of how good a runner you are. But it's really little more than the ratio of your heart rate and your running speed, with a log scale factor to account for the distance.

You see a lot of stuff when you run. Here a tiny "dekotora" ("decoration truck") near the airport in Naha.

Our heart rate is directly proportional to our effort. As we work harder our muscles need more oxygen, so the heart will beat faster to deliver it. As we get more fit our muscles become more efficient at using the oxygen; our lungs can deliver more oxygen to the blood; and the heart is able to pump a larger volume of blood with each beat.

Figuring out a detailed measurement is a little complicated. But you can divide your speed by your heart rate for a simple index of how well trained you are - a higher number means you are faster for the same heart rate, and so you're better at running (or whatever sport you do). Of course, as you run for longer you will get more tired, so the number will drop. To account for that you can adjust it with a logarithmic scale factor that depends on the distance. Something like

"index = log(a*distance) * (speed/heart_rate)".

You could find out "a" by fitting it to running data from a bunch of runners, so that the index is about the same from the beginning of a run to the end.

So if I'm getting better then why has the index been dropping since April? Summer, is why. Our blood doesn't just supply oxygen; it also cools us down. It transports heat from within the body out to the skin where our sweat will take it away. But any blood diverted to our skin is blood that's not going to a muscle. Our hearts have to work harder, our muscles get less oxygen, and we are running worse through no fault of our own. Our efficiency — and the running index — is similarly affected by hills, by humidity, by altitude and many other factors.

My weight over the past three years. The line is a two-week average.

I've also lost the weight I've gained since coming to Okinawa. In Osaka I got a lot of exercise from walking and taking the subway everywhere. Since coming to Okinawa, though, I mostly travel by car, and my job gives me little stress and plenty of free time. I gained about 3kg in the year and a half since coming here.

But since I started running I've dropped from 75kg back to 68-70kg. That's not mainly due to the running; exercise by itself doesn't make you lose weight. If you exercise more, you'll also eat more to make up for it. But I'm careful with what I eat and drink now (I've mostly stopped drinking alcohol) and in combination with running it's had a large impact on my weight.

Sunset in Osaka. Drawback of running is, you can't bring a good camera.

I really enjoy running. It's especially fun to run longer distances, and to explore new areas while running. I've been tempted to increase my distance and increase my pace even further, but I tend to get knee pain when I do. Stretching and other exercises help a bit, but ultimately I have to limit my distance and run mostly slow runs to stay injury free. The joys of growing older, I guess.

Will I continue? Yes, absolutely. It's fun, I feel good and I have no reason not to. I'm even thinking of doing a half-marathon this fall. It's easy enough - I've run close to that distance already - and it'd be a fun event.

Monday, March 18, 2019

AMD GPU on Ubuntu

Summary: I upgraded my Ubuntu desktop to an AMD graphics card; here's my notes on the (very simple) process. You don't need AMDs closed drivers and you don't need any external repositories — everything you need for both graphics and OpenCL is already included in Ubuntu itself.

I built my own desktop in early 2016. Not a high-end system, but pretty fast, with plenty of memory and with great cost-performance. Overall, it's aging remarkably well and will be fine for at least another three years, possibly longer. The exception is the graphics card. The Nvidia 750ti I had was a midrange card when it launched in late 2013, and already a generation behind when I bought it(1).  It has served me well, but by now it's really starting to show its age. Some of my current games only run at the lowest possible graphical settings.

Do people still use desktops? Yes, many do. Do people bring their desktops — and monitor, and keyboard, and mouse — with them when they travel? No, normal people don't. Somebody must have forgotten to tell this guy. Supercomputing 17, Denver.

Worse, the Nvidia Linux drivers — not open source so they must be installed separately — have increasingly been causing problems. I've had screen tearing and other glitches for the past year. The driver now often fails to restart properly after waking the machine so I can no longer put it to sleep. Botched driver upgrades have left me without a usable desktop a couple of times. I don't know if my card is too old to be supported properly, or if the quality of the Nvidia drivers are declining.

AMD is Nvidia's main competitor, and the underdog in the GPU market. They provide full open source Linux drivers for their GPUs. For a few years now, any AMD card should theoretically work out of the box; in practice you always seemed to have to tweak your graphics settings, add unstable or unfinished external components or upgrade your kernel. But for the past year or so, people have increasingly insisted that yes, nowadays it really is as simple as just switching cards, with no messing about with your system.

I didn't think to take a picture of the card until I had already installed it. Besides, for all that I like computers in principle, seeing modern hardware if often as exciting as watching paint dry. Instead, here's a Cray 1 supercomputer on display at the Supercomputing conference in Dallas last year.

So I took the plunge. I got an AMD RX570 with 8GB of memory — a two-year old mid-range card from their previous generation. Not hugely fast, but inexpensive and great performance for the money. The hardware installation is straightforward: unplug and open your computer, pull out the old card then slot in new one. Remember to connect the PCIe power cord to the card, then close the case and restart.

My machine came back up with no issues. The desktop and 3D rendering all worked out of the box. I have no more tearing, and the system definitely feels more responsive. One game was confused by the Nvidia drivers still on the system so I removed them (you can do this from the software center, but it's faster on the command line):

  $ sudo apt purge nvidia*
  $ sudo apt autoremove


While OpenGL support is included out of the box in Ubuntu, the newer, faster Vulkan support is not (these are both standard libraries for rendering 3D graphics). You can install the Vulkan libraries with the following line:

  $ sudo apt install mesa-vulkan-drivers vulkan-utils mesa-vulkan-drivers:i386 libvulkan-dev dkms

What difference does Vulkan make? "The Talos Principle" is a fully immersive 3D puzzle game with a cool storyline that aims for a photorealistic graphical style. It can use either OpenGL or Vulkan. Here's a set of benchmarks with my old 750ti card and my new RX570, with OpenGL or Vulkan, at three different levels of graphical detail:

Dotted lines are OpenGL, solid lines are Vulkan. The blue pair is my old card, the red pair is the new one. The red, horizontal line marks 60 frames/s; you ideally want the graphics to be faster than this at all times.

Take-away: Vulcan is around 25% faster than OpenGL in this game, both for the old card and for the new one. That's a major speed difference just for changing a rendering library. Also, my new card is ~120% faster than my old one. Sounds reasonable for the same class of card about three years apart.


At this point I had a fully feature-complete, well-working graphics system. But GPUs are used for more than graphics these days. You can use GPUs as general accelerators for certain kinds of computations, deep learning and certain kinds of molecular dynamics in particular. We have several dozen compute nodes with very high-end GPUs at work for this purpose (and no, they don't do graphics at all, just computation).

Nvidia is completely dominant today with their CUDA library and compilers, but it's not the only alternative. If you want to do do real compute on an AMD card you should install ROCm, and I intend to do that in the near future. Meanwhile, you can install basic OpenCL 1.1 support using only the open tools in Ubuntu.

OpenCL is an open standard for programming GPUs, and you can use it on AMD GPUs, on Intel GPUs and on smartphones (yes, they have GPUs and yes, they can be useful for this in some cases) and it works on Nvidia GPUs as well. It's not as efficient as CUDA, and it's not as popular, but it still gets the job done, especially if you're just looking to learn.

Today, getting basic OpenCL support for AMD on Ubuntu is easy. Ubuntu already carries all packages you need. Install them with:

sudo apt install clinfo mesa-opencl-icd opencl-headers

"clinfo" is a utility that reports what kind of OpenCL support you have, if any. Run "clinfo" on the command line to see what your particular hardware supports.

"mesa-opencl-icd" (and the packages it pulls in) is the actual OpenCL 1.1 libraries, compiler and other stuff. The "opencl-headers" gives you a set of standard headers for your own code.

There is one single hack you do need to get OpenCL working completely transparently. For some reason, the OpenCL library doesn't get a symbolic link "", and this is needed to be able to link with the library without giving the linker the exact file. You can add the link yourself like this:

$ cd /usr/lib/x86_64-linux-gnu/
$ sudo ln
$ cd

Now you can take any OpenCL program, compile it and run on the GPU. For instance, download this vector addition example: vecAdd.c (from this short tutorial). Compile the program, then run it:

$ gcc vec_add.c -o vec_add  -lOpenCL -lm
$ ./vec_add
final result: 1.000000

There you have it. Full 3D graphics capability using OpenGL and Vulkan (and with working Proton support on Steam); and OpenCL 1.1 support both for running and developing code. All using open source and without enabling a single PPA or going outside the Ubuntu repos. Not bad, not bad at all.

1) Buying the newest, greatest high-end GPUs rarely makes sense. You pay a huge extra cost — in money and in power — for a bit of extra performance and perhaps some new functionality. But games are made to run well on mid-range cards or lower (for as many potential buyers as possible), so that extra cost is largely wasted. They also tend to be physically large and won't fit a small case; and they use a lot of power so you may need to upgrade your power supply and add fans. And as they're new, the drivers won't be as stable or polished. 

You'll spend a lot of money for a computer that's noisy, big, uses lots of power, with frequent graphical glitches and crashes. For all that, you get some nice, cool in-game graphical effects that you notice once then ignore, because you're too busy playing the actual game to notice.

Tuesday, February 19, 2019

The Last JLPT

I retake the Japanese Language Proficiency Test level N1 every year or so. I took level 2 many years ago, but I've never passed N1, the highest level. Honestly, the main reason is that I don't really study for it. The N1 is mostly useful for job hunting or entering university (neither of which apply to me) so I'm just not very motivated.

As it happened, the Naha Marathon was right on the morning of the JLPT. Spent half an hour watching the endless stream of runners passing by as they ran through the city center.

So why do I do it? In part I want to "catch them all". I have all the other levels, and getting the highest one would give me the complete set. But it's also a nice day away from home. I go to some area I'd normally wouldn't visit, have lunch, mill about with hordes of nervous people — mostly young, almost all from nearby Asian countries — then take a relaxing walk on the way back home.

The Convention Center is a really pleasant facility. Most of it — the park, especially — is open to anybody when there's no event happening here.

This year the test was at the Convention Center in XXX on Okinawa. It's a nice parkland area right next to the sea, with a beach and a marina, well worth visiting for an afternoon. The N1 test was in a single, huge room with over 200 seats. The echoes made the listening portion more challenging than usual, but it was bright and airy so not bad overall.

Part of the test hall. Bad shot; sorry about that.

The results came a couple of weeks ago. And I passed.

To be sure, I didn't pass by a lot — 103/180 points is only 3 points over the limit — but still. To nobody's surprise, my reading score was very good (I love reading, after all). The listening was also quite good — it had better be, living here — while the grammar score was lousy. I'm sure all my old language teachers would nod in recognition.

What does this mean? On one hand, I now have all the JLPT levels. On the other, I no longer have any motivation at all to study grammar in the future. And I no longer have a yearly excursion to some random area to look forward to. Maybe it's time to start studying for the Kanji kentei :)

Just a house. It's not notable, it doesn't appear in any guidebook or anything. But it is pretty neat, and I would never have seen it if I hadn't sat the JLPT nearby and walked back.

Tuesday, February 12, 2019


Sweden does not make it easy to renew your passport. The rules are simple: you need to apply either in Sweden or at your nearest embassy; and you need to pick it up in person at the embassy or at a consulate. Simple.

Welcome to Tokyo.

But we live on Okinawa, so I need a round-trip flight to Tokyo (15k yen). And they process applications only on weekday mornings so I need a hotel room (10k) and a vacation day. The passport itself costs almost 20k yen[1]. I have to pick up the passport in person[2] so a few weeks later I have to visit Tokyo or the Kobe or Fukuoka consulates all over again. Another round-trip flight and another day off work. At least I can stay in our apartment in Osaka instead of a hotel if I pick it up in Kobe.

Tokyo. We were lucky with the weather; it was generally sunny and 15-18 degrees while there. The week after it was apparently snowing.

The total cost of my Swedish passport becomes about 60k yen — 5000 SEK or 550 USD. Swedish passports expire after only 5 years, and foreign countries often require at least 6 months validity to enter the country, so I get to do all this again in about another four years.

What to do? Accept the inevitable, and make lemonade of the lemons that the Swedish government has handed you. We take a short winter holiday in Tokyo: go shopping, see a show, eat well and often, and generally enjoy ourselves over an extended weekend.

"Little Tokyo". A fun performance and good music!

We went to see "Little Tokyo", with and by Miyuki Nakajima. She's a singer and songwriter with a large and enthusiastic fanbase, and every few years she writes and produces a musical instead of her regular concert tour. The storyline is often convoluted and a bit difficult to follow, but you really mostly see them for the music anyway.

It was especially fun this year as "Little Tokyo" had a storyline that was actually easy to follow (without spoiling anything, it involved infidelity, ghosts, and animals turning into humans — very kabuki-like). The atmosphere is relaxed and the actors all seemed to enjoy themselves on stage. We had a lot of fun.

Runners along the Imperial palace course. The weather really was great.

I still enjoy running. Nowadays I try to run 4-5 times a week, for a total of 40km. Tokyo is a good place to run — it's largely flat, and has a lot of parks and other areas to run in. By far the most famous and popular route is the 5km circuit around the Imperial palace in the heart of Tokyo.

Imperial palace running course. Yes, those people are all running. Not a great picture — it's difficult to take a good picture while you're running.

How popular is the course? It features in guidebooks and in travel sites. The route has distance markers and permanent signs reminding runners about the rules (run counter-clockwise; keep to the left; be mindful of pedestrians and bicyclists). Running clubs set up camp on the open area at the south-east corner with drink stands, timers and baggage drops. Run stations (rental lockers and showers) is a thriving business in the area.

The outskirts of the Imperial palace is popular for all kinds of activities. Here a couple arriving for wedding pictures. If you run here you do need to be careful.

And for good reason. It really is a very pleasant course. The basic course is almost exactly 5km — short enough for beginners, and if you want to run longer you can either extend the course or run it multiple laps. There's not a single stop-light, and the course is meandering and varied, with a gentle slope up toward the north, then a fast downslope south. And as you run you have the Imperial palace grounds to your left, and central Tokyo defiling past on your right.

The moat by night. Not bad for a smartphone shot.

In all we spent three nights in Tokyo. We did a fair amount of shopping — I got three new books at the Maruzen store just northwest of Tokyo station; they have fairly good mathematics sections in both Japanese and English. We ate well, walked a lot and generally had a good time.

Also Tokyo. That's actually quite a cool bike.

1) If you apply in Sweden it only costs 350 SEK, or about 4000 yen.

2) Sweden — unlike almost every other country I know — doesn't send passports by post. It has to be picked up on site, in person only.