Controlling Anki on Linux using a Nintendo Switch Joycon

I’m lying in bed all day curing a cold and I can’t really motivate myself to tackle the 1000+ reviews I’ve amassed over the last few weeks. There’s one gimmick I just implemented to motivate myself, and that is to use one of the Joycons of my Nintendo Switch to control Anki on Ubuntu. Much more comfortable than the laptop keyboard.

Continue reading Controlling Anki on Linux using a Nintendo Switch Joycon

Practicing Chinese character stroke order in Anki: Natural tracing with JavaScript

A couple of weeks ago I found an amazing resource: makemeahanzi on Github by the excellent Shaunak Kishore. It is a repository of Chinese character stroke order information which he created by applying machine learning to the fonts Arphic PL KaitiM GB and Arphic PL UKai. There is also a natural app he is working on and you should definitely check it out: Inkstone. In the makemeahanzi repository, the individual strokes are saved in SVG format, and it is not very complicated to render them via JavaScript. The big advantage is that Anki naturally supports JavaScript, no plug-ins are necessary (edit: see below), and so the whole thing also works on Ankidroid. Have a look at this short video to see what it looks like:

Continue reading Practicing Chinese character stroke order in Anki: Natural tracing with JavaScript

Matplotlib tricks

Two little things I need now and then and am tired of looking up. To change the default font to one which supports Greek characters:

from matplotlib import rcParams
rcParams['font.sans-serif'] = 'DejaVu Sans'

To scale the xticklabels:

ax.set_xticklabels([ int(np.round(i)) for i in ax.get_xticks()*10**6 ])

How to install Cyanogenmod 13 on LG G2 (d802)

I’ve been a fan of Cyanogenmod since 2012 when I installed it on my HTC Hero. The Hero went and the LG G2 came, which I used for some time with the stock ROM, but I knew the time for Cyanogenmod would come. After using CM12 for some time I wanted to try installing CM13 again. My original problem was that I would be stuck in a bootloop when using CM13. After a while I found that this was caused by using the wrong bootloader, and I installed a “hybrid” bootstack from this source:

After that I rebooted into recovery and flashed the bootstack, CM13, and the Google apps all in a row. CM13 was working, yay! Unfortunately my recovery wasn’t working anymore. It seems that with this bootstack, you need a “bumped” recovery. I just assumed that the default recovery would be bumped, but I was mistaken.

Before I proceeded to get a working recovery again, I decided to do a backup of my otherwise working and already set up system following  this guide:

In the guide it mentions that you need Busybox, but you don’t need it if you run Cyanogenmod 12. I run the backup then with the following commands:

Shell 1:

adb forward tcp:5555 tcp:5555
adb shell
nc -l -p 5555 dd if=/dev/block/mmcblk0

Note that I ommited the “-e” option since it gave me an error.

Shell 2:

adb forward tcp:5555 tcp:5555
cd /path/to/store/the/backup
nc 5555 | pv -i 0.5 > mmcblk0.raw

This backup worked quite nice (as it seems), but it took the whole night to complete. Plus, I have no idea how this should be recovered. I’ll have to check that thread in that case.

Now, back to my original problem. I couldn’t boot into recovery due to the following error message:

ERROR: boot certification verify
 [690] ---------------------------------------
 [...] Secure booting Error!
 [...] Cause: boot certification verify
 [...] ---------------------------------------

I tried flashing a new TWRP recovery (3.0.2-1 from blastagator) as provided in this thread:

Since my recovery was broken, I couldn’t use that one to flash it. I tried flashify, but it didn’t work. Then I installed the Cyanogenmod recovery (which worked), but I couldn’t flash blastagator’s recovery from there either due to a failure in signature verification.

Well, that’s the end for now I guess: I have a working basic recovery (without backup options), so for now I’m happy with a working Cyanogenmod 13 and just did a first backup with Online Nandroid .

PayPal REST SDK for Ruby:

Just for the record: I saw on some official PayPal site the use of “PayPal::SDK::Merchant” encouraged. Don’t do that, it’s highly outdated.

If you’ve successfully executed a payment, you can get the shipping address by loading the payment object once again and then calling @payment.payer.payer_info.shipping_address. The “inspect” method is your friend here!

Picking a random (Chinese) character in ruby

Here’s a simple way to choose a random Chinese character in ruby:


The asterisk expands the range, and “sample(1)” gives you one of the entries.

The unicode block 4E00 to 9FFF contains more than 20000 Chinese characters. If that’s not enough for you, you can find more code blocks here:

Shoutout to for the many versions on how to create a random string.

I need this random Chinese character for my Factory Girl. She’ll create a new Hanzi everytime I call “let”:

let(:hanzi) { FactoryGirl.create(:hanzi) }

This is my Hanzi factory:

factory :hanzi do
sequence(:character) { |n| [*"\u4E00".."\u9FFF"].sample(1).join("") }
sequence(:components) { |n| [*"\u4E00".."\u9FFF"].sample(3).join("") }

The sequence is required to pick a new sample for every test run.