Koterpillar

Arch Linux on MeegoPad

I wanted to replace a Raspberry Pi as a media center with something more powerful, so that the video and the UI doesn't stutter. So I found an Intel Compute Stick clone - MeegoPad T5.

For the impatient: still isn't working properly, but maybe someone else can figure something out.

Booting Linux

Surprise number one: it's a 64-bit platform with 32-bit UEFI. To boot from the standard Arch image, put a 32-bit GRUB next to the 64-bit systemd-boot EFI loader already there (or any other loader which can pass parameters to the kernel) and choose it through the UEFI Shell (F7 during startup shows the boot menu).

Wi-Fi module isn't visible during installation, see below - I had an Android phone acting as an access point.

The installation itself is going fine - 64-bit GRUB can install a 32-bit version of itself. But the booting of the installed system stops at:

Loading Linux ...
Loading initial ramdisk ...

Here's what helped me:

  • Remove load_video from grub.conf. It's not enough (?) to edit /etc/default/grub, had to remove it from /etc/grub.d/10_linux.
  • Turn off Quiet Boot and Fast Boot in BIOS.

Wi-Fi

The Wi-Fi module is a Realtek RTL8723BS. It is detected and started when rtl8723bs-dkms-git is installed from AUR (also see package comments there). Unfortunately the connection isn't stable and after some time stops working entirely. Applying the recommended patches from the driver page didn't help.

Time

(See update below.)

Despite the awful Wi-Fi transfer speed, ping results were looking interesting:

PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=50 time=0.00 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=50 time=0.00 ms
64 bytes from 8.8.8.8: icmp_seq=3 ttl=50 time=0.00 ms
...

Turns out time on MeegoPad is passing... strangely (lanmei in this example):

$ while sleep 1; do echo "Local: $(date) Lanmei: $(ssh lanmei date)"; done
Local: Sun Jan 31 19:37:53 AEDT 2016 Lanmei: Sun Jan 31 19:36:17 AEDT 2016
Local: Sun Jan 31 19:37:54 AEDT 2016 Lanmei: Sun Jan 31 19:36:17 AEDT 2016
Local: Sun Jan 31 19:37:56 AEDT 2016 Lanmei: Sun Jan 31 19:36:17 AEDT 2016
Local: Sun Jan 31 19:37:57 AEDT 2016 Lanmei: Sun Jan 31 19:36:18 AEDT 2016
Local: Sun Jan 31 19:37:59 AEDT 2016 Lanmei: Sun Jan 31 19:36:18 AEDT 2016
Local: Sun Jan 31 19:38:00 AEDT 2016 Lanmei: Sun Jan 31 19:36:18 AEDT 2016
Local: Sun Jan 31 19:38:01 AEDT 2016 Lanmei: Sun Jan 31 19:36:18 AEDT 2016
Local: Sun Jan 31 19:38:03 AEDT 2016 Lanmei: Sun Jan 31 19:36:19 AEDT 2016
Local: Sun Jan 31 19:38:04 AEDT 2016 Lanmei: Sun Jan 31 19:36:19 AEDT 2016
Local: Sun Jan 31 19:38:05 AEDT 2016 Lanmei: Sun Jan 31 19:36:19 AEDT 2016
Local: Sun Jan 31 19:38:07 AEDT 2016 Lanmei: Sun Jan 31 19:36:19 AEDT 2016
Local: Sun Jan 31 19:38:08 AEDT 2016 Lanmei: Sun Jan 31 19:36:20 AEDT 2016
Local: Sun Jan 31 19:38:10 AEDT 2016 Lanmei: Sun Jan 31 19:36:20 AEDT 2016
Local: Sun Jan 31 19:38:11 AEDT 2016 Lanmei: Sun Jan 31 19:36:20 AEDT 2016
Local: Sun Jan 31 19:38:12 AEDT 2016 Lanmei: Sun Jan 31 19:36:21 AEDT 2016
Local: Sun Jan 31 19:38:14 AEDT 2016 Lanmei: Sun Jan 31 19:36:21 AEDT 2016
Local: Sun Jan 31 19:38:15 AEDT 2016 Lanmei: Sun Jan 31 19:36:21 AEDT 2016
Local: Sun Jan 31 19:38:16 AEDT 2016 Lanmei: Sun Jan 31 19:36:21 AEDT 2016
Local: Sun Jan 31 19:38:18 AEDT 2016 Lanmei: Sun Jan 31 19:36:22 AEDT 2016
Local: Sun Jan 31 19:38:19 AEDT 2016 Lanmei: Sun Jan 31 19:36:22 AEDT 2016
Local: Sun Jan 31 19:38:20 AEDT 2016 Lanmei: Sun Jan 31 19:36:22 AEDT 2016
Local: Sun Jan 31 19:38:22 AEDT 2016 Lanmei: Sun Jan 31 19:36:22 AEDT 2016
Local: Sun Jan 31 19:38:23 AEDT 2016 Lanmei: Sun Jan 31 19:36:23 AEDT 2016
Local: Sun Jan 31 19:38:25 AEDT 2016 Lanmei: Sun Jan 31 19:36:23 AEDT 2016
Local: Sun Jan 31 19:38:26 AEDT 2016 Lanmei: Sun Jan 31 19:36:23 AEDT 2016
Local: Sun Jan 31 19:38:27 AEDT 2016 Lanmei: Sun Jan 31 19:36:23 AEDT 2016
Local: Sun Jan 31 19:38:29 AEDT 2016 Lanmei: Sun Jan 31 19:38:29 AEDT 2016
Local: Sun Jan 31 19:38:30 AEDT 2016 Lanmei: Sun Jan 31 19:38:29 AEDT 2016
Local: Sun Jan 31 19:38:31 AEDT 2016 Lanmei: Sun Jan 31 19:38:29 AEDT 2016
Local: Sun Jan 31 19:38:33 AEDT 2016 Lanmei: Sun Jan 31 19:38:29 AEDT 2016
Local: Sun Jan 31 19:38:34 AEDT 2016 Lanmei: Sun Jan 31 19:38:30 AEDT 2016
Local: Sun Jan 31 19:38:35 AEDT 2016 Lanmei: Sun Jan 31 19:38:30 AEDT 2016

The two minute jump near the end is systemd-timesyncd discovering (how?) that something is wrong and synchronizing via NTP.

Conclusion

  • HDMI, X11, hardware acceleration work.
  • Built-in Wi-Fi is no good.
  • Kodi, which was the target of it all, plays video with continuous stuttering.

Update

The time problem was caused by the kernel patches from RTL8723BS driver. Vanilla kernel keeps the time fine.

PLIBMTTBHGATY

Since long I have a book queue (a topic for some other time) but now there's also one for languages I want to learn. So as soon as I saw a meetup for PLIBMTTBHGATY ("programming languages I've been meaning to try but haven't got around to yet") I didn't hesitate a bit.

It didn't fail the expectations: was very nice learning Rust (tough choice but more on that later) together with others. I was lucky to have someone already proficient in it nearby explaining the non-obvious moments. It's a pity I didn't have time to try something real, only got through the official tutorial and a bit of another.

Waiting for the next time! There are a lot of candidates - Elm, Agda and the likes (this time there was a person trying to do printf in Idris), even React.

It would be nice if after the end of the meetup someone from each table would summarise the interesting parts and rough edges they encountered. Would also help to either find the tutorial or a task beforehand or find someone already knowing the language to help. Going to prepare better the next time.

Transport cards

I have a little hobby - collecting transport cards from different places. Before it happened naturally, but now there are three helpful things that simplify things for a lot of people, but mean a hard time for my collection.

  • A card bought in any metro in Japan can be used in any other city. Same in Korea.
  • No one likes garbage, so one-time tickets are eaten by the validators at the end of the trip. Guangzhou has plastic tokens for that purpose - with RFID! They have to be touched on at the start of the trip and inserted in the end.
  • Lastly, paying by bank cards (London, Moscow). Ideal solution: there's no special card, but its function is performed.

Very convenient for everyone, but you have to actually collect the cards on purpose now...

P.S. One more convenience: selling special tourist cards in the airports. Fortunately, these are often not as useful as normal ones so can be safely ignored.

New Year in Moscow

This year, Moscow is going to win an Instagram championship.

1 2 3 4 5

What do I need from a code analysis tool

I am a fan of static code analysis tools, -Wall, etc. Ignoring advice of people who professionally work with programming languages isn't wise. But besides warnings themselves, the linter must actually be convenient to use.

So here's a list of highly advisable features for a linter:

  • Every single warning type must be toggleable. If something is an error for sure, ideally the compiler can tell. Otherwise there must be an option to disagree with the tool.
  • Every warning must be able to be disabled locally. If one file or function must use - with precautions - a debatable mechanism, it's not a reason to allow it globally.
  • Each warning must be ignored separately. One #noqa for everything isn't enough.
  • If a warning is disabled locally but wasn't raised, this must be a separate message. Perhaps the author tried to work around a bug in an old version of a linter, and it's not needed anymore?
  • If the check produced warnings, the exit code must be nonzero.
  • The ideal check state is zero warnings. But if the linter is run on pre-existing code, it must tell whether there are new warnings compared to a known baseline state. This allows to fix the code gradually, without introducing new defects. Of course, if there are less warnings than before, the baseline state must be updated.

Some of these items are trivial, yet I have seen a counter-example for each. Everything except the last point doesn't even require special tricks, so please, if you somehow find yourself writing a linter - keep them in mind.

Pebble

A few words about the new toy - Pebble Time.

In the first grade of university, the first lectures in September were marked by a lot of watches beeping around 10. About the third day in everyone, of course, turned them off, but without phones the watch was the main distraction. I even had a habit of trying to look up the weather and which floor am I at on them.

So, finally I have a watch which theoretically can do that.

First things first: they are good as a watch. Calendar, weather (yay!), nice watchfaces. Timer and stopwatch can be installed, there are a few different ones.

First disappointment: only the Western European languages are supported. Not only the interface, but the fonts have nothing but Latin letters! I understand that to prolong battery life they had to compromise on memory as well, but it is not a pleasant surprise in 2015. One can install Chinese and Japanese language pack, Chinese and Japanese characters display fine with that. There is a Russian firmware, but after installing it all the Cyrillic letters become whitespace (as opposed to squares by default). Why is there no Russian language pack I have no idea, neither do I know what to do if I need to install two.

The application catalog is quite boring. Judging by the fact that I see quite a few test applications, like "paint the whole screen with one color", there's not a lot of them overall. Many are very specialized and therefore not of use to many, such as "transport in (some small French city)". Some apps install but don't run. On the whole, the catalog reminds me of Google Play Market during Android 2 times. Hopefully the situation will improve, or...

Let's improve it ourselves! The developer site is quite good, the documentation and the examples are solid. The emulator requires some strange packages and isn't packaged for Arch Linux properly, so I could launch it (an old version - Pebble, not Time) but not install a program there. On the watch itself the example application installs and runs with no problems.

I wanted (and still want) to make an application putting some pins onto the timeline. Turns out pins can only be added through the Pebble servers. Moreover, the pin specification is very specialized: apart from the expected time fields one can create a "sports event" pin with the fields of "first team score" and "second team score", and the score is a single number (hello, tennis and volleyball).

Would be interesting to compare all this to the Android Wear based watches. It doesn't seem like they're a lot more expensive.

Anyway, I just want an HMD. Anyone up for making Glass or something else work properly and solve the eye strain?

P.S. When typing while resting the palms on the table, the watch feels uncomfortable. Learning the right hand position, like on the piano.

Speed

300 km/h. 300 KB/s.

C as the modern Wenyan

If you were an educated Japanese scholar in the 10th century and wanted to communicate with, let's say, a Vietnamese, you got your inkstone out and used Wenyan. Wenyan - literary Chinese language - was imported (voluntarily or not) into Korea, Vietnam and Japan, and even after the corresponding nationalist movements the languages of those countries kept an enormous amount of Chinese loanwords.

So what does this have to do with C?

This week @brettrann faced a problem: given a string from a reliable source of entropy, generate two, such that running again with the same input string shall not change the result.

Because I had no intention of digging into the language that other project was written in, my advice was simply:

srand(GIVEN_RANDOM_THING); thing1 = rand(); thing2 = rand();

Afterwards, it turned out that both srand and rand are the same in that language (and, of course, the code didn't work exactly like written, because we need strings), but that's not the point.

I know and I can expect my colleagues to know what srand is. If I don't know what srand is, first of all it's a shame, but then I can find out in a minute. And exactly what's written in the code - be it mkStdGen or random.seed - isn't that important.

Nowadays only in China is Wenyan taught in schools, and then only reading and comprehension of classical texts. So it does already happen that a family keeps the great-grandfather's letters but no one can comprehend or (in Korea) even read them properly.

Does it ring a bell?

Semantic versioning

Here's what semantic versions really mean:

  • 0.0.X: There were X stupid mistakes.
  • 0.X.Y: I have X users.
  • X.Y.Z: I had to rewrite the thing X times.

Problem

The lecturer lined up all the students in a row, gave each one two numbers and told everyone to calculate the difference to the neighbor's numbers. Given the results, one needs to calculate a triple integral...

This was the problem in my dream. The thing was, I didn't know whether there was a solution or not - maybe there was enough data after all.

So I decided to ask @dannipenguin and already explained half of the conditions, but at that moment the alarm finally rang.