Category Archives: Uncategorized

Convert MySQL tables to use UTF8 character set and collation

I moved a Gerrit installation to use MySQL. The tables turned out to be using latin1 encoding.

Here’s a vile concoction, composed of many StackOverflow answers and swamp creatures:

-- update database and each table to use utf8 according to
-- to apply to each table, used
-- use utf8_unicode_ci due to:




        DECLARE table_name VARCHAR(256);
        DECLARE end_of_tables INT DEFAULT 0;

            SELECT t.table_name
            FROM information_schema.tables t
            WHERE t.table_schema = DATABASE() AND t.table_type='BASE TABLE';

        OPEN cur;

        tables_loop: LOOP
            FETCH cur INTO table_name;

            IF end_of_tables = 1 THEN
                LEAVE tables_loop;
            END IF;

            SET @s = CONCAT('ALTER TABLE `', table_name, '` CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci;');
            PREPARE stmt FROM @s;
            EXECUTE stmt;

        END LOOP;

        CLOSE cur;
    END $$


Let’s use this stored procedure, and then drop it.

ALTER DATABASE reviewdb CHARACTER SET utf8 COLLATE utf8_unicode_ci;
USE reviewdb;
CALL utfAllTables;

Sadly, it looks like ALTER DATABASE is not PREPAREable, nor does it accept a variable or a function
call as its database name. Therefore, I could not pass DATABASE() here, nor could I move the ALTER DATABASE
statement inside the stored procedure.

Importing laptop into Ireland from outside EU

I am not a lawyer nor an accountant. This is not legal advice. I may be wrong.

Bureaucracy == exercise in exploration!

First, you want to read the general information for individuals, including PN 1878a – Customs and Excise Information for Travellers Arriving in Ireland from Countries Outside the European Union.

In PN 1878a there is an odd reference to digital cameras being 0% duty, and VAT 23%. Where does that come from?

In the section intended for businesses we can find the document A Guide to Customs Import Procedures (PDF) which mentions a system called TARIC. What is TARIC?

Apparently TARIC is an EU-wide system for determining duty on imports. Customs Directorate of Croatia (or whatever the name in English is) apparently also maintains their own TARIC query system with matching data.

Now we need the appropriate code. What is the code for laptops?

It’s 8471410000. If you enter this code and then drill down into ‘for use in civil aircraft’ and ‘other’, you’ll see that in both cases the duty is 0%, in most countries. (In Croatian mirror site, pick ‘Section XVI’ and ‘Chapter 84’. I find it curious that the Croatian system’s UI seems cleaner than the official EU system. More outdated, but nonetheless cleaner.)

Since USA is not on the list, I would presume it fits under the ‘Erga Omnes’ list.

Alright, what about VAT? There is a list of tax rates maintained by the Irish Tax and Customs. Laptops seem to fit under Computer Hardware – Supply, which has a Standard VAT rate. As of 1 January 2014, this rate is 23%.

My conclusion is that the duty is 0%, and that only VAT of 23% is paid.

Considering top-of-the-line 15″ Macbook Pro Retina costs $2.599 = 1877.21 EUR * 1.23 = approx 2309 EUR – versus 2649.00 EUR – we get the difference of 339 EUR that are still saved by buying the laptop from the US.

Fun. 🙂

For the record, no, I did not choose to buy a laptop (nor this laptop in particular) — but exploring my options is good.

Ubuntu 13.10 live CD: Blank screen with EFI

Ubuntu 13.10 fails to start X11 on a Macbook Pro with retina display, and it fails to start X11 on VirtualBox when EFI mode is turned on. Even the failover mode fails. This has been tried with 64-bit version of Ubuntu 13.10. Machines: a 2013 Macbook Pro; and a virtual VirtualBox 4.3.6 machine configured for Ubuntu (64-bit) OS, with EFI turned on.

Ubuntu’s failover configuration tries to use vesa module, which is not available when running under native EFI or UEFI mode.

Let’s fix this by using fbdev module.

  1. Hit ctrl+alt+f1 to switch to console.
  2. Type sudo -i to become root.
  3. Now let’s fix the relevant files:
    cd /etc/X11/
    sed 's/Driver.*"vesa"/Driver "fbdev"/' xorg.conf.failsafe > xorg.conf
  1. Restart X11 et al: service lightdm restart
  2. If necessary, switch to the VT dedicated to X11: hit ctrl+alt+f7

Note that the screen will stay blank for a while longer; give the system some time to proceed.

Good luck!

On the referendum

For me, the issue was not (bluntly) whether the gay marriage is good or not.

The issue is whether stupidity and ignorance will prevail.

Well, now we see how damaging can changing referendum rules be. You see, some time before Croatia entered EU, constitution was amended to permit referendum to be valid without 50% voter turnout.

Croatia voted to enter EU with 43% turnout.

Today, with 37% turnout, Croatian voters demonstrated inability to separate their anxiety from good judgement.

And it’s simultaneously funny and sad; I’d love to see the reaction of people who said: “If 57% of voters can’t be bothered to turn out at the voting booths, then it’s okay to ignore their votes.” The same people have probably voted ‘against’, and are now widely disappointed.

I’m saddened by the fact that 24% of Croatian population has successfully demonstrated that a well-orchestrated brainwashing campaign of fear, uncertainty and doubt can succeed perfectly in Croatia. I’m saddened because this type of population is right for getting an oppressive but populist regime in place. 24% activists + 62% passives. Think of those numbers.

Reading articles on Croatian news portals from the distant Ireland, I see that there’s already talks about a referendum on “cyrillic”, a script whose presence in Vukovar, a city heavily damaged in the war during attacks by a cyrillic-using nation, offends a lot of people. So now not only are we taking away rights that didn’t exist in the first place, but we’ll have a referendum on a script, and waste 5 million more euros.

It’s sad that this thing managed to pass even with a disgusting brainwashing campaign run by certain large newspapers opposing the referendum question.

It’s sad that this thing managed to pass even among the international voters.

I’m happy that Croats in my new home, Ireland, voted ‘against’.

When leaving, I simply *knew* I’d be coming back some day. Now, I’m saddened that 24% of people manage to be misinformed and misled. I’m saddened that 62% find their vote to be irrelevant. And I’m questioning whether I can count on finding the 12% that has been both active and reasonable.

Oh scratch that; considering the campaigns against the referendum, the “reasonable” part is actually much smaller.

To the world: I’m sorry.

To my homeland: I hope you will heal some day.


Just a short note that I’ve went to Dublin on November 6th, and I started working for Google on November 11th. Well, not quite working — training.

I won’t post work related stuff to avoid wrath of the security people 🙂 but I’ll try to expand a bit more on my impressions of Dublin, a bit on the overall atmosphere of the workplace (no confidential or even work-related stuff), and similar “safe” things.

What I can tell you is that — I can recommend Ireland, and it’s great at work training.

Movie to animated gif

To get an animated gif from a movie, I do this:

ffmpeg -i themovie-%02d.png
convert -verbose +dither -layers Optimize themovie*.gif GIF:- > themovie.gif

convert comes from ImageMagick. I could/should pass some more stuff to ffmpeg and convert, such as -s to resize and -r to change FPS of the PNGs, or -resize to resize the output gif.

More info in this gist.