Monday, May 13, 2013

To gradle daemon or not to gradle daemon?

The gradle daemon speeds up builds quite a bit and you do want to have it running on your local machine but not on the build server, that one should always re-build from scratch. This is actually quite easy to accomplish.

In your '~/.bashrc' add the following export so your local machine runs all builds with the gradle daemon:

export GRADLE_OPTS="-Dorg.gradle.daemon=true"

Since, by default, the gradle daemon is not started, it will not be used on your build server.

Sunday, May 12, 2013

How to mount an iPod in linux

I'm currently trying to get rid of my iPod and move all my music to my android phone. Needless to say my iTunes installation on the PC is long gone and these iDevices are the proverbial bottomless bit - you'll never get anything back out of them, or do you?

Thanks to the libimobiledevice and ifuse projects, you can now mount an ipod like any normal usb stick in linux, and it doesn't even have to be a rooted device.

# get ready
aptitude install ifuse
mkdir /media/ipod

# mount
ifuse /media/ipod

# unmount
umount /media/ipod

If you want to mount the device as a normal user, make sure that user is part of the ifuse group.

And that's how to mount your iPod. Making a backup is as easy as calling 'cp -r' or rsync. However, the music files' filenames are completely fubard and since my id3 tags aren't that good I'll need to work with the sqlite3 db that apple stores information in but I'm still working on that part.

First steps on a new postgresql installation

I've found myself trying postgres over mysql for a few things and had some trouble accessing the db server at all at first. So here's how you first access the server:

$ su -          # su to root
# su - postgres # su to postgres
$ psql          # access the server

That wasn't so hard now was it? Once I'm in the psql shell, I tend to issue the following SQL statement so my primary user has unlimited access, to make things easier for development:

postgres=# CREATE USER my_user SUPERUSER;

And that's all the trouble you need to go trough to get started with postgres.

Now you can just call 'psql' as your primary user and do whatever the hell you like (including destroying all data in the db). Note that, when just calling psql, you'll get an error like 'psql: FATAL: database "my_user" does not exist', so just do 'psql postgres' to get in and create some other database.

Thursday, May 9, 2013

Always test your Puppet Modules

Always test your puppet modules. Even if it's just a little smoke test like this:

class { my_module: }

Now to make this one better, create a job on your continuous integration server and let it run the following script inside the modules directory of your puppet project:

It looks for all '*.pp' files inside all 'tests' directories and does a simple 'puppet apply' call. It may not be perfect but it's small, simple, it works and it'll save you some gray hairs.

The next logical step would be to have a playground of virtual servers newly initialized from scratch/snapshot where you can actually run the modules and verify they behave as expected. All this with a config that's as close to your productive environment as possible so you catch and fix as many problems as possible in a throwaway environment instead of production. Unfortunately there's no way I'll be doing something as extensive as this in the forseeable future.

Another interesting thing would be to write JUnit/TestNG compatible reporting xml files so your build server will be able to display results of individual tests and distinguis successful from failed tests.

Monday, May 6, 2013

Resizing VirtualBox Drives

My Virtualbox images are usually fairly small. Here's how to increase the size of a vbox disk, to 8G in this case:

vboxmanage modifyhd /home/user/vbox/vm/vm.vdi --resize 8192

After that, remove the disk from the vm it's currently attached to, hook it to a new vm, which will boot from an iso file. Once booted, start gparted. It will complain that the gpt partition table is not (anymore) at the end of the disk, ignore that message and you'll see the full disk with the initial partition plus additional space at the end. Resize the partition on the disk or create new partitions, whatever you like. Save the changes, stop the vm, move the drive back to the initial vm and start that one again.

Now, if you're on a LVM volume group, you'll need to vgextend the drive. For an ext2 or higher filesystem you'll need to run resize2fs.