2014-05-13

Picture of Earth from Orbit in Cosmos S01E07

Nowadays the interwebz abounds with beautiful images of our Earth from orbit. Lately I have picked up the habit of trying to figure out what part of our world is visible when I see such an image. It is usually quite a puzzle, since the scale of the picture is not always obvious, parts of it are always obscured by clouds, the North can really be anywhere, and worst of all, countries are not painted with different colours! (Duh!) I am usually successful in this, but today I had a real tough one.

A couple of seconds into Cosmos: S01E07, there is a picture of Earth from orbit. Click on the picture below and see if you can identify the visible land before reading further down.



You might think that it is really obvious, but then try to verify your hypothesis by comparing the picture above against google earth, and whoops, you will see that you were wrong.

So, what's going on?

2014-05-12

"By using this site, you agree to the use of cookies."

If you live outside of Europe you might be lucky enough to have no idea what this is all about, but if you live in Europe you are probably sick and tired by now of this message popping up every time you first visit a site:
"This site uses cookies to help deliver services. By using this site, you agree to the use of cookies." [Learn more] [Got it]
The creators of these sites are not to blame for these messages; they are being forced to display them against their will, (and waste money and resources in doing so,) in order to comply with EU regulations. These messages are mandated by law.

I mean, really, how about this:
"This site uses the Helvetica font to help deliver services. By using this site, you agree to the use of Helvetica." [Learn more] [Got it]
Or this:
"This site uses TCP/IP to help deliver services. By using this site, you agree to the use of TCP/IP." [Learn more] [Got it]
All these statements make precisely the same amount of sense: none.

The legislators who came up with the one about cookies are a bunch of technically illiterate ignoramuses who, in a fashion typical of politicians full of shit, have the audacity to be legislating on things they have absolutely no clue about.  They should be removed from office and prohibited from ever holding any job other than milking goats.

2014-04-23

Stackoverflow.com question deleted within 2 minutes.

This question was sighted on stackoverflow.com on Thursday, April 30, 2013.  It was deleted within 2 minutes from being posted, but not before I managed to take a screenshot of the summary.

It is funny when you can tell what's wrong with the code by just looking at the summary!

2014-03-31

Fixing the AutoCloseable interface of Java

Java 7 introduced the AutoCloseable interface, which is roughly equivalent to the IDisposable interface of C#, to be used in synergy with the new try-with-resources statement, which is equivalent to the using-disposable construct of C#.

The problem with Java's AutoCloseable interface is that its close() method is declared to throw a checked exception: void close() throws Exception. This is a problem if you are one of the many programmers who prefer unchecked exceptions over checked ones, because it forces you to deal with checked exceptions every time you write a try-with-resources statement, despite the fact that none of your classes ever throw any checked exceptions on close().  Simply declaring that your class implements AutoCloseable forces checked exceptions upon you.

Luckily, there is a fix for this.  Here it is:
public interface AutoCloseable2 extends AutoCloseable
{
    @Override
    void close();
}
There, I fixed it for you.

By declaring a new interface which redefines the close() method as not throwing any checked exceptions, the problem goes away.


P.S.

I just looked at the Oracle documentation for the AutoCloseable interface and found out that this had already been anticipated:

"[...] subclasses of the AutoCloseable interface can override this behavior of the close method to throw specialized exceptions, such as IOException, or no exception at all."