and has 2 comments
An unlikely blog post from me, about graphics; and not any kind of graphics, but GDI graphics. It involves something that may seem simple at first: rotating a text in a rectangle container so that it is readable when you turn the page to the left. It is useful to write text in containers that have a height that is bigger than the width. This is not about writing vertically, that's another issue entirely.
So, the bird's eye view of the problem: I had to create a PDF that contains some generated images, a sort of chart with many colored rectangles that contain text. The issue is that some of them are a lot higher than they are wide, which means it is better to write text that is rotated, in this case to -90 degrees, or 270 degrees, if you like it more. To the left, as Beyoncé would put it.

I created the image, using the Bitmap class, then got a Graphics instance from it, then starting drawing things up. It's trivial to draw a line, fill a rectangle, or draw an arc. Just as easy it is to write some text, using the DrawString method of the Graphics object. I half expected there to be a parameter that would allow me to write rotated, but there wasn't. How hard could it be?

Let's start with the basics. You want to draw a colored rectangle and write some text into it. This is achieved by:
var rectangle=new Rectangle(x,y,width,height); // reuse the dimensions
g.FillRectangle(new SolidBrush(Color.Blue),rectangle); // fill the rectangle with the blue color
g.DrawRectangle(new Pen(Color.Black),rectangle); // draw a black border
g.DrawString("This is my text",new Font("Verdana",12,GraphicsUnit.Pixel),new SolidBrush(Color.Black),rectangle, new StringFormat {
LineAlignment=StringAlignment.Center,
Alignment=StringAlignment.Center,
Trimming = StringTrimming.None
}); // this draws a string in the middle of the rectangle, wrapping it up as needed

All very neat. However, you might already notice some problems. One of them is that there is no way to "overflow" the container. If you worked with HTML you know what I mean. If you use the method that uses a rectangle as a parameter, then the resulting text will NOT go over the edges of that rectangle. This is usually a good thing, but not all the time. Another issue that might have jumped in your eyes is that there is no way to control the way the text is wrapped. In fact, it will wrap the text in the middle of words or clip the text in order to keep the text inside the container. If you don't use the container function, there is no wrapping around. In other words, if you want custom wrapping you're going to have to go another way.
Enter TextRenderer, a class that is part of the Windows.Forms library. If you decide that linking to that library is acceptable, even if you are using this in a web or console application, you will see that the parameters given to the TextRenderer.DrawText method contain information about wrapping. I did that in my web application and indeed it worked. However, besides drawing the text really thick and ugly, you will see that it completely ignores text rotation, even if it has a specific option to not ignore translation tranforms (PreserveGraphicsTranslateTransform).

But let's not get into that at this moment. Let's assume we like the DrawString wrapping of text or we don't need it. What do we need to do in order to write at a 270 degrees angle? Basically you need to use two transformations, one translates and one rotates. I know it sounds like a bad cop joke, but it's not that complicated. The difficulty comes in understanding what to rotate and how.
Let's try the naive implementation, what everyone probably tried before going to almighty Google to find how it's really done:
// assume we already defined the rectangle and drew it
g.RotateTransform(-270);
g.DrawString("This is my text",new Font("Verdana",12,GraphicsUnit.Pixel),new SolidBrush(Color.Black),rectangle, new StringFormat {
LineAlignment=StringAlignment.Center,
Alignment=StringAlignment.Center,
Trimming = StringTrimming.None
}); // and cross fingers
g.ResetTranformation();
Of course it doesn't work. For once, the rotation transformation applies to the Graphics object and, in theory, the primitive drawing the text doesn't know what to rotate. Besides, how do you rotate it? On a corner, on the center, the center of the text or the container?
The trick with the rotation transformation is that it rotates on the origin, always. Therefore we need the translate transformation to help us out. Here is where it gets tricky.

g.TranslateTransform(rectangle.X+rectangle.Width/2,rectangle.Y+rectangle.Height/2); // we define the center of rotation in the center of the container rectangle
g.RotateTransform(-270); // this doesn't change
var newRectangle=new Rectangle(-rectangle.Height/2,-rectangle.Width/2,rectangle.Height,rectangle.Width); // notice that width is switched with height
g.DrawString("This is my text",new Font("Verdana",12,GraphicsUnit.Pixel),new SolidBrush(Color.Black),newRectangle, new StringFormat {
LineAlignment=StringAlignment.Center,
Alignment=StringAlignment.Center,
Trimming = StringTrimming.None
});
g.ResetTranformation();
So what's the deal? First of all we changed the origin of the entire graphics object and that means we have to draw anything relative to it. So if we would not have rotated the text, the new rectangle would have had the same width and height, but the origin in 0,0.
But we want to rotate it, and therefore we need to think of the original bounding rectangle relative to the new origin and rotated 270 degrees. That's what newRectangle is, a rotated original rectangle in which to limit the drawn string.

So this works, but how do you determine if the text needs to be rotated and its size?
Here we have to use MeasureString, but it's not easy. It basically does the same thing as DrawString, only it returns a size rather than drawing things. This means you cannot measure the actual text size, you will always get either the size of the text or the size of the container rectangle, if the text is bigger. I created a method that attempts to get the maximum font size for normal text and rotated text and then returns it. I do that by using a slightly larger bounding rectangle and then going a size down when I find the result. But it wasn't nice.

We have a real problem in the way Graphics wraps the text. A simple, but incomplete solution is to use TextRenderer to measure and Graphics.DrawString to draw. But it's not exactly what we need. The complete solution would determine its own wrapping, work with multiple strings and draw (and rotate) them individually. One interesting question is what happens if we try to draw a string containing new lines. And the answer is that it does render text line by line. We can use this to create our own wrapping and not work with individual strings.

So here is the final solution, a helper class that adds a new DrawString method to Graphics that takes the string, the font name, the text color and the bounding rectangle and writes the text as large as possible, with the orientation most befitting.

using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;

namespace GraphicsTextRotation
{
public static class GraphicsExtensions
{
public static void DrawString(this Graphics g, string text, string fontName, Rectangle rect, Color textColor, int minTextSize=1)
{
var textInfo = getTextInfo(g, text, fontName, rect.Width, rect.Height); // get the largest possible font size and the necessary rotation and text wrapping
if (textInfo.Size < minTextSize) return;
g.TranslateTransform(rect.X + rect.Width / 2, rect.Y + rect.Height / 2); // translate for any rotation
Rectangle newRect;
if (textInfo.Rotation != 0) // a bit hackish, because we know the rotation is either 0 or -90
{
g.RotateTransform(textInfo.Rotation);
newRect = new Rectangle(-rect.Height / 2, -rect.Width / 2, rect.Height, rect.Width); //switch height with width
}
else
{
newRect = new Rectangle(-rect.Width / 2, -rect.Height / 2, rect.Width, rect.Height);
}
g.DrawString(textInfo.Text, new Font(fontName, textInfo.Size, GraphicsUnit.Pixel), new SolidBrush(textColor), newRect, new StringFormat
{
Alignment = StringAlignment.Center,
LineAlignment = StringAlignment.Center,
Trimming = StringTrimming.None
});
g.ResetTransform();
}

private static TextInfo getTextInfo(Graphics g, string text, string fontName, int width, int height)
{
var arr = getStringWraps(text); // get all the symmetrical ways to split this string
var result = new TextInfo();
foreach (string s in arr) //for each of them find the largest size that fits in the provided dimensions
{
var nsize = 0;
Font font;
SizeF size;
do
{
nsize++;
font = new Font(fontName, nsize, GraphicsUnit.Pixel);
size = g.MeasureString(s, font);
} while (size.Width <= width && size.Height <= height);
nsize--;
var rsize = 0;
do
{
rsize++;
font = new Font(fontName, rsize, GraphicsUnit.Pixel);
size = g.MeasureString(text, font);
} while (size.Width <= height && size.Height <= width);
rsize--;
if (nsize > result.Size)
{
result.Size = nsize;
result.Rotation = 0;
result.Text = s;
}
if (rsize > result.Size)
{
result.Size = rsize;
result.Rotation = -90;
result.Text = s;
}
}
return result;
}

private static List<string> getStringWraps(string text)
{
var result = new List<string>();
result.Add(text); // add the original text
var indexes = new List<int>();
var match = Regex.Match(text, @"\b"); // find all word breaks
while (match.Success)
{
indexes.Add(match.Index);
match = match.NextMatch();
}
for (var i = 1; i < indexes.Count; i++)
{
var pos = 0;
string segment;
var list = new List<string>();
for (var n = 1; n <= i; n++) // for all possible splits 1 to indexes.Count+1
{
var limit = text.Length / (i + 1) * n;
var index = closest(indexes, limit); // find the most symmetrical split
segment = index <= pos
? ""
: text.Substring(pos, index - pos);
if (!string.IsNullOrWhiteSpace(segment))
{
list.Add(segment);
}
pos = index;
}
segment = text.Substring(pos);
if (!string.IsNullOrWhiteSpace(segment))
{
list.Add(segment);
}
result.Add(string.Join("\r\n", list)); // add the split by new lines to the list of possibilities
}
return result;
}

private static int closest(List<int> indexes, int limit)
{
return indexes.OrderBy(i => Math.Abs(limit - i)).First();
}

private class TextInfo
{
public int Rotation { get; set; }
public float Size { get; set; }
public string Text { get; set; }
}
}
}

I hope you like it.

I had this database table containing ranges (a start value and an end value). The challenge was creating a query that overlaps and transposes those ranges so I can say how many ranges are at any point in the total interval or values. As an example, "SELECT * FROM Ranges" would result in a table like:
StartEnd
1020
1030
2535
2040
and I am looking for something like this:
ValueCount
00
10
......
102
112
......
242
253
263

A naive implementation would get the minimum Start (or start with 0, as I did) and the maximum End, create an in memory or temporary table (Values) from min to max using an ugly WHILE block, then join it with the Ranges tables something like:
SELECT v.Val,Count(1) as Nr
FROM #Values v
INNER JOIN Ranges r
ON r.Start<=v AND r.[End]>=v

This kind of works, but for large ranges it becomes difficult. It takes a lot to create the Values table and the join and for extreme cases, like I had with values from 0 to 6 billion, it becomes impossible. The bottleneck here is this Values table, which is pretty much a horror to create and maintain. But what if you don't need all the values?

Before I tell you the solution I found, be warned that you have to properly define what a range is. Is a range 10-20 actually 10-19? In my case it was so, so that is why there are some subtractions with 1 or less than rather than less or equal conditions.

The solution is this:
SELECT DISTINCT Val
INTO #Values
FROM (
SELECT 0 as Val
UNION ALL
SELECT Start FROM Ranges
UNION ALL
SELECT [End]-1 FROM Ranges
) x
ORDER BY Val

The idea is that after you compute the ranges count per each of the start and end values you know that between one and the next the count of ranges will remain the same. The join is significantly faster, there is no ugly WHILE block and you don't need a 6 billion value table. It's easier to plot on a chart as well, with either of these variations:
See the variations:
SELECT v.Val,
Count(r.Start) as Nr
FROM #Values v
LEFT JOIN Ranges r
ON r.Start<=v.Val AND r.[End]>v.Val
GROUP BY v.Val

The result of the query above will be:
ValueNr
00
102
192
202
253
293
342
391
Hope this helps you

and has 0 comments
I will go forth immediately and say that this book is hard to read. It's not just that it uses English names of fruits and plants not often met in normal conversation or movies, it's not only that it uses the English measurements units that most Europeans have no understanding of and it's not even the author's apparent obsession with Angostura bitters :). It's because the book is filled with information and it is better suited to be used as a reference than a one-off read. It is obvious that in The Drunken Botanist the author, Amy Stewart, put a great deal of research; such an amount, in fact, that it would be impossible to be able to absorb all of it in one read. You realize that a book is great when you see affecting you in your every day life. No, I did not get drunk every day on strange cocktails, even if the temptation certainly existed, but I found myself looking at plants everywhere and wondering how they would taste in a drink. "Is that fruit edible? Probably not, it's red and the fruit of a decorative tree, so probably it is poisonous. But surely there is a way to destroy the poison and enjoy the taste in an alcoholic drink." That sort of thing.

And what I find even nicer is that the author is ready to continue the conversation started in the book on a special website called DrunkenBotanist.com

The book is split into very little chapters, each on a certain plant, a little bit of history - the degree of details varying wildly, but described with great humor and passion, the way they are used in drinks, cocktail recipes, some botanical or chemical info - although not too much. There are organized by themes, like leaves or fruits, grasses or trees, and so on, but essentially it's an enumeration of plants and their uses. This is something I didn't like that much. My issue is that I expected to see more botanical information, like how plants are related and how the drinks made from them are related. As such, you only get a few words at the beginning of a chapter about the plant's family, but no connection is made. Of course, no one stops you for researching and doing it yourself.
Another thing that bothered me a little was the images. I agree that full color and size images of the plants described would have printed as a huge book, but the e-book version I read had no such limitations. Instead of seeing a simplistic representation of some plants, I would have liked to see the plant itself. That would have helped me understand what each plant was in my language, as well.

I have to conclude that the book is a very interesting one, albeit difficult to finish reading. I understand the need to earn money and thus sell it as a book, but for me it seems that the book's format would have been a lot more appropriate for a web site and that some features should have been different in the electronic version than the printed one. Instead, the Drunken Botanist site is actually a blog, in a blog format, which is unusable as a reference, really. I recommend browsing the book and certainly have it available. Some information in it is great at parties and the botanical insight into the common drinks and their ingredients is fascinating. But think of it as something to have ready for when you need to know what you are mixing. I would say it's a mandatory read for any bartender, though.

and has 3 comments
It's the middle of autumn again and more and more series are making their entry into the list. But there are a lot of shows that I carry around from post to post without actually watching them. I've decided to remove them from the list until that time comes.



Let's start with the already described ones:

  • Doctor Who - Math Smith has left the show and the new doctor is an actor which I really like, Peter Capaldi, who you might remember from The Thick of It. Unfortunately, he will be very polite in Doctor Who; I would have loved to see him as irreverent, sweary and Scottish as in his other role.
  • Dexter - season 8 of the series has just ended (disastrously) and thus the show. It was a good run, I guess, even if the last seasons were quite ridiculous.
  • True Blood - I am becoming conflicted about this show. On one hand some of the storylines are very interesting, while on the other the multitude of stories, one more over the top than the other, shown in parallel in every episode, make it all feel like one supernatural soap opera. The ending of the season, with the invasion of the zombie vampires, also left me deflated.
  • The Good Wife - the fifth season just started, but I haven't got around to it. I think the show continues to be good, but they probably should wrap it up and do something else before it too dissolves into pointlessness.
  • Haven - the fourth season has just started. I will probably watch it with the wife, she seems to enjoy it.
  • Falling Skies - the third season was just weird. It's difficult enough to justify an almost medieval human resistance while being caught in an interstellar war even without having incompetent writers, which unfortunately the show has.
  • Southpark - Southpark is still running hot at season 17. The Butters episode in which he becomes a DMV witness was delicious.
  • Suits - Suits started fun, I really enjoyed it; for stupid reasons, but I did. The third season showed me that even those reasons are quickly fading. Everybody acts over the top and with almost no connection to real life. It's like a movie made by advertisers.
  • Breaking Bad - I started watching the first episode from season 5 only to realize I don't understand what the hell is going on. Did I even watch the fourth season? Unclear.
  • Homeland - season three starts with Carrie being thrown to the wolves as she goes more and more insane. Having a similar situation in the family doesn't make it easy to watch.
  • The Walking Dead - the fourth season just started, but I didn't get around to it, yet.
  • Game of Thrones - there was a lot of outrage on the Internet linked to the Red Wedding episode. It's the first true test of the show. If people will continue watching it even after blatantly killing some of their favourite characters, then the show will go on until Martin stops writing (or maybe not even then). I am afraid it might not happen that way, though.
  • Mad Men - does anyone remember this started as a movie about advertising people? Right now it seems to be more about the "mad" part of the title, as Don devolves more and more into a crazy person.
  • Continuum - Continuum continues, even if it got kind of weird in the last season. Everybody is related to everybody and makes deals with all. It's becoming an intertemporal high-school drama.
  • Copper - Copper started as in interesting show about Irish policeman in Five Points, but after the second season it got cancelled. The last season was pretty confusing and less and less having to do with the job and more with the personal. I did not like that.
  • Longmire - who killed the killer of madam Longmire? Was it sir Longmire? No. Was it Lou Diamond Philips? No again. Was it the killer hired by Lou Diamond? No, because he wasn't a killer. Does that mean people will stop worrying about it? Definitely not. I really want Longmire to retain that authentic countryside sheriff feel; the screenwriters seem to feel otherwise.
  • The Newsroom - drama, politics, revenge, more drama and finally, some drama. All over the top and on high speed. No wonder the city never sleeps if everybody is overactive.
  • Arrow - new Arrow season, with tales of bringing more superheroes into the story, like The Flash. Will this become the testbed for Playstation and XBox game scripts?
  • Elementary - the second season started with some interesting episodes. One even features Lestrade, as a celebrity addict. Funny, that.
  • House of Cards - this show is the first to be launched on Netflix (and produced by them as well). This means the entire first season was launched on the same day. No more waiting week after week to see a bit of the show, but how much time will it pass now until the next season? It's almost like releasing 10 hour movies.
  • Father Ted - I watched almost all episodes of this very old and obscure show, basically just because it was old and obscure. It's a laughing-track comedy about two idiotic priests on a small remote island in Ireland. Supposedly ireverent to religion, it's just a very silly show.

New shows:

  • The Tomorrow People (2013) - this remake of a really dumb old series just started. I haven't started watching it, but I've read a review that seemed to praise it. It stars beautiful young actors with superpowers, though.
  • The Legend of Korra - the second season has started with a transparent nefarious plot that only the dumb female avatar doesn't seem to get. Her character is so annoying!! Ugh!
  • Atlantis - I expected Atlantis to be a sort of Rome or Spartacus. The bronze-punk science fiction would have made a great show. Unfortunately it seems to be more a kind of a Hercules/Xena kind of show. There is this modern guy who gets into Atlantis through a portal, meets Pithagoras and Hercules, who are both different from the myths, and runs around with swords.
  • By Any Means - I could barely survive through the first episode. This is a British show about a group of people that are hired by the police to bring people to justice. Why doesn't the police do that directly? Because this group uses illegal and imoral acts to achieve their goals, then rationalize them by them being "the good guys" and acting all cool and funny. The show was basically offensive to me.
  • Hostages - a show about a doctor who must opperate on the United States president. Her family is taken hostage to force her to kill the president. Yeah, like that could happen. It has good actors and an intriguing plot, but it could go both ways. I've watched just the first episode.
  • Ironside - another show about a cop. This time the cop is black and in a wheelchair, even if he continues to strong arm suspects and his team with impunity. I found it pretentious and yet another show which is trying to force feed us vigilante justice from charismatic characters.
  • King and Maxwell - a show about a detective agency run by former Secret Service agents. At last a detective agency not run by complete amateurs that got bored. Rebecca Romjin is one of the pair, which makes the show nice to look at, at least. Now, the first episodes felt a bit silly, like a comedy, so I didn't continue watching it, but it could become better.
  • Low Winter Sun - TV series starring two less known, but nevertheless good actors: Lennie James and Mark Strong. It's very dark, with corrupt policemen and rampant gangs, but I can't say I enjoyed it much. Probably because it seems to miss a point.
  • Ray Donovan - something that stars Liev Schreiber and John Voight should be better than this, but the show is not bad. There is this guy that acts like a sort of damage control expert who has to contend with his father getting out of jail and being a dick. Control that damage, if you can!
  • Rewind - it is the season of shows about people playing God. This time they are not policemen, thank you, but an agency that uses technology to go back in time and "fix" things. All seemed straightforward until the end of the first episode, which promises a longer story arch and maybe even more interesting action.
  • Serangoon Road - another Australian show about private detectives, this time placed in Malaysia. Chinese, Australians, Javanese, British and Americans are all dancing around each other, trying to win the jackpot in this country torn by civil unrest and government dissolution. An interesting show, which I continue to watch.
  • Siberia - I almost want to ask "What is Siberia?" in a Matrixy sort of way. It is a series that starts as a reality show, only to have the contestants meet strange phenomena until the entire premise explodes and they find themselves stuck in Siberia, with no contact to the outside world and in mortal (supranatural/scifi) danger. The problem with the show is that it is pretty inconsistent and difficult to watch. It's like it doesn't know what it wants to be: a reality show, a Lost rip-off or something else.
  • Sleepy Hollow - Sleepy Hollow the movie was a masterpiece, combining a moody atmosphere that hinted of the supernatural with a main character that used logic and science to prove that it actually wasn't. The Sleepy Hollow series is the complete opposite, with a clear supernatural storyline involving good and bad witches, demons and Ichabod Crane, a civil war soldier who has found himself in the present and now helps (of course) the police deal with the rise of evil. It could have been good, but I really don't like any of the actors or characters, except maybe the sheriff, but he dies.
  • The Blacklist - I really wanted to like the series, because it stars James Spader (an old and bald one), an actor which I really liked in the past. But it's a confused mess. Spader plays the role of a rogue FBI agent that surrenders after 20 years only to help the FBI find catch the "truly bad" guys. He enlists the help of a girl FBI agent who probably is his daughter, even if he doesn't say it out loud. She is basically a clone of the FBI agent from Haven, while Spader's character is an arrogant prick. Impossible to empathise with anyone and even harder to see a point of this show.
  • The Bridge - an American remake of the Danish/Swedish series Bron, it involves a murderer that leaves a body on the exact border of Mexico and the US, forcing the creation of a joint taskforce. Beautiful Diane Kruger plays the functional autist American agent, while Demián Bichir plays the complex Mexican policeman. There are other characters, but some are even detrimental to the story, in my view. The show is solid and has some interesting and good acting. I hope it stays that way.
  • The Crazy Ones - just so you don't say I don't watch any comedy shows, this stars Robin Williams as a crazy and inspirational ad man, helped by two equally crazy guys and his daughter, played by Sarah Michelle Gellar. It has its moments, but it isn't really my style. Why can't they make comedy that also seems real, rather than completely over the top?
  • The Originals - oh, what a bunch of pretentious crap! a (too) late comer in the vampire TV show business, it even tries to reuse the vampire aristocrat variation. The only modern take of this soap opera like show is that it also adds witches to the mix. This is they year of the witches, after we got tired of vampires and werewolves and zombies didn't quite catch on.
  • The Psychopath Next Door - not an easy show to watch, it's full of psychological violence. It features a young very attractive female psychopath and how she deals with the world. Being a British show she really acts like a sociopath, shows no remorse and does the most atrocious acts just to get ridiculously unimportant things, rather than help the police catch bad guys or whatever :) A really good beginning and a fascinating glimpse in the mind of a true psycho.
  • Under The Dome - when in doubt, use a Stephen King story. Alas, I usually don't like King's writing it tends to drag on. Making a TV series out of one makes a rather boring watch. This is a sci-fi show about a transparent and impenetrable dome that completely isolates a small community from the outside world. The situation quickly devolves because of the people there, as primate tribes are wont to do when consequences disappear.
  • What Remains - British show, I just started to watch the first episode. It seems to revolve around human remains, discovered a long while after the crime (if it was one) and how people lives are affected by the investigation. Could be good.
  • Witches of East End - told you this is the season of the witch. This show is about a family of witches, incredibly good looking ones. The mother is Julia Ormond, her sister is Madchen Amick and one of the daughters is this hot and curvy brunette. Of course good looking guys and evil witches appear soon after. It seems a typical teen show, with drama coming exclusively from social situations, people who are romantic interests or/and are trying to kill you.
  • The Last Witch - The show just appeared and I haven't had the chance to watch it, but it's about witches, which validates my view that witches are the new vampires. At least this show is British.
  • Blackout - a faux documentary British series about a fictional British power blackout that lasted for more than a week. Kind of hard to watch because it's made like a montage of different camera shots taken by different people on handhelds and phones.

Well, it seems that removing the shows that I am not actively watching makes this list more manageable, but it also means you will have to look at more "TV Series I've been watching" blog posts to get an overview.

and has 0 comments

It's difficult to remember that in the original Dishonored storyline there were two people carrying the mark of the Outsider. There was Corvo, but then there was Daud. The Knife of Dunwall and Brigmore Witches extended missions of the game both come as Dishonored downloadable content and both star Daud as the lead. He first has to fight an army of whale butchers then the overseers who come to destroy his army of assassins, then he goes to find the Brigmore Witches and foil their plans. It was a nice touch that they changed characters. Someone who either killed everything that moved or took great care to finish up Dishonored the non-lethal way would probably have issues with changing their game style in the continuation. Having a different character frees our conscience and lets us play this game as we wish at that moment. It also hints that the story is not in the characters, but in the island universe created in the game.

The story here is that the Outsider tips Daud, who is already conflicted about his choice to murder the empress and kidnap her daughter, about a mysterious woman called Delilah. It soon becomes evident that she is aware of Daud's interests when she seeks the Overseers on Daud's hidden base. She apparently is the leader of a coven of witches based in Brigmore Manor. Rumors about them appeared in the main Corvo story, as well. Delilah, originally a servant in Dunwall Tower and a talented painter, is attempting to take over Emily Kaldwin, the young daughter of the empress, and by defeating her you become a hero that, just as Corvo but unbeknownst to anyone but the Outsider, saves Emily. That was a nice twist, also, binding the two stories together. Events in Daud's story also parallel Corvo's, as NPCs talking to each other often reveal.

It is interesting that, besides Blink and Dark Vision which seem to be essential to playing the game, Daud has different magical powers as well as different weaponry. That annoying power that he used to overpower Corvo at the beginning of the main story is available to you and very handy. As with Dishonored, you can choose your level of mayhem which in turn, I suppose, changes the story. I tried to play it as non-lethal as I could, but having the reputation of a renowned assassin for hire really made me itch for bloodthirsty apocalypse. It felt great to know that I can kill everybody, even when I chose not to, I guess.

An intriguing idea came to me. Besides Corvo and Daud there were other people involved with Outsider powers: Delilah and Granny Rags. If they make more downloadable content for the game (which I really really hope they will) it could be interesting to play Delilah, or even Granny, as prequels to these stories. It would serve multiple purposes, as it would probably appeal to female players more, as well as changing the weaponry and magic almost entirely. Witches in this game use magic arrows and use dead animals and plants to do their bidding, while Granny Rags uses hordes of rats and an amulet that makes her immortal until you destroy it. There are neat tricks that would be a waste not to be used by the player. Both Corvo and Daud actually survive in the end and don't forget that the Dishonored universe is placed in an archipelago of islands, only one of them having been explored in any detail, with a lot of rumors and information about the others and a lot more opportunities. A story on the whaling ships, perhaps? Something in a wide open space, as demonstrated by the Brigmore Witches manor grounds, maybe? Dishonored may have started like something that seemed to clone Assassin's Creed, but it has a lot more potential. Knowing the guys at Arkane Studios, that potential is going to be used, even if the wiki on The Brigmore Witches says it is the last DLC for Dishonored. Perhaps Dishonored II will be made soon.

As a conclusion, I really enjoyed the game, even if Daud's voice was Michael Madsen's, who I usually dislike at first glance. It's good he wasn't visually in the game, then :)


[youtube:Rp6hY003tKs]

Being a beginner in both OpenLayers and AngularJS it took me a long while to do this simple thing: add stuff on a map and make it show as I wanted. There were multiple gotchas and I intend to chronicle each and every one of those bastards.
First, while creating a map and doing all kinds of stuff with it using OpenLayers is a breeze, doing it "right" with AngularJS is not as simple. I thought I would not reinvent the wheel and looked for some integration of the two technologies and I found AzimuthJS. In order to add a map with Azimuth all you have to do is:
<div ol-map controls="zoom,navigation,layerSwitcher,attribution,mousePosition" control-opts="{navigation:{handleRightClicks:true}}">
<az-layer name="Street" lyr-type="tiles"></az-layer>
<az-layer name="Airports" lyr-type="geojson" lyr-url="examples/data/airports.json" projection="EPSG:4326"></az-layer>
</div>
You may notice that it has a simple syntax, it offers the possibility of multiple layers and one of them is even loading features dynamically from a URL. Perfect so far.
First problem: the API that I am using is not in the GeoJSON format that Azimuth know how to handle and I cannot or will not change the API. I've tried a lot of weird crap, including adding a callback on the loadend layer event for a GeoJson layer in order to reparse the data and configure what I wanted. It all worked, but it was incredibly ugly. I've managed to add the entire logic in a Javascript file and do it all in that event. It wasn't any different from doing it from scratch in Javascript without any Angular syntax, though. So what I did was to create my own OpenLayers.Format. It wasn't so complicated, basically I inherited from OpenLayers.Format.JSON and added my own read logic. Here is the result:
OpenLayers.Format.RSI = OpenLayers.Class(OpenLayers.Format.JSON, {

read: function(json, type, filter) {
type = (type) ? type : "FeatureCollection";
var results = null;
var obj = null;
if (typeof json == "string") {
obj = OpenLayers.Format.JSON.prototype.read.apply(this,
[json, filter]);
} else {
obj = json;
}
if(!obj) {
OpenLayers.Console.error("Bad JSON: " + json);
}

var features=[];
for (var i=0; i<obj.length; i++) {
var item=obj[i];
var point=new OpenLayers.Geometry.Point(item.Lon,item.Lat).transform('EPSG:4326', 'EPSG:3857');
if (!isNaN(point.x)&&!isNaN(point.y)) {
var feature=new OpenLayers.Feature.Vector(point,item);
features.push(feature);
}
}

return features;
},


CLASS_NAME: "OpenLayers.Format.RSI"

});
All I had to do is load this in the page. But now the problem was that Azimuth only knows some types of layers based on a switch block. I've not refactored the code to be plug and play, instead I shamelessly changed it to try to use the GeoJson code with the format I provide as the lyr-type, if it exists in the OpenLayers.Format object. That settled that. By running the code so far I see the streets layer and on top of it a lot of yellow circles for each of my items.
Next problem: too many items. The map was very slow because I was adding over 30000 items on the map. I was in need of clustering. I wasted almost an entire day trying to figure out what it wouldn't work until I realised that it was an ordering issue. Duh! But still, in this new framework that I was working on I didn't want to add configuration in a Javascript event, I wanted to be able to configure as much as possible via AngularJS parameters. I noticed that Azimuth already had support for strategy parameters. Unfortunately it only supported an actual strategy instance as the parameter rather than a string. I had, again, to change the Azimuth code to first search for the name of the strategy parameters in OpenLayers.Strategy and if not found to $parse the string. Yet it didn't work as expected. The clustering was not engaging. Wasting another half an hour I realised that, at least in the case of this weirdly buggy Cluster strategy, I not only needed it, but also a Fixed strategy. I've changed the code to add the strategy instead of replacing it and suddenly clustering was working fine. I still have to make it configurable, but that is a detail I don't need to go into right now. Anyway, remember that the loadend event was not fired when only the Cluster strategy was in the strategies array of the layer; I think you need the Fixed strategy to load data from somewhere.
Next thing I wanted to do was to center the map on the features existent on the map. The map also needed to be resized to the actual page size. I added a custom directive to expand a div's height down to an element which I styled to be always on the bottom of the page. The problem now was that the map was getting instantiated before the div was resized. This means that maybe I had to start with a big default height of the div. Actually that caused a lot of problems since the map remained as big as first defined and centering the map was not working as expected. What was needed was a simple map.updateSize(); called after the div was resized. In order to then center and zoom the map on the existent features I used this code:
        var bounds={
minLon:1000000000,
minLat:1000000000,
maxLon:-1000000000,
maxLat:-1000000000
};

for (var i=0; i<layer.features.length; i++) {
var feature=layer.features[i];
var point=feature.geometry;
if (!isNaN(point.x)&&!isNaN(point.y)) {
bounds.minLon=Math.min(bounds.minLon,point.x);
bounds.maxLon=Math.max(bounds.maxLon,point.x);
bounds.minLat=Math.min(bounds.minLat,point.y);
bounds.maxLat=Math.max(bounds.maxLat,point.y);
}
}
map.updateSize();
var extent=new OpenLayers.Bounds(bounds.minLon,bounds.minLat,bounds.maxLon,bounds.maxLat);
map.zoomToExtent(extent,true);

Now, while the clustering was working OK, I wanted to show stuff and make those clusters do things for me. I needed to style the clusters. This is done via:
        layer.styleMap=new OpenLayers.StyleMap({
"default": defaultStyle,
"select": selectStyle
});

layer.events.on({
"featureselected": clickFeature
});

var map=layer.map;

var hover = new OpenLayers.Control.SelectFeature(
layer, {hover: true, highlightOnly: true}
);
map.addControl(hover);
hover.events.on({"featurehighlighted": displayFeature});
hover.events.on({"featureunhighlighted": hideFeature});
hover.activate();

var click = new OpenLayers.Control.SelectFeature(
layer, {hover: false}
);
map.addControl(click);
click.activate();
I am adding two OpenLayers.Control.SelectFeature controls on the map, one activates on hover, the other on click. The styles that are used in the style map define different colors and also a dynamic radius based on the number of features in a cluster. Here is the code:
        var defaultStyle = new OpenLayers.Style({
pointRadius: "${radius}",
strokeWidth: "${width}",
externalGraphic: "${icon}",
strokeColor: "rgba(55, 55, 28, 0.5)",
fillColor: "rgba(55, 55, 28, 0.2)"
}, {
context: {
width: function(feature) {
return (feature.cluster) ? 2 : 1;
},
radius: function(feature) {
return feature.cluster&&feature.cluster.length>1
? Math.min(feature.attributes.count, 7) + 2
: 7;
}
}
});
You see that the width and radius are defined as dynamic functions. But here we have an opportunity that I couldn't let pass. You see, in these styles you can also define the icons. How about defining the icon dynamically using canvas drawing and then toDataURL? And I did that! It's not really that useful, but it's really interesting:
        function fIcon(feature,type) {
var iconKey=type+'icon';
if (feature[iconKey]) return feature[iconKey];
if(feature.cluster&&feature.cluster.length>1) {
var canvas = document.createElement("canvas");
var radius=Math.min(feature.cluster.length, 7) + 2;
canvas.width = radius*2;
canvas.height = radius*2;
var ctx = canvas.getContext("2d");
ctx.fillStyle = this.defaultStyle.fillColor;
ctx.strokeStyle = this.defaultStyle.strokeColor;
//ctx.fillRect(0,0,canvas.width,canvas.height);
ctx.beginPath();
ctx.arc(radius,radius,radius,0,Math.PI*2);
ctx.fill();
ctx.stroke();
ctx.fillStyle = this.defaultStyle.strokeColor;
var bounds={
minX:1000000000,
minY:1000000000,
maxX:-1000000000,
maxY:-1000000000
};
for(var c = 0; c < feature.cluster.length; c++) {
var child=feature.cluster[c];
var x=feature.geometry.x-child.geometry.x;
var y=feature.geometry.y-child.geometry.y;
bounds.minX=Math.min(bounds.minX,x);
bounds.minY=Math.min(bounds.minY,y);
bounds.maxX=Math.max(bounds.maxX,x);
bounds.maxY=Math.max(bounds.maxY,y);
}
var q=0;
q=Math.max(Math.abs(bounds.maxX),q);
q=Math.max(Math.abs(bounds.maxY),q);
q=Math.max(Math.abs(bounds.minX),q);
q=Math.max(Math.abs(bounds.minY),q);
q=radius/q;
var zoom=2;
for(var c = 0; c < feature.cluster.length; c++) {
var child=feature.cluster[c];
var x=-(feature.geometry.x-child.geometry.x)*q+radius;
var y=(feature.geometry.y-child.geometry.y)*q+radius;
ctx.fillRect(parseInt(x-zoom/2), parseInt(y-zoom/2), zoom, zoom);
}
feature[iconKey] = canvas.toDataURL("image/png");
} else {
feature[iconKey] = OpenLayers.Marker.defaultIcon().url;
}
return feature[iconKey];
};

defaultStyle.context.icon=function(feature) {
return fIcon.call(defaultStyle,feature,'default');
}
selectStyle.context.icon=function(feature) {
return fIcon.call(selectStyle,feature,'select');
}
This piece of code builds a map of the features in the cluster, zooms it to the size of the cluster icon, then also draws a translucent circle as a background.
I will not bore you with the displayFeature and clickFeature code, enough said that the first would set the html title on the layer element and the other would either zoom and center or display the info card for one single feature. There is a gotcha here as well, probably caused initially by the difference in size between the map and the layer. In order to get the actual pixel based on latitude and longitude you have to use map.getLayerPxFromLonLat(lonlat), not map.getPixelFromLonLat(lonlat). The second will work, but only after zooming or moving the map once. Pretty weird.

There are other issues that come to mind now, like making the URL for the data dynamic, based on specific parameters, but that's for another time.

and has 0 comments
As promised, even if somewhat delayed, I am starting programming posts again. This time is about working with OpenLayers, a free wrapper over several Javascript mapping frameworks. The problem: after successfully creating and displaying a map and adding "features" to it (in this case a yellow circle for each physical location of a radio station), I wanted to add clustering; it didn't work. Quick solution: add the layer to the map BEFORE you add the features to the layer.

For the longer version, I have to first explain how OpenLayers operates. First order of business is creating an OpenLayers.Map object which receives the html element that will contain it and some options. To this map you add different layers, which represent streets, satellite imagery and so on. One can also add to any of these layers a number of features which will be displayed on the map. A common problem is that for many data points the map becomes cluttered with the rendering of these features, making for an ugly and slow interface. Enter "clustering" which means using a layer strategy of type OpenLayers.Strategy.Cluster to clump close features together into a larger one. It should be as easy as setting the layer 'strategies' array or adding to it an instance of a Cluster strategy. But for me it did not work at all.

After many attempts I finally realized that the clustering mechanism was dependent on the existence of an event handler for the 'beforefeaturesadded' event of the layer. Unfortunately for me and my time, this handler is only added when the layer is added to a Map! So all I had to do was to add the layer to the map before adding the features to it. Good thing that I recently shaved my head, or I would have tufts of bloody hair in my fists right now.

and has 0 comments
After playing the second campaign in the Starcraft II game, the Zerg one, I have to say that I wasn't terribly impressed. 27 missions in all, nothing very fancy, and a linear script that involves only Kerrigan getting stronger and going after Mengsk. The only delight here was the character of Abathur, the Zerg "scientist", who speaks like that Korean doctor in Monday Mornings and his only concern is to find new strands of evolution for the swarm. Kerrigan, even if her voice was that of Tricia Helfer, is a cardboard character who acts arrogantly like a queen (well, she is one) taking about vision and cunning, but acting impulsively and in a direct manner most of the time. She is the character I was playing, so that is probably why I didn't really enjoy the story so much. Mark my words, if you want to find the funny moments in the game, just click on Abathur whenever you can.

There were some nice surprises in the game, though, like when destroying a neutral vehicle on a map and receiving a communication from a human soldier complaining he just paid for that car. A huge game, made with people from three continents, SCII must appease the masses to pay for itself, therefore the script could not have been too complex. They also concentrated on the multiplayer action, not on the storymode one plays on Casual difficulty in order to see the "movie", but still... a good script and a captivating story could have brought millions more into the fold, so to speak. The Starcraft universe is, after all, a very interesting one, describing the interactions between three interstellar cultures (four, if you consider the Xel'Naga). The potential here is immense, with books and movies to keep people interested for generations.

I liked the concept of evolution missions. You see, Abathur had the ability to alter strains of units and gave you two choices which were mutually exclusive. But before you chose, you had to play two mini-missions that showed the different strains in action. You usually had to kill some indigenous lifeform, absorb its essence and integrate it into your creatures. Also in the game there was a creature called an Infestor, which, judging by how the Terran campaign went, you will not see it in the multiplayer game. It allowed you to capture any enemy unit, except the heroic ones. Pretty fun. One of the evolution missions gave you the ability to morph hydralisks to lurkers, one of my favourite units from the old Starcraft game.

Overall I enjoyed playing the campaign, even if I felt that it could have been a lot greater. Finished it in about 10 hours, too. Of course, it would have taken a lot longer if I hadn't played on the easiest difficulty, but I didn't have a mouse and I really was only interested in the story. Unfortunately, I didn't feel like I gained much by playing the campaign as opposed to watching all the cinematics one after the other on YouTube, and that is, probably, what bothered me most.

So here is a compilation of Abathur dialogs.

and has 0 comments
There are multiple problems with Star Trek Enterprise that doomed the show from the beginning. One, I am sad to say, is Scott Bakula, who I couldn't really see as a smart and resourceful captain till the very end of the show. Another reason was the name, making people confuse Star Trek Next Generation with this series.

Yet another, and perhaps the most important reason, were the producers who abused their station to steer the show into an impossible position: an Earth ship that is older than Kirk's starship stuck in the middle of epic conflicts through time and space. Even the writers complained that it should have remained a show about early exploration and abstain from the flamboyant temporal cold war or the Xindi saga.

You see, the show started very nicely, with the launch of the first warp 5 capable human starship. The Vulcans are still not sure whether the humans should attempt this, if they are ready for the big bad universe, while humans react like teenagers that have been forbidden something. We get to see the birth of technologies so important in the Star Trek universe: the transporter, newly invented and feared (maybe rightly so, considering the multitude of episodes that involve some accident with it in the other series); they use grapnel hooks to tow; they use explosive torpedoes at start and phaser cannons that they constantly upgrade; the replicators can only manufacture simple food and they have cooks on board for the rest. The interactions of the crew were also welcome, as all of them seemed perfect for the job.

That is why the first season was good, promising a very interesting show about the beginning of human exploration. Then they botched it, with the introduction of a silly and pointless race, the Suliban, who have a faction of people receiving instructions from the future, while other future people are trying to stop them interfering with the "proper" timeline. Basically they should have asked Jean Claude VanDamme to come. This almost destroyed the second season.

A strange decision, which I can't quite say was bad or good, was to make a season that is continuous, rather than the individual episodes of Star Trek until then. They introduced the Xindi, another intriguing concept, of a coalition of species: reptilian, arboreal, simian, insectoid and aquatic. This probably wreaked havoc with their budget, so only the humanoid species usually appear. Somehow they wanted to write about terrorism, since all Americans were being influenced by 9/11, therefore the theme appeared throughout season three and quite a few episodes in season 4. First were the Xindi, who (for no reason that I can see) tested a small variation of a weapon on Earth, in preparation for a bigger one that they were still constructing. Rather than compare it with the American atomic bombs, which were the natural analogy here, they, of course, compared it with the 9/11 attacks.

A strange patch of the universe where the laws of physics are warped by huge metal spheres that have weird effects is the stage for the entire season three, while Enterprise goes to find the Xindi and stop them from destroying Earth. I felt that it was an interesting season, the only bad bits being some inconsistencies of the overall story, rather than individual episodes.

Then they had a religious sect that threatened to blow themselves inside Enterprise unless Archer destroys their enemies. The caricatured religion and condescending jabs at Palestinians should have angered Muslims more than cartoons of Mohamed. Then there was the final act of terrorism, when a faction of xenophobic humans take over the Verteron array on Mars. That script was a mess, probably because it was the last episode before the show ending one. Too much terrorism for a show that defines the transition of humanity into a peaceful future.

And then there was T'Pol, played by the lovely Jolene Blalock. That was probably the problem: she was too damn sexy. They had, therefore, to make her have emotional issues, get into relationships with everybody, make regular trips in the decontamination chamber and rub her body with antiseptic cream and so on. It is a disgrace for women in Hollywood that her role was massacred by all of these preconceptions and easy ways to get audience attention. And she was a Vulcan, the precursor of Spock, for crying out loud!

In other words the powers that be exaggerated everything and allowed Archer to be moving through time or singlehandedly creating the federation, while trying to keep something for Kirk and Picard to do. I know it is difficult to make an enticing and modern prequel to series that you watched and loved as a kid, but randomly choosing themes and ideas to "fix" the show to be more something or another is not a solution. That is why, while it the newest series of Star Trek, it was also one of the worst.

The disappointment comes, for me, when I see several portions of the show actually being great. The MAKO concept, for example, highly trained military personnel that accompanied Enterprise in the Xindi story arch was a good thing and the interaction with the regular security personnel. The controversial decisions that Archer had to make to protect Earth lent more character depth than most of the moral cardboard crap that usually infests Star Trek. The old school technology made the voyages of the new starship bring smart new levels of excitement to the exploration of space. I liked the "In the Mirror Darkly" episode, which was not a crossover to an alternate universe, but only a show about the Enterprise of the alternate universe where there were all ambitious and evil. Even the start credits looked different, showing the glorious history of Earth conquests.

My conclusion, especially today, when the number of sci-fi shows explodes as the audience requires more and more fantasy, is that Star Trek represents the hope of humanity for a bright future and that allowing it to be defined by money hungry Hollywood production companies was ultimately a mistake, no matter how much soul the writers, directors and actors put into it. A space exploration show made by Europeans, something that would mirror Star Trek's United Federation of Planets in cinematography, bringing talent and ideas from Britain, Germany, France, Russia, etc, and borrowing from the sci-fi legacy of all. I would love to see that.

and has 1 comment
  Few people know this, but for a while now I've kept tabs on what happens in outer space, specifically Solar System colonization and asteroid mining. This means I've been connected to the wonderful revolution that is silently unfolding regarding human understanding and access to our small patch of universe.

  But this entry is not about space news, but rather my own thoughts on a subject that keeps bugging me: our own place in the world. You might have heard about the Fermi paradox. It is the theory that as big as the universe is as much time that has passed, the possibility that life and intelligence arose somewhere else is very close to 1. Not only that, but it remains close to 1 even if we look at the universe a few billions years back. The Fermi paradox asks then, how come we haven't heard of anybody else? Look at how fast we are evolving technologically; given a billion years surely we would invent at least the grey goo (although admittedly we would have the good taste to have it in more beautiful colors). What is going on?

  You might think this is not a real problem, but it truly is. To believe that no one in the whole of the universe did think to create self-reproducing probes is as ridiculous as believing we alone are intelligent enough to do it. Even at non relativistic speeds (stuff drifting aimlessly in the void) such a machine should have spread across the galaxy. Why aren't they here already?

  I am writing this piece while we have received confirmation that Voyager, one of the space probes launched in the 70's, run by computers with 4Kb of memory and spending power equivalent to that of a small light bulb to send info back to Earth, has reached interstellar space. It took more than three decades, but it is there. Another few tens of thousands of years and it leaves the Solar System. Triple that time and it reaches our nearest star. Billions of years have passed, though, and a thousand centuries are nothing on that timescale. And we build Voyager in the 70's! Of course, one could get pissed that no 20 Watt light bulb ever survived 30 years here on Earth, but that's another issue entirely. So where are the Voyagers of other species?

  There are several schools of thought on the subject. One, which I won't even discuss, is that we are the chosen people and are the only ones intelligent or even alive. Some versions of panspermia that suggest the ingredients of life came from meteors and are extremely rare on planets seem equally implausible to me.

  Another one, which I found really interesting, is that as technology advances, we are bound to create more complex virtual worlds, which, as comfort goes, are much easy to live in than "real" worlds. And I double quote the word here because when the simulation is advanced enough, the inhabitants there will also make other simulations of their own. In this view, we are most likely creatures that have evolved on the spare CPU of some machine, which is itself a simulation. It's turtles all the way down, man.

  Anyway, I find this theory fascinating because it also fights the law of entropy and the infinity of time. You see, in a simulated world, time would run faster than in real life. There is no need to wait 4 billion years for life to evolve, if a computer can simulate it faster. Do this until you reach the quantum limit underneath which time and space cannot be divided into smaller units anymore (if that even exists in the "realest" world) and you get universes that function with the fastest possible speed. Duplicate one of these virtual machines and two universes live simultaneously at the same time. It's a wonderful concept. Also, the quantum nature of our universe is eerily similar to the bits in a computer. Of course, once we get on that path, anything would be possible. We might be alone in the universe because it was designed as such. Or because the developers of our world are using a very common trick that is to render the graphics of a virtual world only where there are people playing. Another eerie similarity with the quantum world that changes behavior when someone it watching.

  There is also the concept of the multiverse. It says that all the possible states that can be taken by the universe are actually taken. We just happen to live in one version. If a particle can go one way or another, it will go both, once in each of two universes. Universal constants have values in the entirety of a range and a universe for each. We haven't met aliens yet and we were not destroyed by the culture shock because we are here not destroyed. It's a sort of a circular definition.

  Then there is the quarantine hypothesis. Aliens are not only present, but very much involved into our lives. They are waiting patiently for us to discover space flight or quantum matrix decomposition or whatever, before they make contact. They could even make contact just to tell us to stay away, all the universe if full, we are just late to the party. I guess it's possible, why not?

  Another idea, a more morbid one, is that no civilization survives beyond a certain threshold that we have not reached yet. When a global problem arises, there are people who are quick to associate this idea with that problem. Nuclear weapons, global warming, terrorism, sexting, Justin Bieber, twerking, etc. In the universal landscape they are irrelevant, at least until now and in the foreseeable future. Still, there is always the possibility that a game changing technology, what we call disruptive, will emerge naturally and will make any civilization disappear or simply obsolete or completely pointless. Just like the others above, this idea may assume a type of absolute. We could have a tiny chance to escape doom, only its probability is as close to 0 as the probability that there is a whole lot of life in the universe is close to 1. It's a bit terrifying, but because of its inevitability, also pointless to worry about.

  This idea of a chance, though, is interesting because it makes one think further ahead. If such a disruptive event or technology (Kurzweil's singularity, maybe) is about to come, what will it be? When did we burst technologically? When we developed mass production of commodities. When did we explode as a populace? When we developed mass production of food. When will we become more than we are? When we develop mass production of people, perhaps. That's one scenario that I was thinking about today and spurred this blog post. After all, it would be horrible to live in a world where every cell phone or computer is designed and/or built individually. Instead we take the models that are best and we duplicate them. We could take the smartest, more productive and more beautiful of us and duplicate them. The quality of the human race (as measured by the current one, unfortunately) would increase exponentially. Or we don't do that and instead create intelligent machines that surpass us completely. Only we design them to take care of us, not evolve themselves. Lacking the pressure to survive, we devolve into unthinking pets that robots feed and clean. That is another of these scenarios. What is both exciting and worrying is that there are a number of these scenarios that seem very logical and plausible. We can already see a multiverse of doom, but we are not doing anything about it.

  This brings me back to the colonization of the Solar System. For most of us, that sounds pointless. Why go to Mars when we haven't really finished colonizing the high mountains, the deep seas or even the African desert. All of these are orders of magnitude more friendly to human life than Mars. But the overwhelming advantage, the only reason why we must do it (there are others, but not necessary, only compelling), is to spread humanity in more than one basket. It is the good thing to do exactly because we don't know what is going to happen: just make a backup, for crying out loud, otherwise our simulated worlds of increasing complexity will just cease to exist when a larger meteor hits the planet.

  And speaking of meteors, I met people that had no idea that recently a meteor exploded in Chelyabinsk. What does it take for people to take notice of this very plausible threat? A meteor crashing into the new World Trade Center?

  This last point of view, of all I have discussed, is the most liberating and the only one worthy of consideration. Not because it is the best idea ever, but because it leaves us with a way out. We can, if we are careful, see the threat before it becomes unavoidable or spread ourselves wide enough so we don't get wiped out instantly. It gives us both hope and vision. All the others are absolutes, ideas that, just as the concept of an almighty god, are pointless to consider just because we can do nothing about them. All of our voyages, the most treasured discoveries and realizations of human kind, they all start with a thought. Let us think ahead.

and has 0 comments
As you know, I have been living in Italy for a whole two weeks now - I am a veteran, practically - and since friends keep asking me how things are, I am writing this entry. I will not dwell on the regular stuff; this is a hill region, close to the mountains so you can see them on the horizon, but not really mountainous. I am stationed right between the villages of Ispra and Cadrezzate and working 10 walking minutes from where I live. I don't really have anything else to say about the region, it's not that interesting. What I did find interesting are the differences in culture between this place in Italy and Romania. For starters, it seems the northern part of Italy is - proudly - different in culture from the rest of Italy as well.

Pizza, for example, is something that I find hard to understand. In this region close to Milan they make pizza like a sort of prosciutto, very thin. But it's a weird and cumbersome thin, since the outer crust is hard and brittle, while the interior is soft. That means that one cannot cut it easily unless the knife is very sharp, one cannot roll it up like a shawarma or doner kebab, since the margins break and the content of the pizza is not really bound to the dough, so it falls down, and one cannot hold a slice in hand because the core is soft. The way I found works best for me is to cut it into thick ribbons, then kind of compressing them with the fork so that you get several layers of rectangular pizza that you can put into the mouth and chew. I've also tried folding the pizza, so that it becomes a sort of quarter pizza of regular thickness, but that soft core makes it rather difficult to manage and often the ingredients tend to try to escape from the sides when you bite on the thing. Another difference in pizza culture is that they don't use tomato sauce on the pizza, they barely use any in the pizza anyway, instead pouring oil, spiced or not, over it. In my mind a pizza is made out of dough, tomato paste and cheese. They use little tomato paste and, since they feel the need to put oil on it, they probably use little cheese as well.

Coffee. Italians love their coffee, which they call espresso. It's a (pinky) finger thick layer of coffee, which they savor for the taste of it, then get back to work. My colleagues have this ritualized fixed hour coffee breaks, about two or three a day. They also have something called a lungo coffee, which means tall in Italian. This coffee is about two pinky fingers thick, but not quite. To get a full (small plastic) cup of coffee from the machine here, one has to ask for a cappuccino, which is a normal coffee with a lot of milk foam. Apparently they don't have anything like Starbucks in Italy; market research showed that they would not be successful. A mug of coffee is as abhorrent to Italians as a pint of palinka would be for a Romanian. Actually, some Romanians would not mind... Also, while this espresso thingie is small, it only concentrates the taste, as far as I can see, since I feel almost no caffeine effect.

Alcohol. Italians need to have beer with pizza. Drinking anything else, like wine or - God forbid - Coca Cola, is uncouth. However a half a liter of beer is in any bar at least 4 euros. Usually it is tasty, so it's probably a little higher end than a Romanian beer, but consider that in my country a beer is as expensive as mineral water. In comparison a glass of grappa (a grape brandy that seems to be the most alcoholic beverage they have) is about 3 euros. I don't know yet, but it might be that wine is as cheap here, if not more so, than beer. And speaking of wine, they don't have a clear marking on their wine bottles specifying the sweetness of the contents. Worse, I've bought a "secco" bottle of wine which was sweet as honey (this is bad for wine). At first I refrained from buying Chianti, because the name sounded sweet. But no, that's the good wine, apparently, while most wines in Lombardy as crap - lucky me. There are other wines here, as well, but you must know them. It is good that my colleagues are well versed in the alcoholic arts. Apparently in Italy you are allowed to have some blood alcohol content while driving, the equivalent of a having drunk a beer or so. But they don't check for it anyway, so it is customary to drive to a bar, eat and drink there, then drive back. Drinking at work doesn't seem to be a problem either.

Coperto. Sometimes translated as service on the bill, the coperto is the price of staying at a table, having a paper towel and using their utensils. At first I thought they were trying to rip me off, as in Romania we don't have a tax per place - strangely so, I would expect establishment owners to want to encourage people staying in, rather than making them pay for it. Italians don't really tip, though, as the coperto and the price of the food includes the tip. As a comparison, in Romania we habitually tip around 10-15%; not doing so sending a message that we are either cheap or that we disliked the service.

Services are very expensive. If the prices in a supermarket seem similar to ours, anything one does for you seems overpriced to me. I know it's a perception issue that I have and I must adjust it, but still when I got an offer to wash and iron my shirts with 4.5 euros each, I thought they were kidding. Luckily I found a Romanian speaking woman who will do all the work and not give me these insane prices, so maybe the price of service only seems high because I don't know where to find it, yet.

What else? There are no stray dogs or cats that I could see in the area. That's something I miss, actually. In Bucharest there are a lot of dogs and cats. Unfortunately scare tactics in the media and politics will probably lead to them being killed in the name of "progress" and "Europeisation". I did see squirrels and wild rabbits around here, though. Everybody moves around in a car or a bicycle. Not having either makes me the odd fruit in the tree. When I told them I don't even have a driver's licence my colleagues were flabbergasted. Italians don't shake hands when they see each other every day, so when I came to work the first few days and went to everybody to shake, they got freaked a little. I still haven't gone to Milan yet, but I went there to visit and work when I was employed in an Italian company, so I know the city is nice, but the culture is similar. No dogs there, either.

That's about it for now. More to come soon.

Your Inner Fish is a very nice book, popularizing the science behind paleontology and anatomy and making a surprising and thorough connection between the two. In short, Neil Shubin describes the way bodies are built and how our ancestry, from single cell organisms, fish, amphibians to primates, influences our design. It is a rather short book, and also easy to read. From field stories of discovering fossils in the wild to the anatomy classes that he teaches in university, the pages take one through a journey of true discovery and makes us understand so easily some things that very few people consider simple.

I could review Your Inner Fish for you, but someone did a lot more effort of it here. Also, the University of California Television YouTube channel released a one hour video presentation of the book which I am attaching to this blog post, as well as what seems to be the book's Facebook page. What I can say is that I liked the book a lot and I recommend it to everybody, science minded people or not.

and has 41 comments
I realize that the original format of the post was confusing, so, before you start reading it, here is a summary of solutions. You should read on afterwards in order to understand the context of each solution in part, though:
  • Torrents seem to keep a reference to some of the proxy settings when they started downloading. I don't have a clear solution for this, in my case changing the configuration of the proxy and restarting both proxy and Bittorrent eventually solved it. An aggressive solution is to remove all of your torrents and readd them later.
  • Sometimes the settings file gets corrupted or the settings don't make a lot of sense. Save all your ongoing downloads, remember all the relevant settings - like download folder -, stop Bittorrent, go to your user's Application Data folder and remove the settings.dat and settings.dat.old files in the Bittorrent folder. (usually C:\Documents and Settings\YourUser\Application Data\Bittorrent or.and C:\Users\YourUser\Application Data\Bittorrent). After restarting Bittorrent you will have a fresh set of settings, so change them to what you need and reload the list of torrents that you saved.
  • Check the connection settings. Sometimes you want to minimize the number of connections Bittorrent makes because your provider gives you only a limited connection pool. Make sure the value is not too small. Bittorrent needs a lot of connections: to find peers, to download and upload stuff, to open new connections in order to find the faster one, etc. In my case 15 was too little and I had to restore it to the original 150, even it 15 worked with previous versions of the program.
  • Solution from a comment: check your firewall settings and the firewall settings of your router/modem
  • Solution from a comment: check your internet provider. Some, like Comcast, are throttling some types of traffic. This link might help: Stop your ISP from Throttling Bittorrent Speeds
  • Solution from a comment: enable Bittorrent protocol encryption and restart the application
  • Solution from a forum: disable DHT from the Bittorrent client settings (or enable it, if it is disabled?)
  • Solution from YouTube: start the torrent client 'As Administrator', suggesting there may be some file access issues you have.
  • Solution from a comment: enable DHT. If only some torrents seem to be stuck, see if you can enable DHT in those torrents' properties.

Hope that helps. Now for the original post:

Update (again): While resetting the settings did solve my problem temporarily, I had the same problem the next day as well. The only meaningful thing that I had changed was the global maximum number of connections (Preferences -> Bandwith) from 150, which seemed excessive, to 15. I changed the value back to 150 and it started downloading immediately! This is strange, since the value was 15 for years, I think. Well, I am getting tired of these solutions that only work until the next day. Hopefully this is the last time the problem appears.

Update: The enthusiasm I had after making some of the torrents work faded when I noticed most of the other torrents were still not working. My only solution was to go to the Application Data folder, then Bittorrent, and delete settings.dat and settings.dat.old while the program was closed, then restart Bittorrent. Warning! You will lose all the torrents and settings so save them first (I selected them all and copied the magnet links, then added them back one by one afterwards). The weird thing is that, while it worked, the software also looked quite different from what I was used to. Perhaps just blindly updating the version of Bittorrent all the time is not the best option. Sometimes we need to reset the setting to take advantage of the new software settings.

I've had a problem with a router which prompted me to remove it and put the Internet cable directly into my computer port. I wouldn't recommend it for you, since a router adds a level of protection against outside access, but still, I was not home and a friend of mine "fixed" the problem. Since then, I couldn't download anything on Bittorrent, as it got stuck at "Connecting to peers", even if it connected to the trackers, and saw all the seeds and leechers. Googling around I found a suggestion to remove "resume.dat" from the Bittorrent Application Data folder, but it didn't work for me. I tried a lot of things, but none worked until I found an obscure forum asking about a proxy server. And it dawned on me that it could be from there.
You see, I had previously installed a free proxy program called Privoxy, but I had bound it to the previous IP address of the computer. As a result, it didn't load anymore. The Internet settings were OK, I had removed any reference to a proxy, but strangely enough something in the Bittorrent client kept some information relating to the proxy. After I only bound the proxy to the local address, Privoxy started and miraculously also did the Bittorrent downloads (after a restart of the program).

So, if you have issues with the Bittorent client getting stuck at "Connecting to peers", check if you have recently changed your Internet proxy settings.

and has 0 comments
Update: I recognized the voice of Brad Dourif as Piero (how can one not?) so I went to see who the other voice actors were. If you, like me, felt a strange attraction to Callista Curnow, that's because her voice is that of gorgeous Lena Headey. Also you might recognize Susan Sarandon as Granny Rags (hee hee!) or John Slattery as Admiral Havelock. But pretty much no one comes close to Brad Dourif, except perhaps Roger Jackson, who is the voice of Mojo-Jojo!

As you may know, I am a great fan of Arkane Studios games. They did Ultima Underworld, Arx Fatalis, Might and Magic X (which for all intents and purposes was Arx Fatalis 2) and now they did Dishonored. You will probably say that Ultima Underworld was actually a Looking Glass Studios game, but when they dissolved, some people from their team went on to work for Arkane and the resemblance of the games is pretty obvious. Anyway, I am now in a small village in Italy and only have Internet at my work. Imagine my great surprise when I discovered a kit of the Dishonored game on my laptop. I immediately installed it and played the game for a non stop 20 hours until I finished it. However, it was my desire to see the entire story (and to get some sleep in the weekend) that made me finish so quickly. You see, the game is a first person shooter-adventure that follows a storyline. However, on each stage you can explore and find a lot of secrets and side quests and even influence the story a little bit through your actions. The universe in which the game is played is a wonderfully crafted steampunk world, driven by whale oil and technology invented by mad scientists and filled with political intrigue. I can safely say that the game is a combination of Arx Fatalis, Thief/Assassin's Creed and Vampire: The Masquerade – Bloodlines.

For an analysis of the game, there are a lot of things to be said. One of them is that the 3D world was, as far as I could see, almost perfect. I didn't get stuck in some fold of the wireframe, I didn't reach places I shouldn't have reached even when having the power to Blink, I didn't see through textures or seen any major bugs, actually. The game is a huge collaboration of companies, with people from all over the world, they could have screwed up anywhere: design, storyline, sound bits, software, 3D world, etc. It did not happen. You can also see the love that was poured into the game when the story does not end with an obvious finish, but continues on for a few stages. They could have worked less for the same money, but they somehow chose not to.

The gameplay is a joy. You have different ways of solving problems: you can kill anything that moves, you can choose to not kill them, but perform a chokehold on them and hide their unconscious bodies so you can avoid detection or you can go on high ledges and sneaky paths to avoid conflict all together. An interesting component of the story is The Outsider a supernatural being, probably a god, that looks like a normal guy, dressed normally for the age, but having black eyes. He is treated as the Devil in the official religion of the country, but he acts like your ally in the game. His only obvious interest is to have fun watching the chaos. For these purposes he gives you his mark and the gift of magic, which allows you to teleport, possess small animals and humans, summon a pack of ravenous pack of rats to devour your enemies and other fun things like that. The world if very interactive. You can, for example, take a random item like a bottle and throw it away. This would either unbalance your enemy, if you hit them directly, so you can deliver a deadly sword strike, or cause them to go to investigate the noise of the bottle breaking. One interesting option is to take the head of the enemy you have just beheaded and throw it into another opponent. Each level had hidden magical artifacts which you can find using a special Outsider device, a living heart with mechanical bits which you hold in your hand and that talks to you - told you, fun stuff. This usually prompts you to go out of your way to find said artifacts. The complexity of each stage is staggering. The first two stages I tried to play as completely as possible, which took me a lot of hours. After the first level ended I felt pretty good about myself. I had explored a lot of the map and I felt pretty smug about it. In the final summary of the mission I saw, to my chagrin, that I had found about half of all the valuable objects that I could have found. The rest of the missions I just breezed through, in order to see the ending. If I would have played this game as thoroughly as I possibly could, it would probably have accounted for many tens of hours of gameplay. Well, maybe it's me, but emergent gameplay is the coolest thing since fire was invented.

The devices you possess are old school enough to be a lot less effective than magic. You have your trusted one bullet pistol, which you must reload after each firing, you have your crossbow, which can fire darts, sleep darts or incendiary bolts, you have delicious bombs which, when triggered, fire a fast winding metal wire that cuts your enemies to pieces, grenades are always fun, and so on.

There are some issues which I had with the game though. It seemed to me that the magical spells were rather unbalanced. I cannot tell you how much they are unbalanced until I play the game again in another way, but it seemed to me that you absolutely needed to have Blink and Dark Vision and that the best offensive spell was the summoning of the rat pack. The rest were almost useless, at least by description: something that allows you to attack stronger and more enemies at once if you have enough adrenaline, something that allows you to possess animals, but there aren't that many animals in the game, and only partial possession of people, something that causes a gust of strong wind. Well, I will try them soon so I can tell you more in an update. Another thing that felt useless to me were the bone charms who gave me stuff that didn't really seem important. I did play the game on Easy, since I didn't have a mouse for the laptop, so that may explain my disdain of the things.

It is important to realize that the game has downloadable missions and content through Steam. This means the story can go on. I intend to explore this avenue. Also, after playing a second time I have to say that I was amazed of the option to not kill anyone the entire game. Even the assassination missions have ways of getting rid of the characters without killing them (even if their fates are usually worst than death). If you want to go that way, please always check that the unconscious victim is actually unconscious. Otherwise you end the mission with one or two dead people and there is no going back. One example is if you choke one guy, then let it fall with the head in the water. He dies even if you immediately remove him.

All in all I cannot recommend the game enough. Add to this that after you buy it, you also get extra chapters as downloadable content and, who knows, maybe they will allow the community to make their own chapters. It was just fantastic. Go play it!

I embed here an example gameplay from someone who is obviously more skilled than I am.



and has 0 comments
I've reviewed two books of William Golding already and both of them were complex analyses of the human nature. This little novel, The Double Tongue, is similar in complexity. A note at the beginning of the text is explaining perhaps best why Golding's books are so great in details. You see, the novel was published posthumously, after a draft of it was found in Golding's belongings. He has already finished the book once, wrote another version and had started on another draft. No wonder his books were so reflective and self referential and connected to so many other works of literature or philosophy.

About the content, it is rather interesting, as it details the story of a girl in ancient Greece, just before Romans started dominating the country, who becomes the Delphi Pythia. The story quickly goes to the decorative role a "well bred" female would have had in those days, carefully instructed how not to draw attention, kept in total ignorance, all for the moment when she would be offered to a husband. After attempting escape from this fate, the only option her father has to "do with her" is to give her to a priest of Delphi called Ionides. Thinking she was going to become a servant of the temple, sweeping floors, she becomes the oracle. This is used to analyse concepts as religious sentiment, political use of faith and to describe the parallel system used in this world of superstition and showbiz.

I thought that it was a really short story. Told from the point of view of an octogenarian woman, it dwells on the adolescence, the initial shock of coming to Delphi, but very quickly skips entire decades to bring the conclusion. The title is relating to both the Python that the god Apollo killed in the Delphi cave, which gave him the forked tongue that said two things at once, but also to the double system of religious ecstasy backed by very real intelligence networks and the duplicity of people who either declare themselves religious while lacking the sentiment or the other way around . The story is inspired by Ion of Euripides and the ending is revealing only to a select few who understand the reference to a passage of the Bible (see here and here).

I can say that I liked the novel. It wasn't a "wow" thing like in the case of Lord of the Flies, nor did it cause me to feel more enlightened with the final reveal. Being that short and the last novel of Golding, there is really no reason not to read it.