How to name things – thesaurus tip

I’m not particularly good at naming things (variables, methods, functions, classes, modules, etc.). Long time ago George (a colleague) and I were trying to think with “a better name” for a class but none of us had any good ideas. He suggested to use a thesaurus to check for synonyms, related words, etc. and start thinking which of the words would match it or not.

I thought that was a great idea! And actually it was mentioned very briefly at the talk “How to name things” from Peter Hilton (I saw it at ACCU 2015). If I were the presenter I would have explained the thesaurus method for naming things a bit more than he did.

One of the public results of the thesaurus method is my Github repository named potpourri (my first thought was “miscellaneous). Actually, the inspiration to have a github repository for small scripts and not named miscellaneous came when I saw mandrawer from Robert, another Mendeley colleague.

Wattpad story scraper

I wanted to read a story available on Wattpad.. Sadly Wattpad makes people read from phone devices (Android or iOS) instead of giving an epub file. And I really dislike reading from my mobile phone, I wanted to use my e-reader.

I searched on the Internet and I found quite a few videos on Youtube with complicated instructions to download a .jar and find the epub inside (it didn’t work for me, maybe they changed the website). Or to download the book into the mobile and then get the file (which is not easy anymore with Android 5.x, or at least I couldn’t do it easily. I think that I had to root my phone which I haven’t done it yet).

Finally I found the solution: a fantastic Python script! Called wattpad-ebook-scraper.

I know that people without handy Python (Window users) might have problems to use it… but for many other people it’s a very convenient way to create an epub file from Wattpad.

OpenVPN traffic measurement

After setting up the OpenVPN server I wanted to measure how much data the clients were using. I didn’t want to limit it but have an idea of how many MB they used.

I searched quite a lot on the Internet but I didn’t find a good solution. I’ll present my solution here.

In the /etc/openvpn/server.conf (or similar file for your server configuration) add the lines:

script-security 2
client-connect /etc/openvpn/scripts/client-connect.sh
client-disconnect /etc/openvpn/scripts/client-disconnect.sh

Then create the files client-connect.sh and specially client-disconnect.sh.

Using this will log the number of bytes used by a connection like:

Apr 14 23:18:31 localhost openvpn: Session $Client TX: 592794812 bytes RX: 42195316 bytes Duration: 11679 seconds HostIP: $IP

Then we might want an easy way to show the number of MB to make it easier to read. For example, using this script in Python:
Apr 14 23:18:31 $Client TX: 565.333187 MB RX: 40.240589 MB 194 min. $IP

So doing this finally I had the information that I wanted.

OpenVPN configuration for Android

For different reasons I wanted to setup an OpenVPN connection so my Android phone could connect to my Debian Wheezy VPS and from there to the Internet.

I followed this tutorial and was very good (I failed with another tutorial). And I generated the .ovpn that is needed for Android using the script that I wrote.

So the steps in a nutshell:
* Follow https://stavrovski.net/blog/how-to-install-and-set-up-openvpn-in-debian-7-wheezy
* Find the configuration for the server side and the configuration for the client side (Android or other clients like Windows or Linux)
* Generate the .ovpn
* Use OpenVPN Connect Android app
* Open the generated .ovpn file with the OpenVPN connect: connect!

Enjoy!

How to generate OpenVPN .ovpn configuration file

I followed this amazing tutorial and I had a working OpenVPN server.

One thing that I wanted to do is to create .ovpn files. So instead of having the configuration, certificate, private key, etc. in different files I wanted to have everything in the same file.

I found on the Internet how to do this manually, but I wanted to generate different .ovpn for different clients, so I wrote a small Python script.

Feel free to use it, it’s available in the potpourri github repository.

Internet in China: experience from a visitor

On my recent trip in China I used the Internet. I knew of the Chinese Firewall but I didn’t investigate much before going there. I just thought… I hope that I’ll have access to my small VPS server or to my home computer using ssh and from there I can just use SOCKS or something else if I need to. I didn’t have any VPN at that point.

I couldn’t access google.com (but one can access google.hk, the Hong Kong one). And I realized that I do access google.com more often that I thought… and I couldn’t access wikipedia.org (!!). Youtube.com is not accessible, facebook.com, twitter.com either. Or Dropbox: not possible either and I found about Dropbox after uploading the photos of the trip when I was back in London and I shared the links with the Chinese friends (and sadly, and for the first time, I paid one month to Dropbox to have more space… but it wasn’t useful).

I could access my VPS server without problems which was great! (and where I could share the photos after all).

I had my ssh + SOCKS server but from the two hotels where I was the Internet connection was so slow! Downloading files from Europe was about 30 KB/s (just downloading, no SOCKS server or anything like this).

Some days I was just using SOCKS to have “normal Internet”. But on other days I was trying to use “Internet as the Chinese use it!”.

There are many dependencies with Google services: I wanted to download an app for the phone and the app store didn’t work. Or, the thing that surprised me the most: I bought an Easyjet plane ticket without problems, but then I was buying a ticket from Vueling.com. Interestingly during the process of buying the browser stopped responding. I was having a look and the problem that their website use some Javascript from Google: which was not available!

I asked a few people. The ones that have international friends know how to use proxies and VPNs. The other ones, without international friends: they just live in the Chinese Internet.

According to Wikipedia it seems that they do this for control and also to help to Chinese alternatives (and I guess that they can control the Chinese alternatives better than international ones).

A few things that I observed in China

In China I tried to keep my eyes open as much as I could. I also have my camera handy all the time to try to take pictures of things that I see and that I don’t want to forget.

A few things that I observed and that I haven’t seen much in other places…

Chinese sit to take breaks in a squatting position
I saw many people using their phones or just resting in a squat position (almost sitting on the floor). I can’t stay in that position for long time, but it seems that the Chinese can.

I have the theory that they are used to that position a bit more than Westerners because they have quite a lot of toilets that are only a hole on the ground (without a toilet seat) so they are more experienced in making this position.

A Chinese woman said to me that she knew some Westerners that had to take breaks when using the toilet! Like a few minutes squatting, then standing up, then squat again!

On the underground: Chinese use mobiles
I saw many people using their phones on the underground… but I realized when I was back in London that Chinese don’t read newspapers on the underground! They don’t seem to have anything like “Metro” or “Evening Standard” (free newspapers). Also, some people read books but I’d say that there are fewer than in London.

They walk backwards (for exercise)
Every now and then, specially in parks, I saw people walking backwards. I asked why: they think that it’s good for the health, specially if it’s on a slope.

I tried it and I have to say… I liked it! I could feel that I used different muscles than walking forwards.

Benches app (for iPhone)

Finally the app is live! Available for iPhone users! You can find the benches near you! Get it from the iTunes store.

A friend of mine from eVolutive and I (more him than me) have create an app for iPhone where you can find benches near you. It uses the data from Open Street Map.

Why we did an app to show the benches around us?
I had the idea when I was walking the London LOOP. Quite often I asked myself: should I stop here and eat my lunch or keep walking and find a bench? How long for? Is there a bench nearby that I can’t see?

I looked around and OpenStreetMap has benches (obviously not all, and the quality of the data depends on the zone). Using OsmAnd I could, after fiddling with the user interface, see the benches. But it was complicated and not user friendly.

At the same time my grandfather had mobility problems because of his age. I thought that in years to come I might have the same problems as him, and at that point I better have an app like Benches so I can get out and when I need I can search benches nearby to take a break. He won’t use it because he is not into gadgets and technology, but when I’m old I hope that I’ll still like playing with phones or the technology that we will have at that time. So I thought I should start the app now and keep adding benches as I go because when I’ll be 80 years old I might need the benches there, and not adding them.

So, if you like, search for “Benches” on the iTunes store and test it. If benches are missing in the app you can add them in OpenStreetMap (using the usual OpenStreetMap tools) and in about one week they will be imported into the Benches app.

Ah, and last but not least: Benches app also shows drinking fountains and toilets. We might add more things or show other things in the future but we want to keep it simple and not reimplement OsmAnd or a mapping app.

Two surprises from China

My recent trip to China was all very good… and I had two good surprises due to some misconceptions.

I liked the food
I was in China for 2 full weeks and… I liked the food! Actually, I didn’t get bored with the food. One reason is that I was very well guided to the very big variety of food that they have there.

I had two misconceptions:
a) I thought that almost all the food was based on rice and noodles. I thought that during 2 weeks I would have to eat rice or noodles every day… and it’s not the case. They have lot of food without rice and noodles are common but there are options
b) I thought that lot of Chinese food would be spicy. I don’t particularly enjoy spicy food and I didn’t fancy eating spicy food for the whole two weeks. I ate some spicy food but it was easy to avoid, and actually it wasn’t too spicy, even by my standards.

After discovering the very good Chinese food in China food I learnt that London China town has lot of Cantonese food because the first immigrants were from Hong Kong, since it was easier for them to come to London than mainland Chinese.

In that 2 weeks I almost didn’t repeat any dish! This is quite amazing!

They are much cleaner than I thought
I knew that Chinese people spat. I knew that some Chinese restaurants in Barcelona got closed because they were not clean enough. I knew that Chinese restaurants are usually cheap (why so cheap? Bad food? Bad process?). And that Chinese restaurants cut the meat in very small pieces (suspicious, is it because the meat has low quality and they cut it small to hide the bad quality meat, compared with a cut of steak?). Because of all this inputs I expected the hotels to be dirty, and the restaurants to be filthy. I was very wrong.

Staff in restaurants used gloves, fast food chains used masks to avoid contaminating the food while talking across the food. In some places the glasses and bowls were wrapped in plastic to avoid getting dirty while on the table. The hotels were very clean. I have no complain at all!

It’s true that, in some very cheap places where I could see how they prepared the meat, I saw things falling on a dirty floor and being put back again to cook. But that was in very cheap restaurants, almost street food.

Regarding the meat being cut in small pieces: besides creating some more work places, it’s more energy efficient to cook meat cut in small pieces than in big pieces (like a steak). Now even this makes sense! And, of course, it’s chopstick friendly!

Table tennis in China

When I came back from China a few friends asked me: did you play table tennis? How it was?

Well, I think that this was the biggest failure of my trip. I didn’t play! I didn’t see them playing! And I tried, quite hard!

As mentioned, I have a friend in Dalian (north-East China) and she doesn’t play table tennis. This is not a big problem: she has a colleague who plays (I suspect that only socially, not as a sport or at a competitive level). I thought that joining the friend’s colleague I would go to some recreation centre, sport club, etc. in Dalian where I could play with the friend’s colleague and then maybe with some other people as well, since I thought that the Chinese would be excited to show how to play a foreigner. Sadly she had a last minute health problem and couldn’t make it… and she had a backup plan but the backup person couldn’t make it either.

Two weeks before I went to China I posted a message to the CouchSurfing Beijing group. Three people answered:
a) A Canadian guy who plays but we couldn’t meet
b) A German girl who also likes playing (and we couldn’t meet either) (at that time I was thinking… why only non-Chinese!?)
c) A Chinese girl who… DOESN’T PLAY!

I expected more Chinese to answer the message. Maybe CouchSurfing is not that popular in China but it was a bit of a disappointment.

In Beijing I had some more free time and I thought that I would search on my own. I had a few options:
a) Sports street. I found on the Internet that there is a street full of table tennis shops near Heaven’s temple. I went there, saw the shops but didn’t see where to play.
b) “Some vague references” from the Internet. Apparently there is a shopping mall in Wangfujing Dajie and very nearby a table tennis club. I walked the street twice but I didn’t find the mentioned shopping mall (for which I even had the name) and then I ran out of time. I wanted to see the shopping mall and ask where to play.
c) Parks. Internet suggests that many parks (and one in particular) have table tennis tables and Chinese people plays there. Actually the weather was good enough for this. I did walk in many parks, tourist and non-tourist parks. I swear that I didn’t find any table tennis table! I did find people playing cards, Chinese chess, dancing, Tai-Chi, singing opera, etc. but not table tennis.

I was expecting more table tennis tables, perhaps not everywhere but in many places. I understand that I didn’t search for the clubs and recreation places properly, but I didn’t because I thought that it would be easier to play in the parks.

I plan to go to China again – next time I’ll go better prepared, at least with GPS coordinates with tables where to play!