Thursday, May 6, 2010

Writing bachelor's thesis

It's finally done! I just finished writing my thesis and it was really exhausting. But I just though I could put together those little things I found out during my work on this paper. I'm sure, somebody will use it one day.

So there I go: I wrote my thesis in LaTeX on Ubuntu Linux in Czech language. Even if you don't use exactly this combination, it should be useful for you as well. Because I stumbled across a number of issues, I am going to list their solutions and useful links there.

How to get Czech right into LaTeX?
It's simple - just use cslatex. A nice introduction into this.

How to place figures, format text with LaTeX etc.?
This LaTeX cheat sheet is very useful material to have at hand for a quick search. Additionally you can have a look at the online LaTeX book at Wikibooks for a bit more advanced stuff - but it's still very well understandable and straightforward.

How to put vector images in it?
This is actually easy! You just have to convert them to eps or pdf file, according to whether you'll choose (cs)latex or pdftex. Because there is nothing like a universal format, I personally recommend to store the images also in svg format if you would need to edit them later. The Inkscape editor is a good choice for creating vector graphics on Linux anyway (although it's got still some bugs).
The worst scenario is that you get some graphics in a pdf file, created by Word. It's ten times big than it's necessary and nearly uneditable.

How to put bitmaps in it?
The situation get's a bit more complicated at this point. If you use pdftex, you can place your JPEGs and PNGs there without a problem. But if you can't (and that's the case for me, because of the cslatex), you have to convert them to EPS. But you have to do it properly, otherwise the PNGs will be compressed badly. They will have poor quality and at the same time will be 5 times bigger than needed.

The solution for PNGs is to use proper converting utility, because I found out that even GIMP can't convert them alright. My favorite command is:
convert -background "#ffffff" -layers flatten Screenshot.png eps2:Screenshot.eps

The -background and -layers parameters will effectively and in right way get rid of the alpha channel (I saw black fields otherwise). Then you put there the file names, but don't forget the prefix eps2:, which ensures the right version of PS standard. Version 1 can't encapsulate PNGs and version 3 couldn't show in the document. Another interesting thing is that you have to use then the dvipdfmx program, because the dvipdfm or dvipdf don't compress the encapsulated PNGs right, don't ask me why.

What about bibliography?
In the aforementioned wikibook you can find an advanced howto for this. It's better and cleaner to use BibTex. I'll just add a link to the custom style for Czech standard

How to get right line breaking for Czech language?
If you had to place ~ after all short prepositions to get right line breaking, you would probably jump of the window. Therefore there is a useful little program named vlna, which will do it for you. You can read this article about it on and download it.

How to run the whole thing?
You have let it go through latex, bibtex, vlna... it would be really annoying to type in these commands again and again. Fortunately I found a short script for this purpose and added some things to it. Then after any additions I just need to rerun this script, pushing only 2 keys.

vlna -l bakalarka.tex &&
cslatex bakalarka &&
bibtex bakalarka &&
#for glossary
#makeindex bakalarka.glo -s -t bakalarka.glg -o bakalarka.gls &&
dvipdfmx *dvi &&
evince *pdf &

Figure 1: The BASH script for running compilation of the document. The commented out line is for glossary, which I later decided to write on my own, because it was just easier.

Friday, February 19, 2010

Recipe: Antipasto/salad

Today's article is stepping out of the line of other articles pretty much as it's a recipe on an antipasta I've tried this evening. However I don't know how far it is actually Italian as I let myself influence by several recipes on the net and then continued only according to my fantasy and taste.

So it's something between a salad and antipasto and when you add some bread it can be main dish, so whatever :)

Boil some pasta; cut some tomatoes, cucumber, pepper and add olives, capers and mozzarella. You can mix the pasta with the rest and add olive oil, wine vinegar, salt, sugar, garlic and oregano. Before serving add prosciutto/salami and powder with grated Parmesan cheese.

Wednesday, February 10, 2010

Customized PopupMenu in JTable

This is rather a short note about a thing that I have found on the net only partially, so I think it might be useful to post it there. I wanted to create a custom popup menu for any cell in JTable and have the underlying row selected at the same time. In this case common way of adding popupmenus won't suffice. I had to use the following:

public class MyFrame extends JFrame {
        JTable jtable = new JTable();

public MyFrame() {
        jtable.addMouseListener(new PopupListener());

private class PopupListener extends MouseAdapter {

        public void mousePressed(MouseEvent e) {

        public void mouseReleased(MouseEvent e) {

        private void showPopup(MouseEvent e) {
            if (e.isPopupTrigger()) {
                Point point = e.getPoint();
                int row = jtable.rowAtPoint(point);
                int column = jtable.columnAtPoint(point);
                jtable.changeSelection(row, column, false, false);
                /* now we can use custom popup menu, knowing the exact cell */
               , e.getX(), e.getY());

Sunday, January 24, 2010

System lockout after me being quite rude to it

What I've done this this morning: I've run sudo shutdown -h +some time, then changed my mind and clicked on shutdown button in Gnome, BUT I left the previous command running. That wasn't a good idea, because it blocks any other shutdowns, so that I just logged off. It also blocks any other users' attempts to log in. So I decided to shut it down by the button on the case. BAD idea!

When I've come back to my computer this evening, I couldn't log in neither in GDM login manager, nor in console. Wandering, what's going on, I booted from Live CD. At first I had to mount my file system, which is on an LVM2 encrypted partition, which's not quite trivial to play with. But I found this howto that helped me. I searched a bit (at first I thought it's because of PAM as there were plenty of references to it in the /var/log/auth.log), but at the end I found the answer was lying in the manual for shutdown and login... I realized that I am already so pampered by google that it's always the first place I look for.. just anything :-/

The real issue is that the program shutdown creates /etc/nologin and login always looks there and if the file exists, then you can't login. And because I shut it down, it couldn't remove it. That's it. I removed the file and the system than returned to normal.

Saturday, January 23, 2010

jVLT - Vocabulary Learning Tool

Recently, I have read this article on one of my favorite Czech computer e-zines, the And because it was interesting I tried the program. It also has useful and simple homepage, where you can find additional information.

I used it over fortnight and I would like to share with you my experience as it is very positive and I have recommended this program to several of my friends already, who are using it maybe even right now.

The program is based on flash cards principle, that means you can memorize with it whatever pairs of information you want, but it is primarily meant for learning languages. The basic idea is that you put there pairs of words you want to learn and the program will test you with random quizzes. The more difficulties you have with memorizing the word, the more often it's quizzed. And if you know the word, it's repeated less and less over time.

Personal experience

I've already inserted over 400 words. Some of them new to me and some already known, but it's sufficient that you give it only about half an hour every day and you learn everything like nothing :) It's even fun to do the quizzes! I wouldn't learn so much just from my notes even if I wanted, so I think it definitely spares your time and enhances the effectivity of learning.

And now some downsides to balance this article: there are some language definitions e.g. for French, Spanish etc., which tell the program what fields can be added to each word (like conjugation), but they're still much incomplete, so you can't just put it in now. So I plan that when I'm a bit less busy, I'll write some language definitions and send it to the author. Fortunately there's a nice howto, so that everyone with some basic level of knowledge of XML can make them.

Another theoretical downside is that you still have to learn grammar somehow else, because this is only for vocabulary. But there's also possibility to add some examples and interconnect them with words with hyperlinks, so that you can put there at least phrases.

From the features the program offers, there is one especially interesting. You can export/import your data in several formats, e.g. in CSV and XML files, which ensures that even if you wanted to switch to another program, your vocabulary is not lost. There is also an option to merge dictionaries, so that you can share them with your friends (manually).

The good news is that the developers (and some people from community) are still working on it and getting it to a better shape, so that I believe we could even get new features in the future. But it is already nowadays pretty useful.

Other possibilities

There are also alternatives to this program. One of which - Anki is very useful for Chinese, as one of my friends noticed. Perhaps the most complete list of these applications can be found at Wikipedia in the artictle List of flashcard software. They come in different forms, but the principle is the same. I have to admit that I haven't tried any of them, because jVLT just suits my needs well as I've learnt only European languages up to the time.

But some of the programs (namely anki once again) offer sharing your vocabulary on their server, which could be quite useful if it could be shared in groups (for example your colleagues from a language class at your school). Such features could be worth some experimenting.

I really find this much helpful and when you combine it with traditional school lessons, you should be seeing the positive effects pretty soon :)

Thursday, January 14, 2010

3 AM

I know I should get some sleep, but I have to send my assignment to my teacher by Friday and at the same time do an examination from another subject. At 3 AM I just began to merge things together...

Sunday, January 10, 2010

Printf stopped working... or it didn't?

I've just spent 2 hours searching for a problem in my application to find at the end that there was just one character missing. Really funny.

Imagine that you run your program in your IDE and it runs smoothly, then you try it in external console and oops, nothing's showing up. Where's the problem? Why the program stops? Why something showed up and something else did not? You try to debug it, place debug output, comment suspicious things out. And the program just behaves weirder and you see no sense in it.

Finally... I found that the console doesn't print out strings until there is the '\n' char at the end. But the one in my IDE printed it immediately. C is really a challenging language in that sense you've got to watch your every single character written...