sharing technical knowledge

How to install adobe reader under ubuntu 14.04 64 bit

leave a comment »

Get the tar.bz2 of the last version from here, unpack the archive:

tar xjvf AdbeRdr9.5.5-1_i486linux_enu.tar.bz2

run the installer

cd AdobeReader/
sudo ./INSTALL


sudo apt-get install libxml2:i386 lib32stdc++6 libgdk-pixbuf2.0-0:i386 libgtk2.0-0:i386

Et voilà, acroread works now

Written by Domenico

June 17, 2014 at 8:25 am

Posted in posts

Tagged with , , , , ,

Quick’n dirty ISO 8859 (Latin 1) with CRLF conversion

leave a comment »

On your linux workstation:
iconv -f 8859_1 $input_file | tr -d '\r' > $output_file
will convert ISO8859 input files to UTF8 and then remove the tedious carriage return.
If you need to use some text file loaded by a Windows user this could be useful.

Written by Domenico

October 19, 2012 at 11:35 am

Posted in posts

Tagged with , , , , , , , , ,

Get 8.3 Windows short path names in a QT application

leave a comment »

If for some obscure reason you need such a feature in your QT application, you can use the following code, which just wraps the native GetShortPathName Windows function:

#ifdef Q_OS_WIN
#include <windows.h>
QString shortPathName(const QString & file) // returns 8.3 file format from long path
    wchar_t* input=new wchar_t[file.size()+1];
    input[file.size()]=L'\0'; // terminate string
    long length = GetShortPathName(input, NULL, 0);
    wchar_t* output=new wchar_t[length];
    QString ret=QString::fromWCharArray(output,length-1); // discard 
    delete [] input;
    delete [] output;
    return ret;

Written by Domenico

October 1, 2012 at 9:30 am

A Proxy Switcher Application Indicator for Ubuntu

with 23 comments

UPDATE: Proxindicator is now compatible with ubuntu 12.04, and incorporates the good old gnome 2 proxy settings dialog.

I developed a small and useful Application Indicator for ubuntu (and whichever distro supports appindicators) to switch between network proxies without the need for browser-specific extensions (such as FoxyProxy for Firefox and Proxy Switchy for Chrome).
It uses the “locations” defined through System -> Preferences -> Proxy settings… (gnome-network-properties) as switching profiles.
The app is surprisingly called proxindicator and the source code can be downloaded from my launchpad repository using bazaar:

bzr branch lp:proxindicator

I’ve conveniently packaged .deb in my ppa. Simply add my repository and install the package:

sudo add-apt-repository ppa:domurb/domurb-projects
sudo apt-get update
sudo apt-get install proxindicator

then restart your session (log out and log in) or simply launch (Alt+F2) to make the indicator appear in the indicator applet.

Ciao ;)

Written by Domenico

July 8, 2011 at 9:56 am

Convert Xferlog file to CSV

leave a comment »

Many FTP servers (such as proftpd and vsftpd) support the Xferlog (transfer log) format. This is a standard format supported by some log file analysis tools, like webalizer.
I needed to convert this file to CSV (comma separated values) format, so that it could be easily imported into Excel or OpenOffice Calc or any DB. This isn’t so easy because xferlog uses space as separator, which complicates log analysis when transferred file name also contains spaces. Nonetheless the filename can be extracted with these simple sed rules:
< /var/log/xferlog sed 's/.*\ \//\//' | sed 's/\ [ab]\ [_CUT]\ [oid]\ [agr]\ .*//g'
The first sed matches everything until a space followed by a slash is found (begin of the filename), and replaces the matched string with a simple slash. The second sed matches all possible sequences following the filename, and deletes them.
So I wrote this bash script:


< $LOG awk '{print $4 ";" $6 ";" $7 ";" $8 ";" $(NF-6) ";" $(NF-4) ";" $NF}' > .tmp1.csv

#rewrite dates in DD/MM/YYYY format
while read line
        d=$(echo $line | awk '{ print $3 "-" $2 "-" $5 }');
        date -d $d "+%d/%m/%Y" >> .dates
done < $LOG

#save users' home dir
touch .tmp2.csv
for USER in $(cut -d ";" -f6 < .tmp1.csv)
        grep "^$USER:" /etc/passwd | cut -d":" -f6 >> .tmp2.csv

# extract filename
< $LOG sed 's/.*\ \//\//' | sed 's/\ [ab]\ [_CUT]\ [oid]\ [agr]\ .*//g' > .tmp3.csv

# mix temporary file into a csv output file, and then delete them
paste -d";" .dates .tmp1.csv .tmp2.csv .tmp3.csv > $(basename $LOG).csv
rm -rf .tmp*.csv .dates

this way, a file named xferlog.csv will be produced. A sample line containing:

Sun Mar 20 11:11:12 2011 7870 735238584 /path/to/filename b _ i r user ftp 0 * c

will be converted to:

I retain the home directories because local users are chrooted in my configuration (chroot_local_user=YES in vsftpd.conf); otherwise you can skip .tmp2 file creation.

I hope it’s useful. Bye bye

Written by Domenico

March 26, 2011 at 12:57 pm

Combine PDF files using GhostScript

with 4 comments

Some days ago i needed to combine some pdf files into one pdf output file, using a shell script on my CentOS workstation. 
On other Linux distros this can be easily accomplished using pdftk:
pdftk file1.pdf file2.pdf file3.pdf cat output newfile.pdf

But unfortunately CentOS hasn’t the useful pdftk in its default repositories. Instead of adding it from an external repo, i implemented the pdf merge command using GhostScript:

for i in $(seq $(expr $# - 1) -1 1) 
  echo -n "${BASH_ARGV[$i]} " 

This script can be saved as, made executable with a simple:
chmod +x
and then put into a directory that is in your $PATH environment variable (for example i use ~/bin).

Then it can be used as follows: file1.pdf file2.pdf file3.pdf output.pdf

The last argument is the output file. Of course it supports wildcards: *.pdf output.pdf

The script exploits the BASH_ARGV array, containing all the arguments in reverse order. This way, ${BASH_ARGV[0]} is the last argument (output file) while the for loop matches the other arguments (input files). Remember that $# is the total number of arguments, including the executable name ($0).

update october 2013:
You can do it with a one-liner:

gs -dNOPAUSE -sDEVICE=pdfwrite -sOUTPUTFILE=/dev/stdout -dBATCH "$@"

The only difference is that you have to redirect stdout to your target file when you call the program, like this: *.pdf > output.pdf

With the previous implementation, if you forget to put the output file as the latest argument, the program will overwrite the last input file. Moreover now it works even when input file names contain spaces. Therefore the new implementation is more compact, safer, and complete :)

Written by Domenico

February 16, 2011 at 11:15 am

Best Nautilus script to mount ISO images

leave a comment »

I know, there’s a lot of stuff on the internet about mounting ISO images as a loopback device on linux . Basically you can do this from a terminal:

mkdir /media/example
mount -o loop example.iso /media/example

from root account or using the sudo facility. There are some GUIs to automate this (gmountiso for example).

Yesterday i was searching for a fast way to mount ISO images directly from the Nautilus file manager (gnome’s one),

  1. allowing multiple images (mass) mount/unmount
  2. possibly without root privileges.

Read the rest of this entry »

Written by Domenico

December 15, 2010 at 10:08 am


Get every new post delivered to your Inbox.