A swimmer turned cyclist turned swimmer again

Sunny weekends are always a great time to pedal a bike. Cyclists spend practically all weekend in the saddle and enjoy the sunshine, greenery and scenery. Cyclists in Tokyo are no exception. They usually wake up as early as 4 a.m., head for rural areas 50 or more miles away from where they start or pack their bike into a small bike bag and get on a train in order to avoid Tokyo’s dangerous roads.

Tokyo’s roads weren’t designed to be shared. Many of them weren’t even designed for motor vehicles. They usually remain the basic structures of centuries-old passageways, trails and ancient highways. Although most of these roads have been continuously widened, the overwhelmingly majority of Tokyo’s public streets are still narrow and contain unnecessary curves and turns, and to make matters worse, they are always full of illegally parked cars that push away urban bikers and bike commuters to the sidewalks. There’s virtually no bike lanes if not there is no space for bicycles at all. Osaka and other Japanese cities are not that bicycle-unfriendly. Some are even very nice. But Tokyo and its surrounding areas are the exception! Tokyo is definitely the worst place for cycling in this country.

Up until recently, I was one of those early bird hobby cyclists who spend every Saturday and Sunday biking mountain passes and summits. I still love going to the mountains. I just can’t stand Tokyo’s dangerous roads, traffic light waste time and too much vehicular and pedestrian traffic any more.




One day I was heading for Tominnomori, a nature preservation area literally translated as Tokyoites’ Forest park, I got caught in a traffic jam. Tominnomori is a popular cyclist destination in this area and located 3,280 feet above sea level. It attracts not only cyclists but also a lot of motorcyclists and auto enthusiasts. The only road to the area was crowded. And it was cold. Freezing cold. I had already spent more than 5 hours to get there, been stopped by dozens of traffic signals and of course totally exhausted. Then I got caught in a traffic jam. I remember that that was the moment when I decided that this is insane. This is absolutely unacceptable. Painful, even.

Tominnomori

Since then, I have gotten off my bike. I didn’t want to associate these feelings with my beloved bike. There are many spectacular places out there. Even in Japan, there are a plenty of cycling destinations that are much more attractive, breathtaking and do NOT have this problem. But they are usually hundreds miles away from Tokyo.

Niigata

Hiroshima

Miyagi

Yamaguchi

Although I have been doing everything to move out of this town, it’s not that easy to move from one place to another in a short period of time. People here rarely change their careers. Job opportunities are kinda limited. My girlfriend, who is European by the way, may not want to live outside Japan or the Schengen area, while I’d love to live and work in North America.

And in the mean time, I need a place for my daily workout. In the last winter, I ran very early in the morning. Before rush hour took place, the sidewalks were vacant and peaceful. As spring came and the temperature rose, however, they became gradually crowded. It was time to try something new. Something I hadn’t been doing in years.

I’ve started going to the swimming pool that is free from crowds, frustration and fear of dooring accidents. Well, admission fees for public swimming pools in Tokyo cost $ 3.5 – 5.5 (400 – 600 JPY). But they are no different from the train fares Tokyo’s cyclists have to pay, when they try to avoid the crowded streets by rail. And it doesn’t take hours to get there! I can go there 5 days a week and swim at least half a mile every time I go there. I am really happy with that.

Several weeks have passed, since I visited the swimming pool for the first time in more than a decade. On the very first day, I felt discomfort in my chest, back and upper arms. I also found it strange that I couldn’t breath when I needed the most. As I swam fast, I almost drowned in the water, because I too easily lost a chance to breath. When you cycle fast, or run fast, you never care about shortage of breath. I was too used to cycling and running and forgot about breathing intentionally. But it became OK in just a few days. I have gotten used to the water. Things have been going well so far.

What you can do when your Android Studio could not start AVD on Ubuntu 18.04

After experiencing repeated sudden system crashes, I decided to update my Linux environment. Since then, my Android Studio stopped working properly. Several problems were found with the AVD, JVM and Gradle project sync and so forth. And I needed to spend my weekend fixing one problem after another.

I had kvm installed, added myself to its users group and rebooted the system.

$ kvm --version
QEMU emulator version 2.11.1(Debian 1:2.11+dfsg-1ubuntu7.2)
Copyright (c) 2003-2017 Fabrice Bellard and the QEMU Project developers

$ kvm-ok
INFO: /dev/kvm exists
KVM acceleration can be used

$ ls -l /dev/kvm 
crw-rw---- 1 root kvm 10, 232 May 28 18:20 /dev/kvm

$ grep kvm /etc/group
kvm:x:128:femoghalvfems

Still it didn’t make any difference. The IDE kept showing the message “Error while waiting for device: Could not start AVD” and would never start the emulator.




This gave no clue what was going on. There had to be permission problems, I suspected. I changed the permission of the directory.

$sudo chmod 777 /dev/kvm

Of course, I knew it is usually not a good idea. Granting the full control permission to everyone would pose a threat to the entire system and even possibly cause another problem. But it worked, anyway. As I changed the directory permission, I became able to build apps using Android studio.

Unfortunately, the case was not yet closed. In the following hours, I got another system crash and had to reinstall the whole system from a bootable flash drive. My workstation contained NVIDIA and CUDA property drivers that conflicted with some other modlues from time to time. They froze all the processes and threads. I could not even raise skinny elephants.

So I reinstalled Ubuntu 18.04 LTS on my workstation and tried building apps with the latest Android Studio.

This time, I could open the AVD by simply adding myself to kvm user group. And it worked well! I didn’t do anything other than newly install a series of the required virtualization tools and add a new user. And it worked!

$ sudo adduser femoghalvfems kvm
Adding user `femoghalvfems' to group `kvm' ...
Adding user femoghalvfems to group kvm
Done.

Now I really don’t know what prevented the IDE from running the virtual machine.

Chinese Word Counting Made Easy with the Command Line

Days ago, I wrote an article entitled creating Chinese/Japanese word clouds in Python. The article was written for a friend of mine who is learning the language for his research in mathematics and mathematical biology. By writing codes from scratch, one can learn data structures and time complexities. Hash tables and their worst case O(log n), binary search trees O(n) or whatever. Not that there is anything wrong with that. It just takes some time to think and write codes.

Instead of writing scripts, I usually get the same outputs from the GNU/Linux command line tools. As you may know, there are many other ways to do the same thing. And it is always a good idea to find easier, faster and/or more efficient ways. You do not always need to write your own code to get what you want.

Counting occurrences of Chinese nouns annotated by Stanford part-of-speech tagger, for instance, can be carried out by typing the following command.

$ < tmp04_zh.txt sed 's/\s/\n/g'|grep -E '#(NN|NR)'|sed -E 's/#(NR|NN)//g'|LC_ALL=C sort|LC_ALL=C uniq -c|awk '{print $2 "," $1}'

It is a simple combination of 5 different commands which produces the same result as the "count_word_zh.py" script listed on my previous post.

sed performs basic text transformations manual
grep prints lines that contain a match for a pattern. manual
sort sorts lines manual
uniq removes duplicated lines manual
awk is used to rearrange the order of columns here manual
LC_ALL=C is an option to remove localized settings that affect the sorting and comparison results

Despite the fact that Chinese text is written in non-alphanumeric, multi-byte characters, you can still take advantage of the major functions of UNIX and UNIX-like operating systems.




The command line tools may help you save time not only in coding but also in running programs. If you handle large input files, you probably think it is time to execute more than one process simultaneously. Many hands make light work. There are also powerful tools that enable concurrent, and even parallel processing.

These are only a few examples of what you can do with the command line. You can actually do a whole lot more without writing a line of code. While I was doing my PhD in Informatics, I was even taught to avoid writing unnecessary code. The single most important thing is to get the results you want easily, quickly and efficiently. The command line tools will be of great help to you in accomplishing this goal.