Pen & Paper


Moved

24 Sep 2017

Moved. What’s Next?

Calibre

09 Sep 2017

Calibre has been around for over a decade now. It was my primary ebook reader since I first installed it on my Ubuntu nearly 10 years’ ago. Calibre is an exceptional software - free of cost and of ad; it makes me feel morally bound to make a donation to the author. Even after I got my Kindle Voyage, I still use Calibre regularly to manage my book collections, convert books between different formats, send books to devices and of course, read. I never felt the need to explore Calibre’s many other functionalities made possible by its plugins. That was until last week when I was looking for a digital version of a Chinese history book [國史大綱] for my grandchildren and attempting to build myself a small collection of Chinese literature.

Calibre has two powerful plugin functions that I had not used before but I will likely need them for my Chinese ebooks. One is to translate simplified Chinese into traditional Chinese and vice versa. The other one is to remove DRM. The translation plugin was fast when I tested it (took only a few seconds to convert an entire book). I haven’t finished proof-reading yet but so far, the translated text looks perfect. The second plugin is to strip copyright protection. This will have to be done before any purchased ebooks can be loaded into various devices. This plugin has to be tested on the actual file as DRM protection is not the same for different file formats.

I had expected an easier seach as [國史大綱] is not some obscure history book. It was first published nearly 80 years’ ago in 1940 and had had several printings. However, the search experience that I had was probably typical for any one living overseas and trying to find and purchase a digital copy of many Chinese literature.

The problems were multiplied manyfolds due to: 1. my Kindle is tied to amazon.co.uk which offers only a very limited choices of Chinese books. [國史大綱] is unavailable in either Amazon UK or Amazon US. No hard copy. No Kindle copy. 2. I set up a new account in amazon.cn with the hope that I may be able to buy books there. No, amazon.cn is probably tracking user’s IP - it wouldn’t allow me to make any purchase as soon as it found out that my IP address did not originate from China. 3. I could probably go through the trouble to try using amazon.cn with a VPN service, a fake mainland address and gift cards for payment but I wasn’t sure if changing my Kindle country from UK to China was irreversible. I don’t want to get stuck in the Chinese site as the bulk of my reading is English. Risk is too high for the uncertainty. Not worth it. 4. I tried sites in Hong Kong (超閱網 and Taiwan (PubU, Readmoo, 博客來, 臺灣商務) but soon realized that none of these sites would allow digital download. Their ebooks are only good for reading in their own online reader. This allows them to exercise a tigher control over copyright but at the expense of limiting access of their ebooks. Without a digital download, I cannot read it offline or in my preferred reader. I did install and try out their android reading app (超閱網 and Readmoo). The experience was awful because I didn’t have a android tablet and reading books on a phone is a torture. 5. 國史大綱 was first published in 1940 and is most likely still copyrighted. It depends on the country you are in and where and when the book was first published. Books in the public domain can be found in many websites. Gutenberg is one of them. It has a decent catalog of Chinese classic literature in various popular ebook formats. Recommended although I couldn’t find what I was looking for there. 6. Googling “國史大綱下載” or “國史大綱電子書” or its various combination returned a few pages of links. Exploring and clicking on these links are inherently risky because of potential virus. I wouldn’t recommend doing so under a Windows system which is almost always the target of any potential virus attack. Out of desperation, I did take the chance to download a few files but from a VM on Debian after carefully eliminating some questionable links from the Google search results. I also used Calibre in the virtual machine to import the files and examined each of them to make sure they were safe.

Here are the files and you are welcome. Do let me know of any errors especially on the translated text and I’ll do some necessary editing:

Android App

11 Sep 2016

Day 1

A couple of minor issues prior to installing Android Studio on my LMDE 2.

  1. I have more than one version of OpenJDK installed. Android Studio requires version >= 1.8.

    Use `sudo update-alternatives --config java` to change the default JAVA version
  2. I had already defined JAVA_HOME in my .bashrc to use JRE when I installed the EC2 command line tool, Android Studio requires JDK so I had to rename the original JAVA_HOME to JRE_HOME and re-defined JAVA_HOME to point to jdk/bin instead of jre/bin. This was simply done by removing “/jre” at the end of the original string.

    My original “JAVA_HOME”

    /usr/lib/jvm/java-7-openjdk-amd64/jre 

    has now becomes

    /usr/lib/jvm/java-8-openjdk-amd64

Android Studio booted up successfully after installation but with a couple of warning messages:

  1. MaxPermSize option is removed from java version 1.8 and is not supported

  2. OpenJDK shows intermittent performance and UI issues. We recommend using the Oracle JRE/JDK

Item 1 seemed to have appeared only once during the initial boot-up. It did not cause any problem. I assume this can be safely ignored or, alternatively, the option can be commented out in the configuration file studio64-vmoptions found inside the android-stuido/bin folder.

I did some quick research on the net about Item 2. OpenJDK doesn’t seem to create any major issues for people continuing using it for Android Studio. Considering the fact that Google and Oracle are currently hotly engaged in a law suit regarding Android/Java, I have the feeling that Android Studio will eventually ditch Oracle’s JRE/JDK. I decided against installing the Oracle JDK unless some performance issues pop up after.

Finally, the default UI theme IntelliJ looks terrible in my machine. The navigation bar is almost intelligible. Changing the theme to GTK+ under “File->Settings->Appearance & Behaviour->Appearance->UI Options” helps.

Github provides free hosting of a static website for each user and for each project. These websites are generated using Jekyll which will process all files uploaded to an individual user account (master branch of a special repo named USERNAME.github.io) or any project repos with a gh-pages branch.

This short guide will walk through the steps in setting up of a local “Jekyll” installation so that the website can be designed and its content reviewed before committing to Github.

Requirements

Considerations

  1. In configuring Jekyll, it is important to bear in mind that Github’s user page is located at root (USERNAME.github.io) while its project page is served from a sub-directory (USERNAME.github.io/NAME_OF_REPO). The parameter baseurl in *_config.yml* should be set correspondingly as follow:
    • an empty string "" for a user page and
    • "/NAME_OF_REPO" for a project page
  2. To preview the project website locally, it is necessary to temporarily override the baseurl setting using jekyll serve --baseurl "" so that the pages can be found at “localhost:4000”.
  3. The Jekyll engine at Github only supports a selected set of plugins and it may not be the same version as the local installation. To avoid possible conflicts, put gem 'github-pages' in a Gemfile in the repo’s root directory followed by a command bundle install.
  4. Put _site into .gitignore. The folder is generated for the local Jekyll installation only. Jekyll will re-build the site every time following a new upload or commit.

Creating Project Pages

  1. Clone an existing repo
    • $ git clone github.com/user/repo.git
  2. Create and switch to gh-pages branch
    • $ cd repo
    • $ git checkout --orphan gh-pages
  3. Remove all existing files
    • $ git rm -rf .
  4. Scaffold new Jekyll site
    • $ jekyll new .
  5. Make changes and create content
  6. Publish to Github
    • $ git commit -am "new content added"
    • $ git push origin gh-pages

I have created a set of slides for this post using slidify.