Saturday, November 24, 2012

How to: djvu and kindle

There are a lot of ways to perform DJVU to PDF converting. I have investigated a lot of them(online tools, pdf-printers and standalone tools) - and all of them were awful(bad speed, bad quality, shareware, etc.). But recently i've found a nice tool, which performs necessary converting better then others:

1. Go to djvu.sourceforge.net
2. Download binary package(in example my target platform is Windows)
3. Use ddjvu.exe tool, for convertation f.e.:
    C:\Program Files (x86)\DjVuZone\DjVuLibre>ddjvu -format=pdf book.djvu book.pdf

Sunday, July 29, 2012

Yoda Conditions

Yoda-conditions
Using if (constant == variable) instead of if (variable == constant), like if (4 == foo). Because it's like saying "if blue is the sky" or "if tall is the man".

Monday, July 16, 2012

IID_PPV_ARGS

Useful macro, instead this:
hr = CoCreateInstance(
    __uuidof(FileOpenDialog), NULL, CLSCTX_ALL,
    __uuidof(IFileDialogCustomize), reinterpret_cast<void**>(&pFileOpen));

we can write:
hr = CoCreateInstance(
    __uuidof(FileOpenDialog), NULL, CLSCTX_ALL,
    IID_PPV_ARGS(&pFileOpen));

Thursday, July 12, 2012

std::vector of pointers vs vector of elements/values

Some info about pointer vs value.

Vector of elements:

+Do not need to free/allocate memory for elements
+Keep it simple
+All elements memory allocated as one memory block - it increases cache hit and reduces memory fragmentation
+STL algorithms friendly
+Do not uses additional memory for pointer

Vector of pointers:
+Polymorphism
+If we don't know how much of memory we will need
+If we will need a lot of large objects
+Small pointers size useful for pointer to elements swaps