MandarinBanana Mnemonics Anki Import

Today I’ve created a text file with the mnemonics from mandarinbanana.com to import in Anki. You can download the file here:

It is a tab-separated text file (compressed as zip, because it is 45 MB large uncompressed). This is what the import looks like:

Anki import screen
# / nameWhat’s inside
1 / hanziJust a single Chinese character, no HTML formatting. Example: 仍
2 / componentsA simple line showing the components (example: 仍 = 乃 + 亻), followed by dictionary entries for the components and mnemonics for the components.
3 / translationsDictionary entries for the character and any mnemonics associated with the character.
4 / imagesLinks to the comics associated with the character (no download option available so far)
5 / appearancesA list of characters which use the root character as component (example: 仍 appears in 芿)
6 / subtitlesSubtitles of the movies on mandarinbanana.com which contain the character. If you click on the sentence, it will open in the browser.
7 / wordsA list of CC-CEDICT dictionary entries for words the character appears in.

There’s a lot of HTML formatting inside. Here’s what my styling section in Anki looks like (just as an example):

.card {
 font-size: 16px;
 text-align: center;
 background: black;
 color: white;
}

.mnemonics {
  margin-top: 1em;
  padding-top: 1em;
  border-top: 1px solid gray;
}

table {
  margin-left: auto;
  margin-right: auto;
}

td {
  border: 1px solid;
  padding: 5px;
}

div {
  margin: 5px;
}

.hanzi {
font-size: 2em;
font-family: "zenhei";
}

a {
text-decoration: none;
color: inherit;
}

ul {
  list-style-type: none;
}

.mandarinbananalink a {
text-decoration: none;
color: orange;
}

img.mimage {
width: 200px;
background-color: white;
border: 1px solid white;
margin: 1px;
}

@font-face {
  font-family: uming;
  src: url('_UMingCN.ttf');
}

@font-face {
  font-family: simfang;
  src: url('_simfang.ttf');
}

@font-face {
 font-family: zenhei;
 src: url('_WenQuanYiZenHei.ttf');
}

.color1 {
color: orangered;
}

.color2 {
color: yellow;
}

.color3 {
color: limegreen;
}

.color4 {
color: dodgerblue;
}

Each mnemonic is followed by the author’s name (since all mnemonics are CC-BY). If you like to, you can hide this information by including the following code in your “Styling” section:

.authorattribution {
display: none;
}

I hope this is useful for you! If you need a different format let me know in the comments.

If you want to have a look how the file is generated, please head over to https://github.com/mattbenscho/MandarinBanana/blob/master/lib/tasks/output_anki.rake. It takes a few minutes for the script to run because there are so many database calls, which makes it difficult to, for example, post a link on mandarinbanana.com which always returns the latest collection. I’ll have to implement some caching mechanism first, but it’s one of the things I definitely want to do to complete the site.

Have fun learning Chinese!

Copyright information: all mnemonics CC-BY by the respective authors. Dictionary entries: CC-SA CC-CEDICT (www.mdbg.com).

Controlling Ankidroid with a Joycon

This post is kind of an addendum to my previous post, but it’s about controlling Ankidroid. You’ll need the app “External keyboard helper pro” (about $2). Here are the steps:

  1. Press the sync button on the Joycon and pair it with your Android device.
  2. Open “EKH Settings”, go to “Advanced settings”, “Keyboard mapping”, “Customize keyboard mappings”, and click on “Add new key mapping” for each button you want to map. For Example, I have SL and SR mapped to 0 and space respectively as in my previous post.
  3. Open Ankidroid and enjoy flipping your cards with your Joycon! You’ll have to set External Keyboard Helper as input method before.

More info on using the buttons on your headphones (similar approach): https://github.com/ankidroid/Anki-Android/issues/3021#issuecomment-160243369

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

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 ])

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!