# 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 conf.py 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 https://github.com/ltiao/oh-my-zsh.git .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

2. Key shortcuts

3. $curl -o "Solarized Dark.itermcolors" https://raw.githubusercontent.com/altercation/solarized/master/iterm2-colors-solarized/Solarized%20Dark.itermcolors  $ curl -o "Tomorrow Night Eighties.itermcolors" https://raw.githubusercontent.com/chriskempson/tomorrow-theme/master/iTerm2/Tomorrow%20Night%20Eighties.itermcolors

1. Background Opacity
2. Background dimming, animation

## Themes

Bullet Train for oh-my-zsh

$cd .oh-my-zsh/custom/themes/$ curl -O https://raw.githubusercontent.com/caiogondim/bullet-train-oh-my-zsh-theme/master/bullet-train.zsh-theme

ZSH_THEME="bullet-train"


## Powerline-compatible 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.

# 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.

# Adding __name__ and __doc__ attributes to functools.partial objects

The partial function from the functools library is useful for performing partial function application in Python. There are plenty of guides and resources on functional programming in Python and this post assumes a reasonable degree of proficiency with both.

# 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.

# Python SimpleHTTPServer Recipe: Enable CORS

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

#! /usr/bin/env python

from SimpleHTTPServer import SimpleHTTPRequestHandler, test

class CORSHTTPRequestHandler(SimpleHTTPRequestHandler):

if __name__ == '__main__':
test(HandlerClass=CORSHTTPRequestHandler)


# 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: