Why I hate English language


A friend of mine asked me, why I hate English so much?

I picked up a random object (a toilet spray) with an English text to demonstrate why.
The text was “Shake can well
I said:

  • each word in this sentence has too many meanings:
    • well can be “healthy”, “a hole sunk into the ground as a source of water” and many other meanings as well;
    • can can be “to be able”, but can be “cylindrical vessel for liquids” or “prison” or even a slang word for buttocks.
    • the word shake also has many meanings.

this demonstrates that any word can mean anything, and every random sentence can have hundreds unrelated meanings.


So this is a tongue with wrong grammar and huge vocabulary, where each word has too any meanings. Altogether, this makes language poorly suited for communication. I refuse to like it.

hard chinese


My new and unrelated blog: chinehard.wordpress.com

This is my answer to Chineasy.

Compiling CERES library


Just a note.

After many attempts to build CERES library with SuiteSparse using VS2012, I came out to this:

  • use CMAKE to build .vcxproj file, but without SuitSparse, LAPACK and BLAS (otherwise it fails)
  • compile

Image registration with genetic algorithms, again


Given two images, we want to “reigster” them.

After resizing (pyramid, to speed-up the algorithm) and normalizing (to improve the registration) I’ve tried to find shift + rotation (3 degrees of freedom) using algorithms in matlab’s global optimization toolbox.

  • genetic-algorithm – results are good only if initial guess is good/ image offset is small, even with customized parameters.
  • Direct Search – very good results (but the offset is integer, for some reason)
  • Simulated Annealing – poor results

In all cases, the following function was used:

%try to make B similar to A
function a = cor(alfa1)
 global A B 
 global roi

 b1=imChange(B, alfa1);
 a1=imcrop(A, roi);
 a = 1-corr2(a1,b1);

%vector of form [offset-x, offset-y, angle]
function out = imChange(im, vector)
 global roi
 alfa = vector(3);
 offset = vector(1:2);
 B1=imrotate(im, alfa,'bicubic', 'crop');
 out=imcrop(B1, roi+[offset 0 0]);

Playing with Matlab


Image registration using ga (genetic algorithm)

Given two images, A and B, try to find affine transformation to maximize correlation between the to images.

This simple code works on simple images with simple transformations.

function res=reg1()
 clear all;
 close all;

 global A B


 options = gaoptimset('Generations',50);
 options = gaoptimset(options,'MutationFcn',@mutationadaptfeasible);
 options = gaoptimset(options,'PlotFcns',{@gaplotbestf,@gaplotmaxconstr}, 'Display','iter');
 options = gaoptimset(options,'InitialPopulation',[1 0 0 0 1 0]);
 [a,fval] = ga(ObjectiveFunction,6, options);

function a = cor(alfa)
 global A B
 alfa = reshape(alfa, 3, 2);
 t_n = maketform('affine', alfa);
 D = imtransform(A,t_n);
 D = imresize(D, size(B));

 a = 1-corr2(B, D);



“Missing articles project” most popular articles from English Wikipedia that are missing in Russian Wikipedia – for approbation before I create those articles in WIkipedia, or just for fun.


–update 28/6:
1 week later,

  • Дерехо” is 6 place in anonymous google search.
  • Аашикуиis the only 1 result
  • Малани Медиссон
  • – page, not a blog post – is not reachede by google.

    Veg(etari)an Georguan Cousine


    Vegan Georgian Dishes:

    kitri da pomadori nigvzit (tomatoes and cucumbers with walnut dressing)
    mtchadi (corn bread)
    ajapsandali (stewed vegetables: usually eggplants and potatoes)
    dziteli lobio (red beans)
    badrijani nigvzit (eggplant with walnut dressing)

    Vegetarian Georgian Dishes:

    mtsvane lobio (stewed broad beans) — butter :(
    pkhali (chopped, seasoned beet greens or spinach) — yogurt :(
    khatchapuri (cheese pie, comes in many regional variations)

    See also:

    * http://en.wikipedia.org/wiki/Georgian_cuisine

    * http://www.lonelyplanet.com/thorntree/thread.jspa?threadID=1562724

    * http://www.nukri.org/index.php?module=pnForum&func=viewtopic&topic=7749

    tenpo seli


    tenpo seli,
    lon li pona mute.
    kala li musi,
    kasi len li suli.

    mama sina li jo e mani mute
    mama sina li lukin pona kin
    a toki ala meli lili!
    o mu ala!

    tenpo lili la
    sina li lon li toki kalama musi.
    tenpo lili la
    sina li lon kon sama waso

    tenpo ni la
    pakala li ala lon
    mama tu pi sina li lon.

    convert 16 bit “half float” to 32 bit float


    See also:
    IEEE 754 single-precision binary floating-point format: binary32

    16-bit Floating-Point Rules

    float convert16to32float(unsigned int Xi_Value)
     //TODO:test, imporve, optimize..
      int exp = (Xi_Value>>10) & 0x01f;
      float g=0;
      unsigned int *i=(unsigned int *) & g;
      Xi_Value &= 0xffff;
      *i |= Xi_Value << 16 & 0x80000000; //sign
      *i |= (exp-15+127) << 23; //exponent 
      *i |= (Xi_Value & 0x3FF) << 13; //value
      return g;

    copy DB from MS SQL to MYSQL


    I’ve burned too much on this simple task, so I want to keep some gotchas it here.
    The task: copy DB from MS SQL to MYSQL.


    • MySQL migrate — I couldn’t make it work.
    •   http://www.convert-in.com/ — seem to be OK, but demo version is limited, so I’m not sure. Full version – $50.
    • bcp – command line tool; it was extremely difficult (yet possible) to export to a file that MySQL can eat.


    dbcDataAdapter l_SourceDA = new OdbcDataAdapter(l_QuerySource, m_strSource);
            OdbcDataAdapter l_TargetDA = new OdbcDataAdapter(l_QueryTarget, m_strTarget);
            OdbcCommandBuilder cmb = new OdbcCommandBuilder(l_TargetDA); //mandatory! Even if I don't use cmb, this line is crucial as in creates INSERT command
            string l_TableName = cmb.QuoteIdentifier(Xi_TableName, m_cTarget);
            DataSet l_SourceDS = new DataSet();
            DataSet l_TargetDS = new DataSet();
            int l_Rows = l_SourceDA.Fill(l_SourceDS, Xi_TableName);
            if (l_Rows <= 0)
              Log("Empty table");
            l_TargetDA.Fill(l_TargetDS, l_TableName);
            DataTable l_tblSource = l_SourceDS.Tables[Xi_TableName];
            DataTable l_tblTarget = l_TargetDS.Tables[l_TableName];
            int l_Errors = 0;
            // Loop through the top five rows, and write the first column to the screen.
            foreach (DataRow l_r in l_tblSource.Rows)
                l_tblTarget.Rows[l_tblTarget.Rows.Count - 1].SetAdded();
              catch (OdbcException ex)
            Log(string.Format("table {0}: {1} errors out of {2} records",
              Xi_TableName, l_Errors, l_Rows));
            DataSet l_Changed = l_TargetDS.GetChanges();

    This is OK; but I needed support for tables with dash (“-“).
    This was much harder; this thread was useful.
    So two changes that fix it:

       //create command
        OdbcCommand cmdInsert = cmb.GetInsertCommand();
            cmdInsert.CommandText = cmdInsert.CommandText.ToLower().Replace(Xi_TableName.ToLower(), "`" + Xi_TableName + "`");
    //MSSQL use "[" and "]"; there are prefix/postfix fields somehere in the data adapter
    //instead of just updating target data set:
     OdbcDataAdapter l_NewTargetDA = new OdbcDataAdapter(l_TargetDA.SelectCommand);
            l_NewTargetDA.TableMappings.Add("Table", l_TableName);
            l_NewTargetDA.InsertCommand = cmdInsert;

    Hopefully this will be useful for someone.