Adding graphs to posts in Nikola

I really like to teach, try to explain things in a simple manner. There is often no better way of making an explanation than visualizing it. The problem is that I really can't draw, especially on a computer. Wouldn't it be awesome if I could make the computer draw for me ? I found out that, unsurprisingly, there is a software for that already. The one I like is called mermaid - it renders a simple text description of a graph or diagram into an html representation. Can look something like this.

graph TB subgraph one a1-->a2 end subgraph two b1-->b2 end subgraph three c1-->c2 end c1-->a2

This blog is rendered by Nikola hence I would like to show you how I've added mermaid support to my Nikola installation. I use USE_BUNDLES = False in conf.py as for it gives me more control and is more HTTP/2 friendly. With that disabled I can include mermaid's style and js files like so (also in conf.py):

EXTRA_HEAD_DATA = """
<link rel="stylesheet" type="text/css" href="/assets/css/fontawesome.css">
<link rel="stylesheet" type="text/css" href="/assets/css/titillium.css">
<link rel="stylesheet" type="text/css" href="/assets/css/mermaid.forest.css">
"""

BODY_END = """
<script src="/assets/js/mermaid.js"></script>
<script>mermaid.initialize({startOnLoad:true, cloneCssStyles: false});</script>
"""

Where do all these files come from though ? In my case, I have a custom theme, based on zen called zen-cyplo. The assets in the sources are located under themes/zen-cyplo/assets/. Oh, and cloneCssStyles: false is there as the default of true made the different css styles on my blog clash. Finally, to use mermaid in the post do (for reStructured Text):

.. raw:: html

        <div class="mermaid">
        graph TB
                        subgraph one
                        a1-->a2
                        end
                        subgraph two
                        b1-->b2
                        end
                        subgraph three
                        c1-->c2
                        end
                        c1-->a2
        </div>

You can click on source button located below the title of this post to see it in action. If you are interested in the build process and how all these come together - the complete sources for this blog are hosted under https://github.com/cyplo/blog

Upload your site to Netlify using their incremental deployment API

I've recently switched to a setup where I do all my builds for this blog on Travis. While doing so I needed to migrate away from using Netlify's internal build infrastructure. This resulted in a quick python script that allows you to upload arbitrary directory tree to Netlify and does so using their incremental deployment API. All that means that while this site is quite big in size the deployments go rather quickly ! There are some known issues but apart from them the script should just work for any custom Netlify deployment you would like to have. I use it on this very site, to have a preview of any PR before merging it as well as for deploying the main site after the PR is merged. I hope you will find it useful and please do not hesitate if you want to post an issue or a PR !

Running host programs in isolation inside one-off Docker containers

I am quite bad at remembering how to launch docker to have everything set up correctly. Hence the following - a script that launches any commandline specified in its arguments inside a new docker container. Current directory is mounted inside the container automatically, so the thing you are executing can have its local dependencies satisfied.

#!/bin/bash
USERNAME=`whoami`
MOUNT_PATH="/mnt"
CURRENT_DIRECTORY=`pwd -P` # untangle symbolic links if needed - SELinux needs the real path
IMAGE="debian:jessie"

if [[ -z $1 ]]; then
    echo "usage: `basename $0` command_to_run_inside_a_container"
    exit 1
fi

RESOLVED_ARGUMENTS="$@"
docker run -i -t -v "$CURRENT_DIRECTORY":"$MOUNT_PATH":Z $IMAGE bash -c "useradd -M -d '$MOUNT_PATH' $USERNAME && cd '$MOUNT_PATH' && bash -c '$RESOLVED_ARGUMENTS'"

# restore SELinux context for the current directory
restorecon_path=`which restorecon`
if [[ -x "$restorecon_path" ]]; then
    restorecon -R "$CURRENT_DIRECTORY"
fi

I use vanilla Debian Jessie as a run platform there, mostly because this is what most of my servers run. The script covers setting up SELinux and mounting the directory from which it is run as /mnt inside the container while also having the default non-root user added.

Run Jessie, run !

Using ad hoc Docker volumes on SELinux systems

I've recently tried running some quick Docker commands using host's directory as a volume:

docker run -i -t -v `pwd`:/mnt debian:jessie bash -c "ls -hal /mnt"
ls: cannot open directory /mnt: Permission denied

I use Fedora as my main OS, which, it turns out, has some pretty nice SELinux settings. These deny access from inside the container to the outside. Said Fedora consists mostly of almost-newest-but-stable everything though, which makes Docker to be in a fairly recent version. A version that understands how to change a SELinux context for the directory we're mounting, by itself ! You need at least Docker v1.7 for this.

docker run -i -t -v `pwd`:/mnt:Z debian:jessie bash -c "ls -hal /mnt"
total 8.0K
drwxrwxr-x.  2 1000 1000 4.0K Dec 30 18:34 .
drwxr-xr-x. 21 root root  242 Dec 30 19:07 ..

Please notice the capital Z as a mount parameter. And that is it. Mostly. Some cleanup remains, as docker leaves the host's directory with a changed SELinux context. To restore it you need to

restorecon -R `pwd`

Or use any other path you'd like instead of `pwd` in the examples above. Happy dockerizing !

RustFest - organization was the best. Also rhymes.

I went to RustFest and it was amazing !

It was clearly the best conference organizational-wise I've been to so far. It made me think of what I really liked there. What made it so awesome and welcomy ? To me this was a large number of small things just coming together. I listing them here for me to remember and for others to use. Let's make conferences at least this friendly, together !

Before the event:

  • very clear emails, repeating messages couple of times in different emails for the important stuff
  • maps of the popular routes provided, e.g. from the airport and bus station
  • supporter ticket sale - two times the price - you pay for another person that wouldn't be able to get a ticket otherwise
  • survey on dietary requirements/allergies
  • survey on childcare needs
  • clear statement of the code of conduct for the conference

During the event:

  • very good MC person

    • keeping people entertained through the tech breaks
    • keeping tabs on the talk length, allowing appropriate amount of questions if the time allowed
  • live captioning of all talks - small screen outside of the view of the main screen with the text live

  • getting the next speaker prepared and mic-tested before the end of the current talk

  • quiet room to rest with clear rules on no talking and interrupting there

  • clear signage for the different parts of the venue (washrooms, quiet room, party space etc)

  • washrooms

    • all same, ungendered

    • basic items for free in said washrooms

      • chewing gum
      • tooth paste
      • tampons, pads
      • baby wipes
  • info desk/registration

    • clear info during registration, handing out programme
    • asking people if they want to be on the photos - giving out lanyards accordingly - flashy red lanyards for people who do not want photos of them taken
  • emergency number to call with stated purpose

    • code of conduct violation
    • if you are lost in the city

The best terminal emulator for Windows 10's Bash or how to run X applications

update as of 03/2017
As this article is by far the most popular on my site right now I feel that an update is necessary, as the landscape evolved a bit since the original publish date.
Conemu started to support Bash on Windows properly now and this is what I settled on in the end.
The article below is still relevant for the running X applications on Windows part though.

I've been playing a bit with GNU/kWindows a.k.a. Bash on Windows a.k.a Windows Subsystem for Linux (Beta). I was especially interested whether I can use my regular Linux dotfiles to recreate my working environment of zsh + tmux + vim. The biggest troubles I had were with the terminal emulator. While the default one, invoked by saying bash is much better than powershell or cmd.exe already - it lacks some things I've learned to rely on, like 256-colour palette support. Thus the search for the ultimate terminal emulator begun. I tried ConEmu, cmder and their spinoffs to no avail. Either the colours were lacking, or the emulator would swallow up certain strokes like the arrow keys. Then I thought - hey, I use terminator on Linux, maybe it would be possible to use it here as well. To my surprise the answer was - yes !

  • install Windows Subsystem for Linux
  • restart Windows
  • install VcXsrv
  • run VcXsrv
  • invoke the following from the bash console:
sudo apt-get install terminator
DISPLAY=:0 terminator -u
  • profit !

Capture

The font rendering is not ideal and the borderless mode does not work, but hey, it is quite usable nonetheless ! It even has bidirectional clipboard sharing with Windows' windows, which is good. P.S. konsole and gnome-terminal do seem to have troubles launching (crashy-crashes there)

Don't throw away. Fix.

Try fixing your things. It's already broken - no need to sweat.
You might learn something.
Level 2 - push for things to be easily fixable.
It's good for you. It's good for the planet.

image0 image1 image2 image3 image4

Conferences you did not know existed and now you know you just need to go to

Go to conferences. It's good for you.

Ever wondered why to go to conferences ? Is it worth it, especially if you do not feel confident that the conference is on something that would be in an immediate realm of your day-to-day interests ? Just go ! You might end up learning something and meeting new people. And new people mean more variables to mix up your life. A bit scary, I know. Still worth it though. Wondered what conference in Europe are weird enough so people wouldn't mind having another misfit ? Here you go.

nucl.ai

Now imagine something niche within the industry. To me, AI comes to mind. Mages in robes in their towers, sending out autonomous robot armies against each other. Right ? There's a conference for that ! At nucl.ai, in July, in Vienna, you can meet AI professionals from academia and industry alike, most of them coming from game development background. The atmosphere is very newcomer-friendly, the only requirement is that you're interested in AI, not necessarily having anything to do with it professionally. Petra and Alex, the organizers, are wonderful people that make this conference quite unique. It's happy fun to see ideas floating from academia to the industry and vice versa. Don't forget the presentations on work-in-progress major AAA games ! I've learned there that the everyday programming in the games industry is quite different than the one I do in terms of best practices and patterns. Definitely worth a try !

Erlang User Conference

Speaking of something completely different. Erlang ! Was functional before being functional was considered cool. Very practical, very fast, parallelize everything ! Processes everywhere ! Message passing ! Want to feel the groove as well ? Visit Stockholm in September for Erlang User Conference. Meet creators of the language, talk about massive scale deployments. Other FP languages are welcome. I would even say, the more strange the better. Idris seems to be the topic of interest as well.  Eat good food, walk the city of dynamite. Erlang has a quite close-knit community which gives you this warm family feeling.

SoCraTes

Speaking of family. There's a family of conferences known as SoCraTes. Software Crafstmanship and Testing. SoCraTes. Get it ? :D As it's more than one conference a year, it's harder to go to all of them. I only went to Codefreeze, in Finland, in January, and only once, but loved it already. Codefreeze, Finland, in January. Get it ?! :D First thing is that you don't know what will happen there. You just go, meet the people and then you sit down and everyone talks about what they would like to learn and what they can share. This way you come up with some loose agenda you follow more or less. One track, very intense. Talking, swimming in ice water, learning, sauna going. Very intimate feel, not many people, lots of things to learn.

Chaos Communication Congress

Speaking of lots of people and intimate feel. Chaos Communication Congress is, I think, the biggest gathering of all nerds and freaks in Europe, yet being there feels quite at home. The best organized conference I've been to. Friendly people showing their wares on their humble tables, 4 simultaneous tracks, huge building with intricate hallways. It's cyberpunk, it's inclusive, it's about hardcore infosec topics, it's about politics. Everything's there, everyone's there. 4 days of data being constantly uploaded to your brain, on the waves of Club Mate. Feels like an extended holiday present, as it's happening in the last week of December.

The Camps

Chaos Communication Camp and The Dutch Camp. Imagine CCC, the Congress, but in the woods. Middle of nowhere, multigigabit internet connection. sleeping in the tent, then going to a world-class lecture. Both CCC, the camp, and The Dutch Camp, the camp, are happening every 4 years, each of them taking alternating slots. So every 2 years there is a camp somewhere. Did I mention that the location changes every event ? Happy camping !

Summary

So go out there. Explore. Meet people. Learn. Have fun. None of the above are much expensive and most of the events have a policy of "write to us if you want to go but can't afford the ticket". Friendly people fixing problems together.

nucl.ai: July, tickets around 250EUR
EUC: September, tickets around 350EUR
SoCraTes: the cost and the time depend on the event
CCC: last week of December, tickets around 100EUR
The Camps: summer, tickets around 125EUR

Productive New Year's Eve

It turns out that the last day of the year can be quite productive. I've managed to sneak in a PCB layout for the input measurement and protection board for my sunpowered server . Got it ordered, can't wait to test it ! I got carried away with via stitching there a bit - we'll see how hard it will be to solder the larger components because of that. The whole project is hosted here - it's open hardware so please do take a look.

image0 image1 image2

Sporting Let's Encrypt certificate

Let's Encrypt is soon to be publicly available service to provide TLS certificates for free and in automated fashion. I'm helping them test their systems by participating in the beta program. Because of that this site is now sporting, publicly recognizable certificate from Let's Encrypt. Yay ! The work they are doing I believe is of much importance. Lack of easy path for getting TLS certificate was a major hurdle for the most of the website owners, otherwise keen on getting their traffic encrypted. This, in turn, is important for two reasons. Not allowing the content you are viewing on the internet to be snooped at, not leaking you private data is one thing. Other, less known, but as much important, is countering the ability of injecting any malicious code/data into the responses from the servers you got and in turn preventing lots of man in the middle attacks. Hopefully, when Let's Encrypt becomes publicly available we would be on the path to much more friendly internet for all.