Sunday, July 30, 2017

Bookmark Explorer coming for Firefox and Opera

I've decided the functionality of the Bookmark Explorer extension was pretty close to final and, before I refactor it to a new form, I wanted to make sure it works for all the browsers that support the WebExtensions mechanism, mainly Chrome, Firefox and Opera. Frankly, I have no idea why anyone would use Firefox or Opera, but if you do, I've got great news for you: I have published the extension for all of them:
Haven't tested extensively, I am going to do that in the near future, but rejoice, now you can read your news at speed and comfort, then remove them from your bookmarks once you have grown tired. There are some changes to the extension that need to be addressed:
  • The most significant is changing the keyboard shortcut for "Previous Bookmark" to Ctrl-Shift-O for Firefox and Opera, because changing extension key shortcuts in Firefox is really difficult and Ctrl-Shift-K is already used by the developer tools
  • The default settings have been updated. Now, when you install the extension for the first time you will get:
    • 30 second wait for the "Read Later" links to autoclose, giving the browser time to cache the title and icon
    • Preload next tab is now true by default, leading to loading the content of the next news item while you read the current one
    • When creating bookmarks - from anywhere - their URLs will be stripped of some marketing bullshit
  • A lot of bug fixes and speed improvements went into this aparrently minor release

I also plan to make a video of how to use the extension, since letting users read the long description and figure out what the extension does didn't quite work :) I am considering changing the name of the extension for version 3 and I am open to suggestions. I am thinking of Bookmark Surf or something like this. Please let me know of any problems with the extension. I will fix bugs and I will write new features if I agree they are good for my users. All you have to do is ask!

Enjoy!

Update: I was so happy that Firefox for Android supports addons that I just installed it immediately and expected it to work. Unfortunately, the support for the Web Extensions API is very limited for the Android version, most importantly not having a bookmarks API, so the Bookmark Explorer doesn't work. I did make the extension more robust, though, by debugging it on the Android version.

Wednesday, July 26, 2017

Salvation - what a terrible flop

Finally, finally there is a TV series about an asteroid coming towards Earth and what we are going to do about it. It is called Salvation and it fails in every single respect.

Yeah, her hair is moving on its own! The first alarm bell was Jennifer Finnigan, the female costar from Tyrant. She was terribly annoying in that show where she posed as the voice of reason and common sense, while being a nagging and demanding wife to the ruler of a foreign country. I thought "shame on you, Siderite! Just because she was like that in that show it's no reason to hold it against the actress". In Salvation, she plays the annoying nagging and demanding voice of reason and common sense as girlfriend to the secretary of the DOD.

But that's the least of the problems of the show. The idea is that a brilliant MIT student figures out there is an asteroid coming towards Earth. He tells his professor, who then calls someone and then promptly disappears, with goons watching his house. Desperate, he finds a way to reach to an Elon Musk wannabe and tell him the story. Backed by this powerful billionaire, he then contacts the government, which, surprise!, knew all about it and already had a plan. Which fails. Time to bring in the brilliant solution of the people who care: the EM drive! For which there is a need of exactly two billion dollars and one hundred kilograms of refined uranium. And that's just episode 2.

The only moment we actually see the asteroid is in a 3D holographic video projection, coming from most likely a text data file output of a tool an MIT student would build. Somehow that turns into a 3D rendering on the laptop of the billionaire. Not only does it crash into Earth, but it shows the devastation on the planet as a fire front. Really?

Bottom line: imagine something like Madam Secretary which somehow mated with the pilot episode of the X-Files reboot. Only low budget and boring as hell. There is no science, no real plot, no sympathetic characters, nothing but artificial drama which one would imagine to be pointless in a show about the end of the world, and ridiculously beautiful people acting with the skill of underwear models (Mark Wahlberg excluded, of course). Avoid it at all costs.

Update: oh, in episode 3, the last one I will watch, they send a probe to impact the asteroid and they do it like: "OK, we have a go from the president!" And in the next minute they watch (in real time from Io and from a front camera on the probe) how it is heading towards the asteroid. I mean... why write a story and not make it use anything real? What's the point in that? Even superhero movies are more realistic than this disaster. I know the creators of the show did other masterpieces such as Extant and Scream: The TV Series and Hawaii Five-O, they don't know any better, but at least they could have tried to improve just a tiny sliver. Instead they shat on our TV screens.

Monday, July 24, 2017

Update asteroids

I have updated my blog page with the Asteroids in the Solar system. There are only 892 at this date, rather than the 1500 I had before, but these are only the NEOs larger than 1 kilometer and the data is dynamically loaded rather than embedded in the page as it was before. Why didn't I use all of them? Because there are almost 500000 asteroids in the database and displaying them all would have been meaningless. Enjoy!

BTW, if you are wondering what the effects of an impact would be, play with this simulator.

Sunday, July 23, 2017

Dark Intelligence (Transformation #1), by Neal Asher

book cover I loved this book about the far future where humanity is ruled by benevolent AIs and vicious technological wars are being fought with xenophobic alien races. The greatest quality of Dark Intelligence is how it managed to define a world of varying degrees of power and intelligence that somehow manage to coexist without straining suspension of disbelief. I also liked that throughout the book there were hints on various hidden truths in the story, but Neal Asher didn't simply spoil the ending with them, nor did said ending rely solely on disclosing the twists that were glimpsed from those hints. The style of the writing was focused, easy to read, capturing the reader in the world the author created. I finished the book in just two days.

The subject of the story is also one that is very dear to my heart: what is the meaning of identity and personal purpose in life when anything can be changed, altered by either yourself or others, sometimes god like intelligences that just don't see galactic life as any more interesting than we would an ant hill. And while the book is part of a series set in a universe that Asher wrote a bunch of books about, the story is quite stand alone and can be read with pleasure without fear of a cliffhanger ending ruining it all. I liked it and probably I will try other books from the series and from this author.

Tea from an Empty Cup (Artificial Reality Division #1), by Pat Cadigan

book cover It was difficult for me to finish Tea From An Empty Cup. While it was a rather classic cyberpunk novel, which I usually enjoy, I felt it was obsolete in a way that could not be fixed. You know, like when designers or artists try to imagine how computers will be in the future. Only after reading it I realized it was written in 1998, so it was normal for that time and age to misunderstand how humans behave in networked environments, but still... even if the subject was a bit interesting, I actually had to make an effort to go through with it. I think the reason for why I didn't like the book was that the characters were paper thin. Concerned to describe a chaotic virtual reality world in which anything is possible and nothing is regulated (although everything is billed), Pat Cadigan forgot to make us feel anything for the protagonists. And considering that this is a story about how technology is affecting our perception of identity, it made the book unpalatable.

Imagine a Matrix in which people enter voluntarily because the real world is boring by comparison. They create their own intricate fantasies that go well beyond the basic human needs like food or sex and focus on social cues that the participants struggle to constantly redefine and grab for themselves. In this, Pat Cadigan was spot on. However, other than this simple idea that nowadays is ubiquitous on the Internet via the various social networks, the book is nothing but a boring detective story, complete with the "normal" policeman character that enters this virtual world as a complete noob and somehow solves the case. The action is very inconsistent and the feeling I got from the flow of the plot was one of a dream sequence where stuff is cool just by merely being defined as such. At no time while reading the book I was enticed by the scenes in the story.

The concepts inside the book are interesting, but explored very little. The author seems to be under the impression that by merely listing them, the story will somehow become interesting by association, an ironic parallel with the characters in the book. Just think that this book was published at the same time The Matrix movie was released. The difference in quality between the two stories is just too big.

Thursday, July 13, 2017

In Java, two Integer objects with the same value are not == to each other, most of the time

Today I've discovered, to my dismay, that two Integer objects with the same value compared with the == operator may return false, because they are different objects. So you need to use .equals (before you check for null, of course). I was about to write a scathing blog entry on how much Java sucks, but then I discovered this amazing link: Java gotchas: Immutable Objects / Wrapper Class Caching that explains that the Integer class creates a cache of 256 values so that everything between -128 and 127 is actual equal as an instance as well.

Yes, folks, you've heard that right. I didn't believe it, either, so I wrote a little demo code:
Integer i1 = Integer.valueOf(1);
Integer i2 = Integer.valueOf(1);
boolean b1 = i1 == i2; // true

i1 = Integer.valueOf(1000);
i2 = Integer.valueOf(1000);
boolean b2 = i1 == i2; // false

i1=1;
i2=1;
boolean b3 = i1 == i2; // true

i1=1000;
i2=1000;
boolean b4 = i1 == i2; // false

i1=126;
i2=126;
boolean b5 = i1 == i2; // true

i1++;
i2++;
boolean b6 = i1 == i2; // true

i1++;
i2++;
boolean b7 = i1 == i2; // false

i1 = 2000;
i2 = i1;
boolean b8 = i1 == i2; // true

i1++;
i1--;
boolean b9 = i1 == i2; // false


Update: the same thing also applies to Strings. Two strings with the same value are not == although they are immutable, so even the same string won't be equal to itself after changes. Fun!

I now submit to you that "sucks" applies to many things, but not to Java. A new term needs to be defined for it, so that it captures the horror above in a single word.

Wednesday, July 12, 2017

Microsoft SQL Server table partitioning

Tonight I went to an ADCES presentation about SQL table partitioning, a concept that allows for a lot of flexibility while preserving the same basic interface for a table one would use for a simpler and less scalable application. The talk was very professionally held by Bogdan Sahlean and you should have been there to see it :)

He talked about how one can create filegroups on which a table can be split into as many partitions as needed. He then demonstrated the concept of partition switching, which means swapping two tables without overhead, just via metadata, and, used in the context of partitions, the possibility to create a staging table, do stuff on it, then just swap it with a partition with no downtime. The SQL scripts used in the demo can be found on Sahlean's blog. This technology exists since SQL Server 2005, it's not something terribly new, and features with similar but limited functionality existed since SQL Server 2000. Basically the data in a table can be organized in separate buckets and one can even put each partition on a different drive for extra speed.

Things I've found interesting, in no particular order:
  • Best practice: create custom filegroups for databases and put objects in them, rather than in the primary (default) filegroup. Reason: each filegroup is restored separately,
    with the primary being the first and the one the database restore waits for to call a database as online. That means one can quickly restore the important data and see the db online, while the less accessed or less important data, like archive info, loaded afterwards.
  • Using constraints with CHECK on tables is useful in so many ways. For example, even since SQL Server 2000, one could create tables on different databases, even different servers, and if they are marked with not overlapping checks, one can not only create a view that combines all data with UNION ALL, but also insert into the view. The server will know which tables, databases and servers to connect to. Also, useful in the partition presentation.
  • CREATE INDEX with a DROP_EXISTING hint to quickly recreate or alter clustered indexes. With DROP_EXISTING, you save one complete cycle of dropping and recreating nonclustered indexes. Also, if specifying a different filegroup, you are effectively moving the data in a table from a filegroup to another.
  • Finally, the SWITCH TO partition switching can be used to quickly swap two tables, since from Sql Server 2005 all tables are considered partitioned, with regular ones just having one partition. So one creates a table identical in structure with another, does whatever with it, then just uses something like this: ALTER TABLE Orders SWITCH PARTITION 1 TO OrdersHistory PARTITION 1; to swap them out, with minimal overhang.

Monday, July 10, 2017

Memory Mapped Files in .NET 4.0

Just a heads up on a technology than I had no idea existed. To get the details read this 2009 (!!! :( ) article.

Basically you define a MemoryMappedFile instance from a path or a file reader, then create one or more MemoryMappedViewAccessors, then read or write binary data. The data can be structures, by using the generic Read/Write<[type]> methods.

Drawbacks: The size of the file has to be fixed, it cannot be increased or decreased. Also the path of the file needs to be on a local drive, it can't be on a network path.
Advantages: Fast access, built in persistency, the most efficient method to share data between processes.

Friday, July 07, 2017

NullPointerException in Java when using null values in a switch statement

Fuck Java! Just fuck it! I have been trying for half an hour to understand why a NullPointerException is returned in a Java code that I can't debug. It was a simple String object that was null inside a switch statement. According to this link states that The prohibition against using null as a switch label prevents one from writing code that can never be executed. If the switch expression is of a reference type, that is, String or a boxed primitive type or an enum type, then a run-time error will occur if the expression evaluates to null at run time.