Category: Notes

Non-cyclic keyboard layout switching

22.02.2010 16:30 ·  Notes  ·  linux, xkb

I was taken with the idea of non-cyclic layout switching and configured my notebook to work this way.

What is non-cyclic keyboard layout switching? Imagine you have several keyboard layouts; for example, I have three: English, Ukrainian, and Russian. Normally, to switch between these layouts, you use a single shortcut, like Ctrl + Shift, and the layouts change one by one all around: en → uk → ru → en → uk… So if the current layout is English and you need Russian, you would have to press the shortcut twice to get there. Another problem is that in order to switch to the desired layout, you have to remember which keyboard layout is currently active and the order in which they change. You could argue that this is no big deal, as there is a visual indicator in the system tray most of the time. But the truth is that if you often have to switch between layouts and use different layouts in different windows, it is not very convenient, although most people are used to it and do not realise it.

With non-cyclic keyboard layout switching, each layout has its own shortcut, for example, CapsLock for English, Shift + CapsLock for Ukrainian, and Ctrl + CapsLock for Russian. In this case, you only need to press the shortcut once to get the layout you want. You don’t need to worry about which layout is active or remember which layout is used in a particular window. Just press the hotkey before you start typing. Simple.

After a few days of using this setup, I agree that it is indeed much more convenient than the standard cyclic switching, where you have to press the hotkey several times to get the layout you want.

2009 Recap

31.12.2009 10:02 ·  Notes  ·  recap

Last post of the year. It’s a good time to look back and summarise what happened.

At the end of April, I started my more or less active participation in the GIS community, which over time has become more than just a thematic resource and community for me. I found new friends here, and now most of my activities are directly or indirectly related to it.

Changing jobs… seems like a pretty big change. But after six months, I don’t see any improvements or advantages compared to my previous job. Promises are still promises, and everything I wanted to get away from is still there.

2009 will be remembered as the last year of the “senior” group of the pop dance team “Bravo”. For the last two years, the senior group has only been getting smaller and smaller, and here we are… In September, there were only five people left from the whole collective - 4 girls and 1 guy. But a bunch of newcomers arrived without any choreographic training. Our place was taken by the “middle” group, which continues to gain momentum, winning first places and all sorts of prizes at all sorts of festivals and competitions. All thanks to our artistic director and choreographer. Well done, Ira!

My first (and hopefully not the last) trip to the QGIS developer meeting took place this year. A week of working on QGIS, new friends, discussions, and a lot of impressions. Now I know for sure that QGIS is going to conquer the world :-).

After returning from Austria, I switched to using Linux. On the desktop, Windows has moved to the last line in the bootloader menu, and on the laptop, it is not there at all. Despite the lack of a few small things, Linux is an amazingly convenient and powerful system. There is no desire to go back to Win. I keep the “other system” for testing and a few very specific programs.

Happy New Year, everyone!

Switching to Linux

10.12.2009 16:36 ·  Notes  ·  linux

I’m gradually moving from a desktop to a laptop, and spending more and more time on Linux.

By and large, the transition to Linux is almost complete. There are still a few projects that were originally developed for Win (they are very specific tools), some of which I plan to port and those that cannot be ported at all - will run in VirtualBox.

From time to time, I find myself missing some programs and tools that I am used to as a user of another system. But this is more due to ignorance.

P.S.: vim, of course, is very powerful, but to get used to it… its tutorial is very short and covers only a few topics.

QGIS hackfest 2009 (Vienna)

24.11.2009 08:05 ·  Notes  ·  qgis, travels, meetings

It’s been almost a month since I returned from Vienna and I still haven’t written anything about Hackfest. I’m not a good writer.

Read more ››

Laptop

02.11.2009 08:24 ·  Notes  ·  laptop

An idiot’s dream :-). Finally it came true - I got a laptop.

Actually, I’ve been thinking about getting a laptop for a long time, but the fact that I have a desktop computer at my disposal has stopped me. There was no real need for a laptop. Cold calculation and expediency have always prevailed over childish “I want it!” impulses. But now the situation has changed in favour of this purchase. I’m going to the QGIS hackfest, and there will probably be more travelling after that.

I opted for a Lenovo ThinkPad SL500. It is not the most powerful machine at the moment, but it was not bought for games. As one article said, “The best laptop is YOUR laptop”, and mine suits my needs quite well :-). The only thing that is a bit annoying is the glossy top lid. It seems to be a problem for all manufacturers: everywhere I’ve been - all laptops are glossy, and many not only on the outside, but also on the inside. So I didn’t have much of a choice here. The newer SL510 is matte (thanks to Patrick, they came to their senses!), but it is impossible to get it now, especially in our province.

For those who are interested, here are the brief specifications: 15.4" WXGA TFT display, Celeron DualCore T3000 1.8GHz/800MHz, GL40 Express chip, integrated video GMA 4500M, RAM 2048 Mb DDR2 667 MHz (PC2-5300), HDD 250 Gb, DVD-RW, modem, Wi-Fi, Bluetooth, LAN 1 Gb/s, 7-in-1 card reader, webcam 2 Mpx, 4 USB ports, there are also headphone and microphone outputs, HDMI, FireWire and VGA. A detailed review can be found on notebookcheck.net, where the same model is described, but with a slightly different configuration.

I have already installed DeepStyle 3.1, updated some packages and am now setting up a build environment for QGIS. I also need to read a lot of mans and do some fine-tuning (suspend, power management, CPU frequencies, etc.). But all this will probably be done after the hackfest, as there is not much time left.

Back from jungle

01.11.2009 10:02 ·  Notes  ·  visa, travels

I haven’t written anything for a month, as I just haven’t had enough time, and internet access has been quite limited at times. The most important news is that I’m going to the QGIS Hackfest in Vienna. Actually, the discussion about attending the hackfest started more than 2 months ago at the end of August, but I deliberately did not write anything because there were a lot of problems and ambiguities, especially the question of the visa. It was only this week that everything finally became clear.

The most difficult part was getting a visa from the Austrian embassy. The first thing you need to do is call the embassy or visit them in person to get the list of documents required and make an appointment. The last option is more suitable for Kyiv residents; for the rest, it is better to make a call. Remember that there is a charge for the call (€12) and that you can only pay by VISA or MasterCard, so keep your card details around.

The list of documents is not very long, but for all the documents you need a copy with a translation into German, otherwise, they will not be accepted. I have collected the following documents:

The documents should be submitted one month before the planned date of departure. Of course, you can submit them earlier, but they will only be processed one month before anyway. I went to Kiev, stood in line and handed in the documents. Last week I received a call for an interview and went to Kyiv again…

It turns out that I am a suspicious person for the embassy. I got my passport back in April 2008, but it was “clean” until now (well, I haven’t had much luck travelling). So “clean” passport — one. I’m travelling alone — two. Only for 5 days — three. Four: travelling alone, all alone and and not on a sightseeing tour from some agency. Going to the capital — five (Why? For what? He’s probably a terrorist). I talked to the officer for about 15-20 minutes, and here the letter with the invitation to the hackfest, or rather to the “developers’ meeting” (if it had said hackfest - I would certainly have left without a visa), which I had asked the organisers for in advance, came in very handy. Then I waited almost 4 hours for an answer, but it was worth it - they gave me a visa in the end. For exactly 5 days. Now I am packing my bags.

P.S.: You can read about the upcoming hackfest in Vienna on the wiki. There is also a blog post with a report on the previous one, which took place in Hannover this spring, and an interview with the participants. If I get the chance, I will try to post updates directly from the scene or share my impressions when I get back. And this post can be seen as a teaser :-).

Building QGIS with MSYS

01.09.2009 08:14 ·  Notes  ·  qgis

I wanted to build QGIS on Windows using MSYS + MinGW. I gathered all the necessary programs and libs, updated the QGIS code from SVN and, armed with the “Coding and compilation guide”, set to work. It took my Sempron almost two evenings to compile the dependencies and QGIS itself. It went well at first, but when I got to avce00, I stuck. That thing would not compile at all, throwing warnings and errors at almost every line. I gave up and grabbed the binaries from OSGeo4W. That did the trick.

And this is the moment. It’s compiled. I run it and… and nothing. QGIS crashes at the beginning of loading. I run it from the console - it crashes again, leaving an “Access violation” message in the terminal. So here I am scratching my head and trying to figure out who to blame: avce00, my two left hands or spots on the sun. There are many reasons for this behaviour. Even developers say that building with MSYS and MinGW is quite a complex process.

I decided to postpone it for now, and in the meantime, I will try to build QGIS with VisualStudio Express. I need it for work.

Again about non-ASCII characters in matplotlib

04.08.2009 08:07 ·  Notes  ·  matplotlib, python, tips

A bit more about Cyrillic and other non-ASCII characters in matplotlib. I decided to create a more comprehensive example to show how to output Cyrillic (or any other non-ASCII) characters in different parts of the plot. Actually, there is nothing complex here; you just need to find the time and read the manual, which is quite good, by the way. But as not everyone likes to read manuals… Anyway, here is the code:

#!/usr/bin/env python
# -*- coding: utf-8 -*-

from pylab import *
import matplotlib.pyplot as plt
import matplotlib.font_manager as fm

plt.rcParams["text.usetex"] = False
fp = fm.FontProperties(fname="/home/alex/devel/mpl_cyr/CharisSILR.ttf")
plt.text(0.5, 0.5, u"довільний текст", fontproperties=fp)

# create some data to use for the plot
x = arange(0.0, 3.0, 0.01)
y1 = sin(2 * pi * x)
y2 = cos(2 * pi * x)

# the main axes is subplot(111) by default
plot(x, y1, label=u"Синусоїда")
plot(x, y2, label=u"Косинусоїда")
xlabel(u"Підпис вісі X", fontproperties=fp)
ylabel(u"Підпис вісі Y", fontproperties=fp)
title(u"Назва графіка", fontproperties=fp)
legend(prop=fp)
show()

Cyrillic and other non-ASCII characters in matplotlib

23.07.2009 17:49 ·  Notes  ·  matplotlib, python, tips

There is a wonderful Python library - matplotlib. It is a plotting library that supports a wide range of plot types and is designed to emulate MATLAB commands and behaviour. The library is easy to learn; to draw a simple plot, you literally need two commands. I have used this library in my Statist plugin for QGIS and in another GIS project. To make installation of matplotlib more convenient for inexperienced users, I recently packaged it for OSGeo4W.

Sometimes, I needed to display non-ASCII (namely Cyrillic) characters on matplotlib plots. And there was a problem: such text was drawn as empty squares. Reading manuals, googling, and asking on the mailing list led to two solutions that I would like to share with you.

Method 1: the almighty TeX

matplotlib can use LaTeX to display both plain text and mathematical symbols. Moreover, a limited subset of TeX and the corresponding parser, fonts, and renderer are built into the library, so for this subset, you do not even need to have a full TeX installation. Unfortunately, this TeX subset only contains mathematical characters and letters of the Greek alphabet. In all other cases, an external LaTeX installation is required. To use LaTeX for text rendering, we should set the option

text.usetex: True

in the rc-file. This can be done either globally, by editing the rc-file once, or as needed at runtime. Below is an example of run-time initialisation:

# -*- coding: utf-8 -*-
from matplotlib import rc

rc("font", {"family": "serif"})
rc("text", usetex=True)
rc("text.latex", unicode=True)
rc("text.latex", preamble="usepackage[utf8]{inputenc}")
rc("text.latex", preamble="usepackage[russian]{babel}")

Now we can output Cyrillic (or any other non-ASCII characters)

xlabel(u"Вісь Х: довжина, см")

The big disadvantage of this method is that the user needs to have LaTeX installed.

Method 2: unicode + fonts

matplotlib uses its own font rendering engine with full Unicode support. Therefore, we can explicitly specify a font that contains the required character sets and render the text using that font. Here is a small example:

# -*- coding: utf-8 -*-

import matplotlib.pyplot as plt
import matplotlib.font_manager as fm

plt.rcParams["text.usetex"] = False
fp = fm.FontProperties(fname="/home/alex/.fonts/academy.ttf")
plt.text(0.5, 0.5, u"кириличний текст", fontproperties=fp)
plt.show()

There is also a disadvantage - the required font may not be available on the target system or may be in a different directory, so the font has to be stored in the same directory as your program. But in my opinion, this is much better than having LaTeX as a dependency.

Personally, I chose the latter option.

Vacations and GIS

08.07.2009 15:32 ·  Notes  ·  spatialite

It’s been a week since I went on “last year’s” holiday. Yes, I managed to get those unused 19 days. But that doesn’t stop my bosses from pestering me with phone calls and even dragging me into the office a few times. But all in all, it is very good.

I have more free time, which I spend not only on holidays but also on interesting and necessary things like plugins for QGIS. I’ve already received some feedback on Statist, and I’m improving it. Also, I have an idea for another plugin, but I don’t know if it will be implemented yet.

I am also involved in a GIS project, or rather, its continuation. I came across a nasty bug in the SpatiaLite provider in QGIS. At least, it seems to me that it is a bug. This has caused some difficulties, and I have to look for workarounds…

By the way, a few days ago, Alessandro Furieri (SpatiaLite author) announced the release of SpatiaLite 2.3.1 and released two new projects:

In my opinion, SQLite-based spatial databases are a real alternative to shapefiles. Although shapefiles are the de-facto standard in GIS today, they are already outdated and do not meet the ever-increasing requirements.