April 26, 2008

Mail from the US usually gets here in 7 days. So when it still wasn’t there in 3 weeks, I really began to panic.

And just now I found a letter addressed to me, in a doorless mailbox next to mine, WITH THE ENVELOPE TORN OPEN!

Now, when it comes like that, our Postal service puts a stamp saying it arrived damaged. This one had no such stamp, which means it was “damaged” after it was delivered!

My faith in mankind has suffered a heavy blow :(

long long on Windows/Dev-C++/MinGW

April 22, 2008

[sarcasm on]
(because Moldova is probably the last country where programming competitions are still held on Windows)
[sarcasm off]

The long long data type has been introduced in C as part of the C99 standard. On 32-bit machines it is a 64-bit signed integer data type. The printf/scanf formatting string for this type is %lld.

Using Dev-C++ and the MinGW port of the GNU C Compiler on Windows, one would expect programs to run the same way they do with GCC on Linux. But no! Apparently MinGW calls the Windows libraries, so every time you call printf or scanf you’ll end up using Microsoft’s version of the functions!

And of course Microsoft cares about backwards compatibility, so when C99 was published they didn’t switch to the standard, keeping their non-standard %I64d formatting string instead!

[subsides into an angry stream of unintelligible muttering]


April 17, 2008

Whoever said that fairy tales only appeal to children was WRONG.

Lois Lowry -- Gossamer

Ultima Noapte De Dragoste, Întâia Noapte De Război

April 11, 2008

Romanul lui Camil Petrescu face parte dintr-o serie de opere româneşti pe care mi-am propus să le citesc pentru a-mi şterge o dată şi pentru totdeauna impresia că nu există cărţi româneşti care merită citite. (Totuşi a reuşit numai pe jumătate.) Read the rest of this entry »

How Linux Handles Summer Time

April 3, 2008

Daylight Saving Time is a controversial policy, but if you live in a region where it’s used, there’s not much you can do about it.

Linux adjusts the clock automatically, using zoneinfo. You can find out when these changes happened / are scheduled to happen using the zdump tool:

zdump -v Europe/Chisinau

The argument should be a path relative to /usr/share/zoneinfo/. A quick hint that you got it wrong is if you only get four entries (for the limits of time ;) ), 1901 and 2038 here, for instance.

P.S. If you have other operating systems on your machine, you should only allow one of them to change the time, otherwise you’ll get your clock shifted by more than one hour.

Python Trick: Subtracting Dates

April 3, 2008

I’m not the Python genius I want to be, so here’s this, for future reference:

How to subtract one date from another, and get the result in days:

from datetime import date
(date(2008, 3, 31) - date(2005, 2, 1)).days

A simple application:

party = date(2008, 6, 1)
(party -  date.today()).days