Skip to content

Instantly share code, notes, and snippets.

Avatar

fak

  • London, UK
View GitHub Profile
@fak
fak / deploy_ppdms_on_myChEMBL.md
Last active Aug 29, 2015
Deploy the ppdms resource on an Apache web server (myChEMBL image)
View deploy_ppdms_on_myChEMBL.md

Setting the scene

First we need to add a few modifications to te existing environment. In order to communicate with the github servers, we will generate ssh keys using ssh-keygen -t rsa -C "your_email@example.com and then add them to the list of ssh keys in the github profile.

For a working bash and vim environment, we can clone the dotfiles repo with git clone git@github.com:fak/dotfiles.git and from within that repo cp bashrc ~/.bashrc and cp vimrc ~/.vimrc.

To activate a few nice features of vim we will also git clone https://github.com/gmarik/vundle.git ~/.vim/bundle/vundle and then open vim and use :BundleInstall to get our favourite colour-scheme, status bar and so on.

We also want to set up a virtualenv as described here.

@fak
fak / gist:9647804
Last active Aug 29, 2015
define a SQLAlchemy connection string, eg. for csvsql
View gist:9647804
sqlalchemy_connection_string = "postgresql://%(user)s:%(pword)s@%(host)s:%(port)s/%(release)s"% params
@fak
fak / biblatex_hack.md
Last active Nov 16, 2016
No period after one-letter initials in biblatex
View biblatex_hack.md

In an ideal bibliography file, authors are identified by full last name and full first name. The citation formatting will then abbreviate first names to initials or keep full names according to user specifications. However, when parsing meta-data from articles, full names are often abbreviated to initials. Biblatex takes these initials as full names, which is logical but not practical, given the incomplete nature of many of the meta-data. Thus, authors with only a single first name will not have a period after their name initial if the initial was the only first name information available to biblatex. To fix this, a hack was proposed in a post on stackexchange. For me and my limited understanding of biblatex, this did not work out of the box, but combined with this post I figured that what I needed to do was to set m

@fak
fak / TB_attach_bounce.md
Last active Jan 2, 2016
Thunderbird attachments bounce with message ''BANNED: application/x-msdownload,.pdf"
View TB_attach_bounce.md

Noticed some strange behaviour when sending a pdf file that had been compiled with LuaTex. Messages sent with this file attached would come bouncing right back at me with a message BANNED: application/x-msdownload,.pdf and would be saved under the name nsmail.exe in Thunderbird's cache folder. Other pdf files would be sent without problems. Even more confusing, saving the file using Preview solved the problem in some kind of blackbox process. The only obvious difference between the two files was that the LuaTex header said pdf 1.5 while the header of the Preview-saved file said pdf 1.3.

I found some threads that dealt with similar problems here and here. Apparently TB assigned the incorrect MIME type to the pdf file I compiled with LuaTex, in this case application/x-msdownload,.pdf rather than simply application/pdf. By then I had a feeling that this behaviour was some

@fak
fak / awk_concat
Created Dec 17, 2013
awk - concatenate multiple .txt files without header
View awk_concat
awk FNR-1 *.txt > target.txt
@fak
fak / virtualenv_wo_wrapper.md
Last active Dec 30, 2015
using virtualenv without virtualenvwrapper
View virtualenv_wo_wrapper.md

But virtualenvwrapper is awesome...

Yes it is, but some situations might make it difficult for us to use it. For example, we might be working on system without root access and thus be unable to install virtualenvwrapper using sudo pip install virtualenvwrapper.

In that case we have to work with virtualenv as it is. This is not very dramatic, we just have to manage the location of virtualenv by ourselves.

So in any suitable location, we can create a virtualenv (eg bootstrap) with virtualenv bootstrap and activate it using source bootsrap/bin/activate. From that point onwards, we are operating on the virtualenv. At least from version 1.10+, virtualenv already has pip installed so we can install any package with pip. To revert to the system we can simply do deactivate.

@fak
fak / virtualenv_on_mychembl.md
Last active Dec 30, 2015
virtualenv on myChEMBL
View virtualenv_on_mychembl.md

cool but why

The myChEMBL virtual machine comes with a number of python modules already installed, which means in most cases things will work just fine. In case additional modules are needed, virtualenv allows to experiment with different combinations and versions of python on one single instance of the myChEMBL VM. In this gist, I specify the steps necessary to set up virtualenv on the myChEMBL VM.

setting up

The first step is to install the python package manager pip. This can be done using easy_install, a more basic package manager for python. It is already installed on myChEMBL but in case it still needs to be installed, this can easily be done using

sudo apt-get install python-setuptools python-dev build-essential

So once that is sorted we can install pip with the command

You can’t perform that action at this time.