• NFS 101

    NFS might not be the fastest, but it surely is the simplest one across *nix environments.

    server side


    $ sudo apt-get install nfs-kernel-server portmap

    share directory by editing /etc/exports


    It could be just one IP or subnet as shown above. Then restart exports if configuration errors, it’ll scream.

    $ sudo exportfs -a

    or /etc/init.d/nfs-kernel-server restart which is giving roughly the same thing

    client side


    $ sudo apt-get install nfs-common portmap

    That’s enough to get started mounting.

    1. mount directly

       $ sudo mount <server-ip>:/opt/share /mnt/share
    2. to make it permanent, edit /etc/fstab

       <server-ip>:/opt/share  /mnt/share   nfs auto,noatime,nolock,bg,nfsvers=3,intr,tcp,actimeo=1800 0 0

    That’s simple.


    To list all mount points:

    $ showmount -e <server-ip>

    Mount on OSX might not be as effortless. However, resvport option would make thing simple again.

    $ sudo mount -t nfs -o resvport <server-ip>:/path /<destination>
  • OSX El Capitan: pip install virtualenvwrapper error

    I faced the problem that pip had no permission over some weird directories and installation failed. That happened with me when pip install virtualenvwrapper

    To make it work, dealing with its dependancies manually is a must.

    sudo pip install pbr
    sudo pip install --no-deps stevedore
    sudo pip install --no-deps virtualenvwrapper

    Your virtualenvwrapper should work as it should.

  • rabbitmq unable to start

    If rabbitmq cannot start and give you this following error.

    Error description:

    Then, there is something wrong in your queue messages. The easiest fix would be deleting all the existing queues.

    $ sudo rm -rvf /var/lib/rabbitmq/mnesia/*

    or on OSX (via brew)

    $ rm -rvf /usr/local/var/lib/rabbitmq/mnesia/*

    Start rabbitmq again :) it should run fine.

  • Save x page per sheet PDF in python

    Reportlab is my go-to PDF library in python; however, it doesn’t do multiple page layout well. The solution is to do regular multiple pages PDF with reportlab, then process that PDF file afterward to have any layout you want (2-page per sheet, 4-page per sheet, 9-page per sheet, …)

    What you need?

    pdfnup – it’s available via pip but an ImportError always there. As a result, you need to download that and do install by yourself.

    $ python setup.py install

    Simple enough. You also have a command line to work on too.

    >>> from pdfnup import generateNup
    >>> generateNup("multiple-pages.pdf", 2, verbose=True)
    written: file-2up.pdf

    There you go.

  • Virtualenv with python3

    Nowadays, although python2 still are the production preferred choice, python3 is maturing and surely started taking over. Testing under python3 environment is pretty easy.

    On Linux, most distros have both python2 and python3 bundled. However, on OSX, you need to install python3 by yourself. Fortunately, it is one command away with the magic of brew.

    $ brew install python3

    Then you could check by calling python3 if it works. Then you could make a virtuanenv with python3.

    $ mkvirtualenv --python=`which python3` en-py3
    (en-py3) $

    That’s all. Nothing extra required. Happy testing your app on python3