my blog was never faster nor easier to deploy!

Deployment via git

The local repository

You can host your site on Gitlab, Github or something else - just like I do. But if you want to start from scratch you can make a folder and initialize git in it, after that you can copy over your Jekyll files.

mkdir jekyll && cd jekyll
git init
cp -r /path/to/old_jekyll_folder /path/to/jekyll
git add .
git commit -am "initial commit."

The remote repository

Now we need a new repository on your web-server, but it doesn’t need to be inside your web directory - just somewhere inside the system. I assume you have configured your public-key to work as a login and you also need write-privileges to the web directory with this user.
First we need to initialize the repository:

#Initialized empty Git repository in /home/nh/website.git/
mkdir website.git && cd website.git
git init --bare

Then we need define a post-receive hook that checks out the latest changes into the web-servers DocumentRoot (this directory must exist; Git will not create it for you):

nano hooks/post-receive

Put this inside the file:

#!/bin/sh
GIT_WORK_TREE=/var/www/www.example.org git checkout -f

After that we need to enable the hook which will be triggered every time we push our changes to this repository. It will apply every commit to the directory which you have defined inside the post-receive hook.

chmod +x hooks/post-receive

We are now done on the server and we only need to set up the update process on the local system.

The update process

First we need to edit our git config file in our local repository to add the remote server.

nano .git/config

Add this to the file:

[remote "production"]
    url = username@webserver:/home/nh/website.git

That’s it! Now you have set up your deployment! To deploy your jekyll changes is now as easy as this:

git push production

Make jekyll fly

This is the fastest site I've ever built.
before and after

Optimizing the web-server

Since I wanted to optimize my server I looked for a site which would allow me to test my servers performance and maybe also give me hints, than I found pingdom which is a really good tool to test your site!

First I installed Googles Pagespeed on my CentOS machine which was a fairly easy process.

Now I needed some optimization of my servers cache, for this I needed to use the mod_expires module of my apache installation.
I made a new file /etc/httpd/conf.d/expires.conf with the following content:

ExpiresActive On
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/png "access plus 1 month"
ExpiresByType image/jpeg "access plus 1 month"
ExpiresByType text/css "access plus 1 month"
ExpiresByType text/javascript "access plus 1 month"
ExpiresByType application/x-javascript "access plus 1 month"
ExpiresByType application/x-shockwave-flash "access plus 1 month"

After that I edited my DNS entry to use CloudFlare which I highly recommend to you!

Now I have a really fast Apache web-server with caching and CloudFlare enabled.

Optimizing pictures

You can make images smaller by using image_optim! This is a great tool and fairly simple to install:

gem install image_optim image_optim_pack

If you want the full suit you also need to do this on ArchLinux:

yaourt -S pngout
sudo npm install -g svgo

After that you can simply go to the directory in which you stored your pictures and let image_optim run through all subdirectories and files recursively with this command:

# WARNING: This could take a while!
image_optim -r .

Hiding the clutter

I have made an .htaccess file for this reason, but since I have the opportunity to simply change the DocumentRoot to _site I did that instead!
Maybe it will help you!

Wow such top. So stats. More better than regular top. Written in node.js vtop

I’ve been using top since I started maintaining a server in 2010.
It’s a really powerful tool to glance at it and see if your system is alright, but since I discovered htop, top was made obsolete for me.

Although I really liked htop I always felt that it sometimes had a too clunky representation of the data, so that I couldn’t quickly enough see if my system was acting out of the common workload.

Than I discovered vtop!
But let’s start at the beginning of my journey.

Why not simple old top?

top vs htop

As you can guess from the pictures above htop does really exactly the same as top, but in a much nicer way so in my opinion there is no discussion about why you would choose top over htop!

vtop the unknown beauty

vtop

vtop looks much cleaner than htop. One look and you exactly know whats going on on the system! You can list processes by CPU or Memory usage which is really awesome, you can navigate with your arrow keys or k and j which is also nice and the best of all you can simply highlight/select a process and kill it by typing dd!

You can install it also very easily through npm(you need to install node.js on your system)!

sudo npm install -g vtop

After that you can execute it by typing vtop

I really love it! Maybe there are some use-cases where I still need htop e.g. when I want to find a PID and don’t need it to kill the process, but vtop is now a part of my daily used tool!

Try it out yourself!

I changed my blog from Wordpress to Jekyll!

Why i switched to Jekyll

I was thinking about switching from Wordpress to something else for quite a while, but I didn’t find anything I really liked.

First I thought about switching my blog to a self made Laravel site, but it’s kind of reinventing the wheel. It’s a lot of work and is still open to bugs and exploits and therefore has to be updated really often - which I was not willing to do and also didn’t had the time for to do. Also I still would have PHP Code which to be totally honest I don’t really like because it is really slow in comparison to Node.js or Go code.

My second thought was to implement my blog in Go. Yay! The response time would be amazing and I sure would learn a lot - given I only played around with Go so far. But then again - a lot of overhead, fast out-of-date and time-consuming to maintain.

At first I was against static site generation.

I search a while and read a little bit more about static site generation and the more I thought about it the more it became clear to me: “This is the way to go.”

Static site generation was the key to the cons I had previously had against other solution. No security risks, because it is “only” HTML and no code is compiled on the server at runtime. No overhead - there are a lot of great static site generators out here and it would be - once set up - really fast to write articles and publish them.

Okay, so where to start?
There is Pelican, Pico, Nikola and of course Jekyll.

So I looked at them all with the following requirements:

  • easy to use
  • can import my post from Wordpress (would turn out as a ‘biggy’)
  • support Markdown
  • actively maintained
  • easy way to preview my work before uploading it to any server

Nikola

I started with Nikola because it seemed like the perfect fit to me. It met all my requirements and also was very easy to install on ArchLinux (yaourt -S python-nikola-git). So I headed right into it made a new git repo and nikola init to start a new Nikola instance. Okay now let’s import my Wordpress posts.
I made exported my posts from within Wordpress thought a XML file and executed Nikolas built-in import method nikola import_wordpress posts.xml. Wow, that was easy. Nope. Error. Damn it! DuckDuckGo to the rescue! Okay installed Nikola from source on Github. Still that Error. After a few hours of fumbling around I admitted defeat and moved on the the next generator on my list.

Pelican

Aswell as Nikola, Pelican checked off everything on my list so i also installed it. This time through pip. Just for funsies.

pip install pelican markdown
pelican-quickstart

Okay so now let’s import it.
pelican-import --wpfile --dir-page -o content -m markdown posts.xml

Cool, so far so good let’s look at my files.

python -m SimpleHTTPServer

Doesn’t work. Mhmmm… let’s try Python2.

python2 -m SimpleHTTPServer

Eureka! Long story short I really didn’t like the way theming works in Pelican although I thought I could live with it, there where still some options on my list and I thought: “Better make sure you like it, because you will be using it for quite a while!”

Pico

Okay so I started on Picos website. Oh my.. PHP? Why? Oh boy, now I have to set up a complete web developing environment for a “simple” static site generator? Nah!
So I searched for lightweight Web-Servers for in-place use.
I discovered [node-sng][http://code.ravelsoft.com/node-sng] and thanks to Arch it was also easy to install.

But at this point I thought I just drop Pico because it is not practical for me and thus I wouldn’t use it for long.

Jekyll

Let’s try the clear mainstream option. Nice checks off everything on my list.

gem update
gem install jekyll

Nice! So let’s import everything. Awesome Doc is awesome!

ruby -rubygems -e 'require "jekyll-import";
    JekyllImport::Importers::WordpressDotCom.run({
      "source" => "wordpress.xml",
      "no_fetch_images" => false,
      "assets_folder" => "assets"
    })'

Mhm.. now my posts are still in HTML - I want them in .md format. Okay Bash-Script to the rescue! (you need pandoc to use this script)

#!/bin/bash
FILES=/home/nh/Desktop/posts/*
MDFOLDER=/home/nh/Desktop/mdfiles/
for f in $FILES
do
    completename="${f##*/}"          # complete file name with .ext
    filename="${completename%.*}"    # name without .ext
    mdname="$filename.md"            # lets add .md extension

    pathToMd="$MDFOLDER$mdname"      # define the output path

    # Let's rock!
    echo "Processing $mdname"
    pandoc -s "$f" -o "$pathToMd"
done

Awesome! Let’s compile them and look at what I’ve got so far.

jekyll serve -w

Oh it looks kind of messy. The file header it not right. Okay I will go through my posts I also need to change some image urls and stuff.
Nice auto-compile function! While we’re at it let’s also install a nice theme.

Here are some useful code-blocks:

Conclusion

Although it was quite some time editing 60+ posts I really like the result and you may like it too! I’m really glad I took the journey to discover Jekyll.

This very article is my first one completely written in Jekyll on my beloved SublimeText-Editor with some Plugins. (Jekyll, Markdown Preview and Markdown​Editing)

I hope I gave you some insights in my journey and maybe you can save yourself some trouble and fist try Jekyll before you end up digging through the entire internet to find a static site generator you like.

Good luck! ;)

Disclaimer: Dieser Beitrag kann ironische/sarkastische Passagen enthalten. Er ist stellenweise wahrscheinlich sehr technisch. Achso und nein ich bekomme kein Geld von Telegram, ich bin einfach davon überzeugt.

Okay also wir wissen, dass WhatsApp das Imperium ist und von Facebook verschlungen zu werden, kann den Imageschaden der durch zahlreiche Sicherheitsskandale in der Vergangenheit verursacht wurde auch nicht kitten. Also was tut nur der sicherheitsbewusste User? Er wechselt zu Telegram!

Warum Telegram und nicht Threema?

Threema ist eine nicht-freie und kostenpflichtige App. Nicht-frei, was soll das denn heißen? Das bedeutet, dass Threema nicht zu FOSS [Free and Open Source Software] gehört. Das ist bei sicherheitskritischen Anwendungen essenziell um sicher zu sein, dass etwas wirklich sicher ist, denn bei FOSS hat jeder Zugriff zum Quelltext der Software und man kann überprüfen, ob die Software auch das macht was der Hersteller behauptet.

Warum kann man sich bei Threema also nicht sicher sein?
Zwar benutzt laut Hersteller-Angaben eine freie Bibliothek (das heißt dieser Teil ist FOSS) für die eigentliche verschlüsselte Kommunikation und hat zur Überprüfung dafür auch extra ein spezielles Logging bereit gestellt, aber dadurch, dass nicht das komplette Programm einsehbar ist, ist es nicht auszuschließen, dass der Hersteller die Daten - selbst wenn tatsächlich mit NaCl verschlüsselt wird - nicht irgendwo anders abgreift. Das ginge eben nur wenn Threema selbst FOSS wäre, dies ist aber leider nicht der Fall. Dies weiß auch der Hersteller unddeshalb sagte er in einem Interview mit der Zeit:  “Letztlich ist es eine Gefühlssache, ob man mir vertrauen will”

Was macht Telegram also anders?
Zu aller erst ist Telegram FOSS! Telegram steht unter der GPLv2 und ist damit freie Software. Zudem gibt des den aktuellen Quelltext für die Android-Version auf Github und somit ist auch eine einfache Zugangsmöglichkeit gegeben.

Okay Telegram ist frei, aber wie sieht es jetzt mit der Verschlüsselung aus?
Also kommen wir zum Eingemachten. Dies mag für den ein oder anderen zuerst kontrovers erscheinen, macht aber bei näherer Betrachtung durchaus Sinn. Telegram hat sein eigenes Protokoll für die sichere Kommunikation entwickelt, damit der Versand von Nachrichten schnell geht und man auch die Chat-History von anderen Geräten aus einsehen kann. Man ist also immer synchron und kann schnell auch Fotos und Dateien versenden. Damit ist aber die Nachricht an sich nur von Client zu Server und von dort wieder von Server zu Client verschlüsselt. Hier wurde auf Grund der schnellen Übertragung ein Kompromiss zwischen Sicherheit und schneller Verfügbarkeit eingegangen. Deshalb gibt es bei Telegram auch die “secret chats” diese sind dann End-zu-End verschlüsselt. Das bedeutet, dass die Nachricht weder von einem Dritten noch vom Hersteller gelesen werden kann, sondern nur von den Gesprächspartnern. Dies hat ein paar Nachteile, wie zum Beispiel das Wegfallen der Synchronisation über mehrere Geräte, denn die Nachricht ist nur auf dem Empfangsgerät verfügbar. Mann kann aber auch Sachen einstellen wie das automatische Selbstzerstören einer Nachricht. Damit hat Telegram in der Hinsicht dieselbe Funktionalität wie Threema, denn dort ist das Synchronisieren über mehrere Geräte hinweg auch nicht möglich.

[Quelle: Telegram FAQ und Threema FAQ]

Extras

Telegram hat ja sogar noch eine API welche es Entwicklern ermöglicht die vorhandene Infrastruktur von Telegram zu benutzen und eigene Funktionalität hinzu zu fügen oder einfach Telegram auf anderen Plattformen wie zum Beispiel dem Desktop zur Verfügung zu stellen. Das ist nicht nur Spielerei sondern wir werden dadurch in Zukunft hoffentlich viel coole neue Software sehen.

Fazit

Telegram ist im Vergleich zu Threema kostenlos und dazu noch freie Software. Es hat eine Api um Entwicklern das Verwenden von Telegram zu erleichern und es ist mindestens genauso sicher wie Threema, wenn nicht gar noch sicherer. Hinzu kommt die extra Funktionalität und die Tatsache, dass Telegram eine non-profit Unternehmung