Articles

Jetbrains in Unity integration

In Java, Ubuntu on 02/07/2012 by weirdfellow Tagged: , , , , , ,

I really really love products by . Those guys really know what a developer expects, needs and they deliver. However, the IDEs (I have been using IntelliJ IDEA, as well as PhpStorm) don’t integrate with Unity that well – it’s not possible to pin the icon to launch bar, the windows do not merge and you get duplicate icons etc.

To tackle this problem, you can create custom launchers and drop them into /usr/local/share/applications (you might need to create this directory first).

IntelliJ IDEA.desktop

[Desktop Entry]
Name=IntelliJ IDEA Community Edition
GenericName=Java Editor
Comment=Develop with pleasure!
Exec=/usr/local/programs/idea-ce/bin/idea.sh
Icon=/usr/local/programs/idea-ce/bin/idea.png
Type=Application
MimeType=text/plain;
Categories=Development;
StartupNotify=true
Terminal=false
NoDisplay=false
StartupWMClass=jetbrains-idea-ce

PhpStorm.desktop

[Desktop Entry]
Name=PhpStorm
GenericName=PHP Editor
Comment=Develop with pleasure!
Exec=/usr/local/programs/phpstorm/bin/phpstorm.sh
Icon=/usr/local/programs/phpstorm/bin/webide.png
Type=Application
MimeType=text/plain;
Categories=Development;
StartupNotify=true
Terminal=false
NoDisplay=false
StartupWMClass=jetbrains-phpstorm

The important thing is the StartupWMClass - it allows Unity to identify the windows and connect them to icon in the launcher, so that they merge nicely... Small thing, but makes me so much happier :)

Articles

Cannot open Name index using db3

In Ubuntu on 28/09/2011 by weirdfellow Tagged:

I am using Ubuntu 10.04, but often have to work with RPMs – see what’s inside or get the content. And errors drive me crazy – “Cannot open Name index using db3 – No such file or directory (2)” especially.

Eventually I figured it out. If you are getting it, that means the file /var/lib/rpm/Name is missing.

Because I am on Ubuntu and don't really depend on RPMs databases, I purged the whole /var/lib/rpm directory, and then ran rpm --rebuilddb to recreate them. This created empty /var/lib/rpm/Packages file. Now just copy it as /var/lib/rpm/Name.

Error free environment :)

Articles

Compressing RAM with zRam

In Ubuntu on 04/05/2011 by weirdfellow Tagged: , , , , , , ,

A successor to compcache, zram, has been already integrated in the Linux kernel for a while now. This means that no additional compilation nor tweaking is required to benefit from compressing memory on the fly and massively reduced swapping.

As with compache, I wanted to nicely integrate the solution into the Ubuntu Upstart deamon – hence this short article. After a couple of minutes of playing the configuration was ready.

Create file zramswap.conf in /etc/init and put the following content in it.

description "Initializes zram swaping"
 
start on runlevel [2345]
stop on runlevel [!2345]
 
pre-start script
 
# load dependency modules
modprobe zram num_devices=2
 
# initialize the devices
echo 1073741824 > /sys/block/zram0/disksize
echo 1073741824 > /sys/block/zram1/disksize
 
# Creating swap filesystems
mkswap /dev/zram0
mkswap /dev/zram1
 
# Switch the swaps on
swapon -p 5 /dev/zram0
swapon -p 5 /dev/zram1
end script
 
post-stop script
 
# Switching off swap
swapoff /dev/zram0
swapoff /dev/zram1
 
rmmod zram
end script

Now you can start the service with sudo start zramswap (it will be automatically started on after the reboot as well).
You will benefit from 2x1GB swap files, which will be compressed and stored in the RAM. Tested on Ubuntu 11.04.

Articles

I don’t believe in Groovy

In Java on 31/10/2010 by weirdfellow Tagged: ,

I always try to stay on the open minded part of the population. I have been trying with Groovy too… Half year later I can state – it is a fancy toy that looks great in the sample, but not a generic purpose language.

Groovy advocates usually have following reasoning:

Static typing doesn’t give any benefits – you have to unit test anyway
I am almost certain that nobody will ever hear from me that testing is unnecessary – quite the opposite.
But type checking allows to instantly identify a whole bunch of common coding mistakes, without need to wait for the tests to execute (and those can take some time)…

Java is too verbose, Groovy is much more compact.
Let’s make the identifiers optional wherever there is only one token in scope that fits! Compiler can figure things out and the code will be 17 bytes shorter!!! All this time I would have spent so much time on pressing the space…

Java is verbose – but what is wrong in being verbose? The more compact code, the more comments are required and it the end it sums up to the same number of bytes. I could start writing a more verbose, self explanatory Groovy code too. In other words – to make a code that is easier to read I would have to discard the compactness of Groovy. In such case – why bother with Groovy at all?

I don’t deny Groovy the right to exist – I definitely can see its the benefits. There are even things in Groovy I really like. Closures. Compact syntax for creating instances of ArrayList and HashMap. XML parsing. Groovy definitely can be useful.

However I am certain that those are only the situations when once you got working code, you never touch it again… Projects when the functionality has to be there now, and will be thrown away week later. Or tiny, very specialized classes you can throw away when they need to change and write them again. Refactoring a Groovy code will be a nightmare – because of its dynamic nature.

So – if doing anything with longer time frame, anything that might get refactored – keep away from Groovy.

Articles

Patching Cairo

In Ubuntu on 01/08/2010 by weirdfellow

I had it enough… GTK applications are respecting some of the Fontconfig setting (you can switch antialias or hinting on/off), but others were just ignored (it wasn’t possible to specify hintstyle or switch between grayscale and subpixel antialiasing)… Not only I have had issue with that – in my case the “quasi-bitmap” fonts used for programming look much better with grayscale AA. There were some ad-hoc patches, for instance cairo-respect-fontconfig, but they don’t really fix the problem – just sweep the problem under the carpet.

First of all I had to decode what is used to render fonts in Gnome. After identifying that the bugs are in Cairo, I decided to compile it myself. After a bit of the struggle with missing libraries – thank you Ubuntu for Synaptic Package Manager – I managed to compile Cairo 1.8.10. I have applied patches shipped with Ubuntu and started to look into the problems.

The functions dealing with properties returned by Fontconfig have been rewritten and profusely commented – patch file and binary package available to download below.

Be aware: After the installation, you might notice that the Appearance panel seems not to work. This behavior is intentional and absolutely OK.
Gnome does not save it’s settings in Fontconfig registry, and by default Fontconfig comes with some settings – they are stored in files in /etc/fonts/conf.d. By default they cover switching on antialiasing (10-antialias.conf) and switching on slight hinting (10-hinting-slight.conf). In the result Fontconfig will always override those two settings.

As a workaround, remove those two mentioned symbolic links, and the panel will start to behave correctly again. Files 10-hinting.conf and 11-lcd-filter-lcddefault.conf are ok and should stay in /etc/fonts/conf.d. The long term solution would be for Gnome to save the font settings in the Fontconfig registry too - I am working on the plug-in for gnome-settings-daemon, that would do this.

Downloading

The source of Cairo is available from the project homepage, but I downloaded the source package from Ubuntu launchpad - this version does not require autoconf, you can just call ./configure.

Patching

Ubuntu patches are to be downloaded from here. Each patch is to be executed from cairo-1.8.10 directory in following manner:
$ patch -p 1 <path-to-the-patch-file. After applying Ubuntu patches, you can apply my patch.

Compilation

My version of library would compile, but it was much bigger than the one shipped within distro. Setting environment variables to skip debug information and add some optimizations prior executing configure (export CFLAGS='-Wall -g0 -O0 -O2') helped a lot. After successful execution of configure and make, the result can be found in src/.libs directory. Copy it into the /usr/lib folder and restart X.

Results and downloads

Finally I have fonts that work as I want.

Patch file from Rapidshare
Binary package from in progress.

Statuses

In Shorts on 31/07/2010 by weirdfellow

Does Git stand for Great Innovative Technology?

Articles

Insanity

In Ubuntu on 25/07/2010 by weirdfellow Tagged: , , , , , , , , , , ,

This is just insane…

The number of blog articles, forum posts and standard proposals definitely proves it….

After struggling with it for a while I have finally managed to (at least I hope so) get an overview of the font rendering stack in Gnome… That’s how it looks at the moment (Ubuntu 10.04):

Gnome fonts settings are stored in gconf registry (~/.gconf). They are read by gnome-settings-daemon and automatically published in two places: xrdb - and XSETTINGS. In addition to the Gnome settings, there is the Fontconfig with the handful of configuration files (/etc/fonts/fonts.conf, /etc/fonts/conf.d/*, /etc/fonts/local.conf and ~/.fonts.conf). All settings are combined by Cairo lib (which behaves weirdly when dealing with Fontconfig data - there are a few bugs in there) and Xft is invoked to render the fonts.

xrdb registry can be listed by calling xrdb -query. Getting to see the published XSETTINGS properties is a bit more tricky - but possible with tools provided by xsettingsd project. Install it (there are binaries for Ubuntu) and execute dump_xsettings. It is even possible to get rid of gnome-settings-daemon - useful especially for the KDE guys running GTK apps.

Why the hell doesn't it look like that? Fontconfig sole purpose is to store font configuration information, why are additional registries introduced?

Appearance panel would need just to create/remove symlinks in ~/.fonts.conf.d/ to files in /etc/fonts/conf.avail or create one own there. There would be 5 of those for default values of: one for hinting and hintstyle, autohint (now still not available through GUI), antialias and lcdfilter. gnome-settings-daemon wouldn't need to publish fonts settings anywhere... If the gconf must stay, there might be a plugin for gnome-settings-daemon that would publish the gnome font settings in a Fontconfig file, instead of xrdb and XSETTINGS.

It doesn't sound like rocket science and definitely would make the font settings more consistent. Life would be so much simpler...

Follow

Get every new post delivered to your Inbox.