Posts (old posts, page 4)

Workflow for keeping Nikola config file updated

For most, keeping Nikola up-to-date is usually a simple matter of running something like:

$ pip install --upgrade nikola

The same goes for its dependencies. However, one important thing that can get overlooked is the Nikola configuration file for your site (the file sitting at the root of your Nikola site directory), which is almost always updated with each major Nikola release.

Read more…

Louis does dotfiles... again

Switching to Zsh

First I created a fork of Oh My Zsh and added it as a submodule to my existing dotfiles repository under a directory named .oh-my-zsh:

$ cd $HOME/Dropbox/dotfiles
$ git submodule add .oh-my-zsh

Since my dotfiles repo is a fork of Mathias Bynen's dotfiles, which is primarily for bash, there shouldn't be any conflicts. In fact, we should be able to switch seamlessly between using zsh and bash as the default shell.

$ cp .oh-my-zsh/templates/zshrc.zsh-template .zshrc
$ vim .zshrc
export ZSH=$HOME/Dropbox/dotfiles/.oh-my-zsh

Add or modify files in .oh-my-zsh/custom

Commit and push

$ stow --simulate --verbose=1 --ignore='(gitmodules|oh-my-zsh)' --dir=/Users/ltiao/Dropbox dotfiles
$ stow --verbose=1 --ignore='(gitmodules|oh-my-zsh)' --dir=/Users/ltiao/Dropbox dotfiles
$ chsh -s /bin/zsh

Switching to iTerm2

  1. Download and install iTerm2

  2. Key shortcuts

  3. Solarized Dark:

    $ curl -o "Solarized Dark.itermcolors"

    Tomorrow Night Eighties:

    $ curl -o "Tomorrow Night Eighties.itermcolors"
  1. Background Opacity
  2. Background dimming, animation


Bullet Train for oh-my-zsh

$ cd .oh-my-zsh/custom/themes/
$ curl -O

Powerline-compatible Fonts

  1. Download Powerline fonts

  2. Install a font. "Meslo LG S Regular for Powerline" is probably just as good as any.

  3. Configure iTerm2 to use font


Creating custom (Unix) fortunes

Like others, I include fortune in my .bash_profile so that I am greeted with a random, witty and thought-provoking epigram upon starting a new shell session. Eventually, however, I found most of the epigrams to be mostly trite and vapid, and quickly grew tired of them. Instead of tinkering with the probabilities of sampling from the various datafiles available, I decided to roll with my own epigram datafile.

Read more…

Louis does dotfiles


For a long time, I kept a small set of minimalistic dotfiles (.bash_profile, .gitconfig, .vimrc). You probably couldn't find anything in my .bash_profile other than exports and path definitions that were absolutely necessary to get tools such as Homebrew and virtualenvwrapper to work. Furthermore, I was dismissive towards spending any significant amount of time down the rabbit hole of perpetual dotfile customization and optimization.

Recently, while digging through my bookmarks saved from months ago, I came across GitHub does dotfiles. Needless to say, after perusing through some of the most popular dotfiles, dotfile utilities and tutorials, I came away quite impressed. It disabused me of my previous misbelief that dotfile calibration is ultimately a fruitless and ceaseless task, and I decided to give it another shot.

Read more…

Python SimpleHTTPServer Recipe: Serve specific directory

  • We need to be able to pass the path to the root of the directory tree we wish to serve.
  • We can only pass arguments to the ServerClass and not HandlerClass. Note however that HandlerClass is passed as an argument to ServerClass so we should be able to propagate the argument to HandlerClass.
  • The translate_path method of SimpleHTTPRequestHandler takes the /-separated path specified in the URL and prepends os.getcwd() to it. We just have to instead prepend the argument we propagated to SimpleHTTPRequestHandler.
  • Lastly we modify the test function to take multiple optional arguments (port and base path) using the excellent module argparse.

Read more…

Python SimpleHTTPServer Recipe: Enable CORS

Create a file, let's call it, with the code below:

#! /usr/bin/env python

from SimpleHTTPServer import SimpleHTTPRequestHandler, test

class CORSHTTPRequestHandler(SimpleHTTPRequestHandler):

    def end_headers(self):
        self.send_header('Access-Control-Allow-Origin', '*')
        super(CORSHTTPRequestHandler, self).end_headers(self)

if __name__ == '__main__':

Read more…

Installing lxml on Mac OSX (10.11) inside a virtualenv with pip

The lxml library is a dependency for many popular Python projects such as Scrapy and Nikola. If you are a Mac OSX user, it's highly likely that you have encountered the following error when trying to install lxml or its dependants with pip:

In file included from src/lxml/lxml.etree.c:346:
$WORKON_HOME/venv_name/build/lxml/src/lxml/includes/etree_defs.h:9:10: fatal error: 'libxml/xmlversion.h' file not found
#include "libxml/xmlversion.h"
1 error generated.
error: command 'clang' failed with exit status 1

Read more…