Upgrade Ubuntu server with boot partition full

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 (= 3.2.0.53.63); however:
Version of linux-image-server on system is 3.2.0.58.69.
linux-server depends on linux-headers-server (= 3.2.0.53.63); however:
Version of linux-headers-server on system is 3.2.0.58.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_3.2.0.58.69_amd64.deb
$ sudo dpkg -i linux-server_3.2.0.58.69_amd64.deb

Enjoy!

C++11 vs Python – not quite there yet

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”

Scan and create multipage .pdf files from .jpeg

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

One-liner to rename files in bash

To rename many files from one pattern to another use e.g.

for i in *.jpeg; do mv $i ${i//exampel/example}; done

Some useful patterns:

${parameter//substring/replacement}
${parameter##remove_matching_prefix}
${parameter%%remove_matching_suffix}
${parameter:offset}
${parameter:offset:length}
${parameter:offset:length}

To check whether the parameter is null:

${parameter:+use this if param is NOT null}
${parameter:-use this if param is null}
${parameter:=use this and assign to param if param is null}
${parameter:?show this error if param is null}

Joomla! upgrade

Unbelievable that such a simple thing as an upgrade to a newer version of CMS may cause any headache these times. Recently I have received a warning message from my host (lunarpages.com) that I still use an old version (1.7.2) of Joomla! for my company site, while a newer version is available. I have tried to follow official upgrade procedures for about an hour without success, resulting in wrong layouts and half-working admin functionality, and finally ended up just downloading the complete package for Joomla_3.1.5-Stable-Full_Package.zip and simply unzipping it to the current installation folder. That did the trick (well, almost) leaving me with the similarly popular warning message

Joomla upgrade warning Error
Your host needs to disable magic_quotes_gpc to run this version of Joomla!

After some googling around the following solution worked. I have created two files as shown below in the folder with Joomla! installation (so not affecting other websites) and that did the trick.


[php.ini]
magic_quotes_gpc = Off
session.save_path = "/home/<user>/tmp"


[.htaccess]
/home/<user>/www/<site>/php.ini

Enjoy!