Tuesday, July 29, 2014

Git: Show updated tree of branches in console

To do this, just add the following to ~/.gitconfig[alias]
  tree = log --graph --all --decorate --pretty=oneline --abbrev-commit
Then git tree will give text based tree of branches:

To run git tree in console showing e.g. 20 latest commits we can run git tree in a while loop as follows: while true; do clear; git tree -20; sleep 2; done

Wednesday, July 23, 2014

Gnome 3.12: Add VirtualBox machine to gnome's activities and dash

Specific virtual machines can be launched directly from gnome activities or gnome dash without the need to start standard Virtual Box GUI. For this we need to create desktop files and place them in our local applications folder, i.e., /.local/share/applications.
Example of a desktop file starting virtual machine called w7 is as follows (file name w7.desktop)
[Desktop Entry]
Encoding=UTF-8
Version=1.0
Name=w7
Comment=Starts the VirtualBox machine w7
Type=Application
Exec=/usr/lib/virtualbox/VirtualBox --comment "w7" --startvm "25e911a6-7bae-422a-84c2-30ced68d701d"
Icon=w7.png
view raw w7.desktop hosted with ❤ by GitHub
These files can be created manually, but also using Virtual Box GUI. Once we have these files, it is enough just to copy them into /.local/share/applications and they will be e immediately available in the gnomes activities. From the we can just drop and drag them to dash.
If we want to create them manually, we can use the example from the above. The ids of the virtual machines can be obtained using the following vboxmanage list vms
"w7" {25e911a6-7bae-422a-84c2-30ced68d701d}

Tuesday, July 22, 2014

Gnome 3.12: Auto start applications with a delay

In gnome, applications can be start by copying *.desktop files into ~/.config/autostart.

The installed desktop files of your applications are in /usr/share/applications and in ~/.local/share/applications. Thus you can copy files from there into ~/.config/autostart and modify to your liking.

Off course, you can also create your own desktop files for running, or starting applications with a delay. For example, I made the desktop file called myautostart.desktop in ~/.config/autostart[Desktop Entry]
Type=Application
Name=MyStartup
Comment=Starts my applications
Exec=/bin/bash /home/put-your-user-name/.mystartups.sh
X-GNOME-Autostart-enabled=true
Hidden=false
NoDisplay=false

As can be seen the file starts ~/.mystartups.sh which has the following contents:#!/bin/bash
sleep 2
exo-open /usr/share/applications/terminator.desktop
sleep 1
exo-open /usr/share/applications/chromium.desktop

The file launches terminator and chromium using desktop files with 2 and 1 second delays.

Sunday, July 20, 2014

Imagemagick: Flattening tiff images

mogrify -alpha off -colorspace gray -depth 8 -flatten *.tiff

Ubuntu: Fix ntfs parition on usb drive

If there are problems with mounting usb thumb drive (in my case the usb is /dev/sdc1), one can use this:sudo ntfsfix /dev/sdc1

Saturday, July 12, 2014

Capture desktop using ffmpeg and re-size the resulting video.

The following command can be used to record your display and the compress the resulting image ffmpeg -f x11grab -video_size 2560x1440 -i $DISPLAY -f alsa -i default -c:v ffvhuff -c:a flac test.mkv
ffmpeg -i test.mkv -vcodec libx264 -preset ultrafast -qp 0 -acodec copy -vf scale=-1:720 output.mkv

Thursday, July 03, 2014

How to install virtual environment of Python 3.4.x from source in Ubuntu 14.04

Below is a recipe that I use to used to install and set-up virtual environment of Python 3.4.x in Ubuntu 14.04 x64.
# Below are commands used to install and set-up virtual environment of Python 3.4 in Ubuntu 14.04.
# First we need to install dependencies. Please not that this is much larger list than is required for setting up only Python.
# The reason is that usually I and my users install other python packages through pip (list of the popular ones is at the
# end) and these packages also require some packages to be installed first. Thus, I prefer to install everything at
# once.
sudo apt-get install build-essential libc6-dev libreadline-dev libncursesw5-dev libssl-dev libgdbm-dev libsqlite3-dev libbz2-dev liblzma-dev tk-dev bzip2 libbz2-dev sqlite3 tk8.5-dev zlib1g-dev liblzma-dev libblas3 liblapack3 gfortran libopenblas-dev liblapack-dev libmagickwand-dev libxml2-dev libxslt1-dev qtmobility-dev git cmake libqt4-dev libwebp-dev
# Download latest Python, unpack it, and enter into Python folder.
# When writing this post, Python 3.4.1 was the latest release.
wget https://www.python.org/ftp/python/3.4.1/Python-3.4.1.tar.xz
tar xvfJ ./Python-3.4.1.tar.xz
cd Python-3.4.1/
# Configure, compile and install in /opt/python341
./configure --prefix=/opt/python341 --enable-shared
make
sudo make install
make clean
# Create Python virtual invornoment in /home/<yourusername>/mypy34env/
/opt/python341/bin/pyvenv ~/mypy34env/
# active the python virtual environment
source ~/mypy34env/bin/activate
# Check if we are really using the just installed python
which python pip
# expected output
#/home/<yourusername>/mypy34env/bin/python
#/home/<yourusername>/mypy34env/bin/pip
# In some cases, python shared libraries will be need. Thus we can add the location of python's libraries to the linker.
export LD_LIBRARY_PATH=/opt/python341/lib:$LD_LIBRARY_PATH
# I and many my users usually require other packaged (such as numpy, pillow, pyside) to be installed in python.
# With all dependencies installed before, installing these packages is very simple.
# Please note that installing all of them will take a little while. From my experience, pyside takes the longest
# time to compile.
pip install ipython numpy scipy sympy matplotlib pandas pillow wand flask simplejson requests arrow lxml pyside