100th Anniversary of Landau’s Birth

Thanks to “Symmetry factor” blog for pointing this out.

Lev Davidovich Landau, a brilliant theoretical physicist and a founder of a whole school of thought in theoretical physics, was born exactly one hundred years ago, on 22 January 1908. His work was amazingly broad, from condensed matter physics to quantum field theory. He was awarded the Nobel Prize in 1962 for his work on superfluidity of liquid helium. He is one of the few people in the world whose student – Alexei A. Abrikosov – also got a Nobel Prize.

He is also, together with E. M. Lifshitz, author of a renowned 10 volume course in theoretical physics, covering incredibly wide range: Mechanics, The Classical Theory Of Fields, Non-Relativistic Theory of Quantum Mechanics, Quantum Electrodynamics, Statistical Physics (2 volumes), Fluid Mechanics, Theory Of Elasticity, Electrodynamics Of Continuous Media, and Physical Kinetics!

Though in todays standards bit harder to read (in my opinion), all 10 volumes are an incredible source of information, and always very handy as a reference handbook, or study book.

For some time now, I’m a proud owner of all 10 volumes, and since some time ago, also of the electronic versions of all 10 books. If anyone’s interested, I’d be happy to share these. Just let me know = leave a comment.

Last word – my favourite part of the mentioned course is when Landau says “as reader can easily verify himself”; I once tried it, took me some 5 pages of computations, but the result was right. 🙂

Prague and Belgrade Panoramas

Ever since I bought my first digital camera (in January 2005, haha), I always wanted to make my own panoramas. It was just a “stupid” M307 HP compact. So you can imagine – no manual settings, only presets available for white balance; the usual lot you get when you don’t know yet what all you need, and don’t wanna spend too much money on something you have no idea if you’ll ever need.

But then again, there’s always Photoshop to fix anything that went wrong, right?

So, even with photos that each has different exposure and white balance, you can still make panoramas that look at least decent.

Well, I’m writing all this self-praise to say something else – I was always planning on writing a small guide/tutorial on how to make panoramas in Photoshop, but I never knew if it wouldn’t be just a loss of time. So, if anyone’s interested, just let me know, and I can put something simple together as a page here.

Here are few of my creations

Continue reading

BZip2 – Gotta Love It :)

I’ve never been much of a friend of commercials and recommendations, but there simply are stuff that have to be recommended.

Like Woody Allen’s 1975 movie “Love and Death“. 😀

Or like BZip2.

It’s free, it’s even patent free, it’s great, it’s almost unused in Windows world… Why? I have really no idea. The compression ratio is typically twice as good as that of zip. The only “down-side” is, that it can store only 1 file per archive… But then again, there’s tar to take care of this, and e.g. total commander can handle both pretty well.

But that’s not what I wanted to talk about. Yes, I wanted to talk to all you geeks who love programming just as much as I do – about the bzip2 API. And what’s more – it also has a nice documentation! Wow, yes!

I used to use many different compression formats throughout my programming carrier – zip, rar, lzo, minilzo, arithmetic, freearc, … – but never I used library so simple to learn and use. Plus, again, that has such a good ratio at reasonable speed and memory requirements (of course, if you want the best, there’s always PAQ in flavour of your choice, but who can afford to wait 10 hours for 1 file to be compressed?).

But enough talking, more coding. As an example, here’s how to do file-to-file compression (leave out error handling and comments, and whole code is 18 lines long, including declarations, etc.):

bool PackFile(const char* file_name)
{
    // open the input file
    FILE* file = fopen(file_name, "rb");
    if (0 == file)
        return false;

    // open the output file
    std::string out_file_name = file_name;
    out_file_name += ".bz2";
    FILE* out_file = fopen(out_file_name.c_str(), "wb");
    if (0 == out_file)
    {
        fclose(file);
        return false;
    }

    int bz2error;
    BZFILE* out_bz2 = BZ2_bzWriteOpen(&bz2error, out_file, 9, 0, 0);
    if (BZ_OK != bz2error)
    {
        fclose(file);
        fclose(out_file);
        return false;
    }

    // load file data into buffer, and store them to bzip2-out stream
    char buffer[1024];
    uint loaded_len;
    while ((loaded_len = fread(buffer, 1, 1024, file)) > 0)
    {
        BZ2_bzWrite(&bz2error, out_bz2, buffer, loaded_len);
        if (BZ_OK != bz2error)
        {
            fclose(file);
            BZ2_bzWriteClose(&bz2error, out_bz2, 1, 0, 0);
            fclose(out_file);
            return false;
        }
    }

    // close in file
    fclose(file);

    // close out bzip2 stream and the file
    uint total_in, total_cmp;   // how many bytes we read, and resulting compressed size
    BZ2_bzWriteClose(&bz2error, out_bz2, 0, &total_in, &total_cmp);
    fclose(out_file);

    return true;
}

Sending e-mail using pure WinSock

I’ve spend quite a bit of time these days searching for a simple way to send email from C++.

There sure is a lot of stuff on this on the Net, but there was one trouble – the program I’m writting is an NT service. Thus, all those MAPI-based solutions didn’t work for me (there are simply too many small things you have to take care of, that disable simple installation of software).

So, I just looked up “SMTP” on Wikipedia, and believe it or not, it was enough. I just wrote the whole thing as a pure plain-text communication with SMTP server, at it worked at first shot, haha!

Continue reading