Moving to a new server is always a challenge. This time I wanted to have a proper version of Python for backend, but the current server only had version 2.4(!). As somebody put it "Wow, that’s ancient!". Anyway, as I wanted to have Django running my application I needed something at least 2.6’ish. I have asked for a new server and after some attempts my hosting provider (Lunarpages) provided me with one. OK, PHP and MySQL seem to be also OK (think of WordPress, etc), so I am settled. Right…
Another example of something that costs time because it is simply not well documented (at least at the moment of writing). When working with Amazon S3 objects (identified by keys in buckets) you may want to get meta-data associated with those keys. In my case I was storing versions (revisions) of backups in meta-data.
Although not being addicted to vim I do happen to use it on a regular basis as it is available on virtually all environments I do meaningful work with :). To get it a bit fancier you can add the following to your
syntax enable set background=dark colorscheme solarized set tabstop=4 set shiftwidth=4 set expandtab
Download and copy corresponding theme like solarized.vim to ~/.vim/colors
If you get annoying A/B/C/D characters when pressing arrow buttons either change
.vimrc to get
or type it in the vim prompt
At certain point my small silent server needed an extra package, but running apt-get only gave me errors. Digging further I found that my /boot partition (default Ubuntu server setup) was running out of disk space. After manually deleting old versions of images I finally got space, but that didn’t fix broken packages, e.g.:
$ sudo apt-get -f install dpkg: dependency problems prevent configuration of linux-server: linux-server depends on linux-image-server (= 220.127.116.11.63); however: Version of linux-image-server on system is 18.104.22.168.69. linux-server depends on linux-headers-server (= 22.214.171.124.63); however: Version of linux-headers-server on system is 126.96.36.199.69. dpkg: error processing linux-server (--configure): dependency problems - leaving unconfigured No apport report written because the error message indicates its a followup error from a previous failure. Errors were encountered while processing: linux-server E: Sub-process /usr/bin/dpkg returned an error code (1)
The only fix I have found was downloading and installing the missing package manually:
$ wget https://launchpad.net/ubuntu/+archive/primary/+files/linux-server_188.8.131.52.69_amd64.deb $ sudo dpkg -i linux-server_184.108.40.206.69_amd64.deb
I find myself searching and (re-)implementing this on a regular basis. The
os.walk is often given as a starting point, but then there are still few lines that are needed to wrap-up.
Although rather trivial, but every time I am still looking it up:
import os dir = os.path.dirname(os.path.realpath(__file__))
Although not exactly fair, while reading the C++ Primer book to refresh my C++11 knowledge during Christmas break (OK, after kids went asleep), I came across the example given for the new C++11 features (lambdas), strings and STL usage in chapter 16, which does nothing more than counting words in a text file. This is a rather classical example and I happen to have it as a part of the Python course I give to my colleagues. Of course I couldn’t hold myself from comparing C++11 and Python as C++11 actually tries to get higher level and closer to languages like Python. Here is what I’ve got.
Continue reading “C++11 vs Python – not quite there yet”
The following command can be used to determine whether your Linux kernel is 32- or 64 bit:
Recently I needed to scan and mail multi-page documents. I have a rather simple scanner that can produce descent .jpeg files, but when combining into a document it sucks. Therefore I prefer to scan in 100% quality and then produce documents depending on my needs.
E.g. hereby some commands to put two scanned pages into a single .pdf document with 75% quality (reducing ~2.3MB images into ~800KB):
convert -quality 75 page_1.jpeg page_1_75.jpeg
convert -quality 75 page_2.jpeg page_2_75.jpeg
convert -page A4 -compress jpeg page_1_75.jpeg page_2_75.jpeg document.pdf