Nine-patch Bitmaps on Android

Excerpt from new Android Training by Google:

Supporting different screen sizes usually means that your image resources must also be capable of adapting to different sizes. For example, a button background must fit whichever button shape it is applied to.

If you use simple images on components that can change size, you will quickly notice that the results are somewhat less than impressive, since the runtime will stretch or shrink your images uniformly. The solution is using nine-patch bitmaps, which are specially formatted PNG files that indicate which areas can and cannot be stretched.

Therefore, when designing bitmaps that will be used on components with variable size, always use nine-patches.


Multiple gcc versions on Ubuntu machine

# let the beast in

# install the older gcc versions
apt-get install gcc-4.4
apt-get install g++-4.4

# configure
update-alternatives --remove-all gcc
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.4 44
 --slave /usr/bin/g++ g++ /usr/bin/g++-4.4
 --slave /usr/bin/gcov gcov /usr/bin/gcov-4.4
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.6 46
 --slave /usr/bin/g++ g++ /usr/bin/g++-4.6
 --slave /usr/bin/gcov gcov /usr/bin/gcov-4.6

# switch gcc
update-alternatives --config gcc


git user configuration override

In case if it's required to have a different user configuration from the one stored in .gitconfig, there is two possible ways to achieve this:

Local (per git)
$ cd git-repo
$ git config user.name "Name Surname"
$ git config user.email "name.surname@domain.com"

This method will override default or git's user configuration. Add following to .bashrc:
function gitswitch () {
    case "$1" in
        export GIT_AUTHOR_EMAIL="name.surname@domain.com"
        export GIT_AUTHOR_NAME="Name Surname"
        export GIT_COMMITTER_EMAIL="name.surname@domain.com"
        export GIT_COMMITTER_NAME="Name Surname"
        echo "Using custom configuration."
        unset GIT_AUTHOR_EMAIL
        unset GIT_AUTHOR_NAME
        unset GIT_COMMITTER_NAME
        echo "Using default configuration from .gitconfig."
        echo "Bad argument - please specify 'custom' or 'default'."
And then:
$ gitswitch custom
Using custom configuration.
$ gitswitch default
Using default configuration from .gitconfig.
$ gitswitch ?
Bad argument - please specify 'custom' or 'default'.


To Go or not to Go?

Apparently Go language makes more and more community attention. Today made a 15 min try and was surprised how simple and fast you can get into it.
Surprisingly, there is bindings for GTK which allows to write GUI apps for both Linux and Windows, and one of the demos looks as simple as:
package main

import (

func main() {
	window := gtk.Window(gtk.GTK_WINDOW_TOPLEVEL)
	window.SetTitle("GTK Table")
	window.Connect("destroy", gtk.MainQuit)

	swin := gtk.ScrolledWindow(nil, nil)

	table := gtk.Table(5, 5, false)
	for y := uint(0); y < 5; y++ {
		for x := uint(0); x < 5; x++ {
			table.Attach(gtk.ButtonWithLabel(fmt.Sprintf("%02d:%02d", x, y)),
						 x, x+1, y, y+1, gtk.GTK_FILL, gtk.GTK_FILL, 5, 5)

	window.SetDefaultSize(200, 200)



First post, again

Finally decided to move my blog to blogspot. Hello World.