# From Jekyll to Nikola

I have recently moved my website from Jekyll to Nikola, another static site generator. The main reason was that I wanted to move from ruby to a python solution because I have pretty much stopped using ruby since I left my side job. In university python is my language of choice anyway because of its math and plotting libraries, so it makes sense to use it for scripting and my website, too.

With this premise I put my favorite search engine to work and found loads of options but decided quickly for Nikola, mainly to avoid analysis paralysis. Its first big plus is that it supports restructuredText out of the box which I wanted to learn for a long time. It always seemed superior to markdown with its extensible roles and directives, for example the math directive for LaTeX formulas. Speaking of which Nikola has built-in support for rendering LaTeX math in posts with MathJax which was actually also one of my exclusion criteria in the first place. However, I quickly replaced MathJax with KaTeX since it is noticeably faster – read jerking page motions as each equation is rendered versus subsecond rendering of the whole page – and I believe that its reduced instruction set will suffice for me. Finally, I am thrilled to put jupyter notebooks directly on my page at some point.

The main disadvantage in comparison to Jekyll that I discovered is that theming is harder. Jekyll is pretty bare-bones in that regard and you necessarily have to do everything yourself which has the upside of giving you full control from the beginning. Nikola on the other hand comes with core- and community-developed themes with a certain structure. This can get you going fast but as soon as you want to customize your page, you find yourself writing your own theme. The process is only barely documented and in the end I copied and modified the lanyon theme which was ironically ported from Jekyll, among other things translating it from Mako to Jinja2 that I already knew from ansible. Additionally I prefer its brace syntax over Mako's XML language.

My most invasive change to the lanyon theme is the listing of categories and tags in the sidebar. The issue is that Nikola mostly consists of plugins, including a plugin for rendering a categories and tags page. This has the side effect that the list of categories and tags is only available on that particular page. So right after modifying my first theme I had to jump into Nikola's (admittedly somewhat messy) codebase to find out how I could make this work. In the end I wrote the following mini-plugin to make the categories and tags available on every page.

from nikola.plugin_categories import ConfigPlugin

class Tagsandcats(ConfigPlugin):
def set_site(self, site):
super().set_site(site)

def registervars(context, template_name):
tags = site.tags_per_language[site.default_lang]
cats = site.category_hierarchy

context["tags"] = [(tag, site.link("tag", tag)) for tag in tags]
for cat in cats]

site.config["GLOBAL_CONTEXT_FILLER"].append(registervars)


# Installing CyanogenMod on a Samsung Galaxy S4

First and foremost a DISCLAIMER as you see them on every single post on this topic ever. The procedure described in this post will void your warranty permanently and irreversibly and at the same time may brick your device, meaning that it is rendered totally, unrecoverably unusable.

You are interested in switching from your preinstalled and probably bloated android version to CyanogenMod. Sadly this is not as easy as you would want it to be when you have to gather every piece of this multi-step process from different blog and forum posts. In the end it turns out to consist of

• Flashing a custom recovery mode
• Installing CyanogenMod
• Optionally installing the Google Play Store

## Collecting the Files

First and foremost you should download a version of CyanogenMod you want to install as well as an extended recovery mode that allows you to install non-verified ROMs. There are various options to choose from though I picked Cyanogen Recovery since it is maintained by the same people that develop CyanogenMod. Both files are available on the CyanogenMod download page. It is important that you choose the version specifically made for your device.

Furthermore you will probably want to have access to the Play Store. You can get Google Apps distributions of various extent at OpenGApps. For the S4 you have to select the ARM platform, the android version that you want to install, 5.1 as of the 27th of December, 2015. This should leave you with the following files, though possibly more current versions.

$ls cm-12.1-20151117-SNAPSHOT-YOG7DAO1JN-jfltexx-recovery.img cm-12.1-20151117-SNAPSHOT-YOG7DAO1JN-jfltexx.zip open_gapps-arm-5.1-pico-20151225.zip  To prepare for the actual installation you should now transfer the OpenGApps and the non-recovery CM files to your SD-card. You will later have to locate these with a rudimentary file explorer, so better put them in the root directory. ## Flashing Following these preparations, you have to flash an extended recovery mode onto your mobile phone because the provided one does not allow the installation of non-verified ROMs. For this I used heimdall, a reverse-engineered implementation of a Samsung-internal USB protocol for low-level control of android devices. Most importantly it lets you inspect your phones partition table and flash images onto them. heimdall communicates with your phone in download mode, a special mode of operation. You enter it by powering off your phone and then restarting with Volume Down + Home + Power while only releasing the last one when the phone vibrates. If it worked, you should see an android logo and a confirmation question that asks if you really want to enter download mode (Yes, you want to). Then connect it to your computer via USB. As a precaution you should first check your partition information table (PIT) and look for the recovery partition, i.e. the one that stores the recovery mode. In my case it was called RECOVERY but I have seen posts where it was called SOS. It is very important that you pick the right one. A mistake here can leave your phone unbootable. $ heimdall print-pit --no-reboot # ... --- Entry #20
--- Binary Type: 0 (AP) Device Type: 2 (MMC) Identifier: 21 Attributes:
5 (Read/Write) Update Attributes: 1 (FOTA) Partition Block Size/Offset:
10166856 Partition Block Count: 20480 File Offset (Obsolete): 0 File
Size (Obsolete): 0 Partition Name: RECOVERY Flash Filename: recovery.img
FOTA Filename: # ...


Once you have identified the recovery partition, use heimdall to flash Cyanogen recovery. --RECOVERY is -- followed by the Partition Name of your recovery partition. --resume makes it reuse the existing download mode session.

heimdall flash --resume \
--RECOVERY cm-12.1-20151117-SNAPSHOT-YOG7DAO1JN-jfltexx-recovery.img


## Installation

Finally we get to the actual installation. Start your phone in recovery mode this time with Volume Up + Home + Power again keeping the first two pressed down. In the recovery menu select Install from ZIP and navigate to the ZIP-files you transferred to the SD-card during preparation. You can install them by clicking on them with the power button. Remember though that the order is important, CM first, then OpenGApps and ultimately power off and start normally.

If you made it to this point, you voided your warranty, but installed a mobile operating system without bloatware and some nice privacy built-ins.

# Writing a Research Paper

Prof. Simon Peyton Jones gave a great talk about how to write a research paper. I will summarize it here, so that you can check and review the individual suggestions without skipping through the video.

## Don't wait: write (0:21)

Write your paper right from the beginning. It will drive your thought process and let you see more clearly, which parts need further refinement. The paper in progress also serves another way of communicating with fellow students, researchers or your advisor.

You also should not be intimidated by great work, that others produce. Most ideas start small and only become great once you explore the details.

## Identify your key idea (4:20)

The paper should present exactly one key idea. You do not need to know, which your key idea is, in the beginning, but when you finish, it has to be very clear. Make certain, that absolutely everyone understands, what this main contribution is. Your readers should not have to ask themselves, what is actually novel about your approach. If you find, that you actually developed multiple ideas, split your paper and write one each. This lets you focus on each idea and makes the final result more accessible to your readers.

## Tell a story (7:21)

Making people read your papers is hard business. They should be accessible and engaging. Imagine yourself explaining your current project to a colleague.

• Explain the problem. You should start with specific instances, that are easily comprehensible, before introducing the problem in its full generality
• Why is it interesting?
• It is unsolved. Why are existing solutions not applicable to this specific problem?
• Explain the idea in full detail. Here come formalisms, proofs, benchmarks and results on real-world data
• Compare your idea to other people's approaches

This narrative flow manifests in SPJ's typical outline

• Abstract (4 sentences, 100 readers)
• Introduction (1 page, 100 readers)
• The problem (1 page, 10 readers)
• My idea (2 pages, 10 readers)
• The details (5 pages, 3 readers)
• Related work (1-2 pages, 10 readers)
• Conclusions and further work (0.5 pages)

You can see this structure applied in his papers, for example one on advanced pattern matching.