Donnerstag, 10. Oktober 2013

Install and update to latest Intel driver in Ubuntu (without PPAs)

If you are running a Laptop with integrated Intel graphics, it's pretty easy to update your drivers to the latest stable version, without running a PPA. You can easily build and install the driver on your own:
  1. Get the necessary dependencies:

    sudo apt-get build-dep xserver-xorg-video-intel

  2. Download the driver version you want to install (either stable tagged or git) from:

    http://cgit.freedesktop.org/xorg/driver/xf86-video-intel/

  3. Now (extract the archive and) open a terminal in the folder
  4. Set the x64 library path:

    export PKG_CONFIG_PATH=/usr/lib/x86_64-linux-gnu/pkgconfig:$PKG_CONFIG_PATH

    This is necessary to otherwise the configuration step will fail.

  5. Configure everything to set install path to /usr:

    ./autogen.sh --prefix=/usr

  6. Build the driver:

    make

  7. Install the newly build driver to /usr:

    sudo make install

  8. Reboot and check whether new driver is installed and looking into:

    /var/log/Xorg.0.log

    Search for 'LoadModule: "intel"' (without ''). Three lines below you find your actual running driver version.
Beware: This will overwrite your actual installed driver. To revert to your previous driver (in case of problems), just reinstall it via: sudo apt-get install --reinstall xserver-xorg-video-intel

Dienstag, 17. September 2013

Build and install latest PostGIS in Ubuntu Linux

If you need to stick with the latest PostGIS version for your PostgreSQL-database, you either have to find a suitable PPA or simply build the extension yourself, because Ubuntu's PostGIS version is out-of-date. Instead of using 3rd party PPAs, I recommend to build it yourself the following way:

  1. Install the prerequisite packages:

    sudo apt-get install packaging-dev postgresql postgresql-server-dev-9.1 libxml2-dev libgeos-dev libproj-dev libgdal-dev

  2. Download the sources (e.g. for PostGIS 2.1.0):

    wget http://download.osgeo.org/postgis/source/postgis-2.1.0.tar.gz

  3. Extract the sources and go into extraction folder:

    tar xvzf postgis-2.1.0.tar.gz; cd postgis-2.1.0

  4.  Configure the sources

    ./configure

  5. Compile PostGIS

    make

  6. Install the compiled PostGIS extension

    sudo make install

  7. Use PostGIS within PostgreSQL:

    CREATE EXTENSION postgis;
     
Now you can build and control the update of your PostGIS versions by yourself.

Freitag, 6. September 2013

Process PostgreSQL data in R with Ubuntu Linux 12.04

Here is the ultimate overview  for all who like to work with R in Ubuntu and who want to process data from PostgreSQL. As a requirement, I assume that you already setup your PostgreSQL database.


  1. Step: Install dependencies (PostgreSQL, JDBC-Connector for PostgreSQL and R)
    sudo apt-get install postgresql libpostgresql-jdbc-java r-base-core r-cran-rjava r-cran-dbi 
  2. Step: Open Terminal & run R with
    R
  3. Step: Install JDBC-Package (RJDBC) for R
    install.packages(c("RJDBC"))
  4. Step: Connect to your database from within R
    # Include JDBC package
    library(RJDBC)

    # Initialize JDBC PostgresSQL driver
    drv <- JDBC("org.postgresql.Driver", "/usr/share/java/postgresql-jdbc4-9.1.jar", identifier.quote="`")

    # Establish connection to database
    conn <- dbConnect(drv, "jdbc:postgresql://localhost/database", "user", "pw")
    # Run your SQL select query
    data <- dbGetQuery(conn, "select * from iris where Species='setosa'")
  5.  That's it :) 
If you want to connect a non-local database, you have to adjust your dbConnect-command.

Donnerstag, 29. August 2013

Create Virtual Machine with Windows Guest using Qemu/KVM in Ubuntu Linux


I think Qemu/KVM represents a nice native alternative to Virtualbox or similar. Although all the GUI-tools (like aQemu or Qtemu) are broken in Ubuntu 13.04, it's really easy to setup a VM using the terminal. Precisely, you only need 3 commands to get a running VM:

  1. Create an image, where your VM is installed in. For Windows (>XP) take at least 18Gb:

    qemu-img create -f qcow2 ~/VMs/Windows\ 7/Windows\ 7.qcow2 18G

  2. Install your preferred OS in the created image:

    qemu-system-x86_64 -hda ~/VMs/Windows\ 7/Windows\ 7.qcow2 -cdrom ~/windows7_image_x64_.iso -boot d -m 4096 -cpu kvm64,+nx -enable-kvm

    Explanation for the parameters:
    This launches the typical Windows installation, whereas your new image represents your HDD to install to and -cdrom sets your installation media. The -boot parameter ensures that your VM boots the proper partition (you might can leave it out) and the option -m reserves 4096MB RAM for your VM (adapt it to your system). The -cpu parameter ensures that a 64-Bit CPU is emulated, because it's a KVM CPU you have to enable KVM in Qemu too.
    Note: Adapt the options to your system, especially in case your x86 user!
     
  3. After installation completed, launch your VM with:

    qemu-system-x86_64 ~/VMs/Windows\ 7/Windows\ 7.qcow2 -m 4096 -vga std -enable-kvm -cpu kvm64,+nx

    Of course you need to define the CPU again, enable KVM and set the memory. The option -vga std enables more and higher resolution within your VM, so use it if your are unsatisfied with low resolution.
     
That's it ! Of course you can also Linux VMs with it.

Two additional tips:
  • If your mouse pointer is caged within VM, free it with LEFT-[CTRL]+[ALT]
  • You can reach your Host from the Guest from the IP 10.0.2.2. This might be handy for web developers.

Dienstag, 27. August 2013

Enable Cover-Preview for Audio Files for KDE's Dolphin in Kubuntu 13.04


Unfortunately cover art preview is still not included in KDE (see Bug-report), you can enable that feature by yourself by building and installing the Preview Plugin of RazrFalcon from kde-look.org.

So, if you ever wanted a cover art preview for audio in Dolphin, e.g. like Nautilus has, here's my guide to make it work in Kubuntu (13.04):


  1. Install the necessary dependencies for building:

    sudo apt-get install cmake automake kde-workspace-dev libtag1-dev libqt4-dev libflac++6 libflac++-dev libtag-extras-dev

  2. Get the sources of the plugin:

    wget http://kde-look.org/CONTENT/content-files/145088-AudioThumbs-0.2.tar.gz

  3. and create a folder for it to unpack it:

    mkdir ~/audiothumbs;
    tar -zxvf 145088-AudioThumbs-0.2.tar.gz -C ~/audiothumbs


  4. Cd into the folder with sources and create a build dir and cd into it:

    cd ~/audiothumbs; mkdir build; cd build

  5. Now prepare building with cmake:

    cmake -DCMAKE_INSTALL_PREFIX=`kde4-config --prefix` ..

  6. Finally compile it with:

    make

  7. and install it with:

    sudo make install

  8. Update KDE's settings to find the new plugin:

    kbuildsycoca4

  9. End all open Dolphin windows and reopen it. Go to "Control -> Configure Dolphin... -> General -> Previews" and enable "Show previews for Audio files"

  10. Now move to your folder with music and enable preview for the folder and enjoy the cover art in dolphin

Dienstag, 20. August 2013

Completely encrypt your external HDD / USB-Key securely using Ubuntu Linux


If you ever wondered how to encrypt some external devices in Ubuntu or Linux in general, the following commands will guide you:

1. Create a crypted LUKS container for your device (replace /dev/xxx with your device):    

sudo cryptsetup --cipher aes-xts-plain64 --key-size 512 --hash sha512 --iter-time 5000 --use-random --verify-passphrase luksFormat /dev/xxx

You can also spare the additional parameters, cryptsetup will fall back on the default  parameters. Further explanation of what each parameter means can be found here.  

2. Open you encrypted container:    

sudo cryptsetup luksOpen /dev/xxx crypt_container    

3. Create a file system within the opened container (e.g. ext4):

sudo mkfs.ext4 /dev/mapper/crypt_container


4. Close the container and unmount it:    

sudo cryptsetup luksClose crypt_container     
sudo umount /dev/xxx    

That's it. Finally, if you disconnect and replug you device, Dolphin or Nautilus  will ask you for you password and mount it as every standard device.   If you need to check your new encrypted device or partition for errors, read this.

Donnerstag, 15. August 2013

Create *.po translation files from Vala Sources with context information in Ubuntu / Linux

I recently tried to create a *.po-File for translations strings from Vala sources which include locale context information.
As it was not so easy to figure out the right command, I thought I would share it with the internet folks:

xgettext -o result.po -L C -k_ --keyword=C_:1c,2 src/*.vala

So how does this work ?
  • xgettext extracts the translatable strings from the sources 
  • ...and puts it into the output file (-o result.po)
  • ...it also requires a defined programming language in this case C (-L C)
  • ...and needs to know what are translatable keywords (_ for strings and C_:1c,2 for contextual information, in this case)
  • ...finally set the input files (src/*.vala)
It's not that hard if you understand how it works :)