Monday, December 31, 2012

The (forced) mobile designation for the iPad on Blogger

I was looking for something on my blog using my iPad and I noticed that the format of the blog was horrible. It used a "mobile" mode by default. That meant no Javascript, fixed width, etc. Pretty nasty. There is a link at the bottom of the page that says "View web version" which changes the "m=1" parameter in the query to 0, which makes it accessible as it should have been.

I will be investigating this and how to address it. Meanwhile, there is the workaround of clicking the link mentioned above.

Sunday, December 30, 2012

A spectacular, if nothing else, chess game (Wing Gambit)

I want to present to you a game I had last night that was both spectacular and really silly :) You know when you look at chess master games and you are either bored by their precision or befuddled by their ingenuity? Well, this is only a really good show, the equivalent of big budget action movies.
1. e4 c5 2. b4 {The Wing Gambit, a weird anti Sicilian move that I want to
master.} cxb4 3. a3 bxa3 4. Bxa3 {At this point White has control of the
center and a developed minor piece. The rook also has a semi open file
available.} a6 5. Bc4 d6 6. Nf3 e6 7. O-O Be7 8. d4 Nf6 9. Re1 O-O 10. Nc3
Nc6 {Even if I wrote a blog entry on the Wing Gambit, I remembered nothing
and my opponent was so terrified that he tried to protect everything with
unnecessary pawn moves.} 11. e5 {I had no plan and it shows. I was planning
to take on e5 with the rook, eventually, or free my queen by actively
moving the knight on f3.} Ne8 12. Bd3 d5 13. Bb2 {I've decided that I
needed that bishop and moved it to protext the defenceless knight. However,
that is no longer an active square for it.}

(13. Bxe7 Qxe7 14. Na4 Nb4 15.
Bf1 b5 16. Nc5 {The computer suggested this weird continuation, were both
knights are trying to find outposts in the opponent's teritory.})

13. .. f6
14. Nh4 {I had come up with a daring stratagem, enacted in the next few
moves. Can you spot it?} Nxd4

(14. .. fxe5 15. Bxh7+ Kxh7 16. Qh5+ Kg8 17.
Ng6 exd4 18. Ne2 Nf6 19. Qh8+ Kf7 20. Nxf8 Qxf8 21. Qh3 Kg8 {Houdini
recommends a different approach for Black, something that would have
brought it into an advantageous position.})

15. Bxh7+ {The attack begins
with a minor piece sacrifice.}

(15. Nxd5 Qxd5 16. Bxd4 f5 17. Nf3 {The
computer had other ideas, which were almost as wild as what I was

15. .. Kxh7 16. Qh5+

(16. Qxd4 fxe5 17. Rxe5 Bxh4 18. Rh5+ Kg8 19. Rxh4 Qf6 20. Qxf6 Nxf6 {The computer would have equalized quickly
in this situation, a most boring continuation that I refused out of hand. I
didn't check the king to swap a bishop for a knight.})

16. .. Kg8 17. Ng6 fxe5

(17. .. Nf5 18. Rad1 Nh6 19. Nxd5 exd5 20. Rxd5 Qc7 21. exf6 Bxf6 22.
Nxf8 Bg4 23. Qg6 Bf5 24. Qh5 Qf7 25. Qxf7+ Kxf7 26. Bc1 Kxf8 27. Bxh6 Bxc2
28. Bd2 {A violent variation from Houdini, something that you have to check
out because there is a lot to learn from it. However, the game did not go
that way at all.})

18. Qh8+ Kf7 19. Nxf8 {Here I publicly prove my idiocy.
The position before taking the rook was mate in 6 moves. As such, I got
cold feet at the apex of my attack. Just a few more seconds of thought and
I would have seen the continuation that the computer saw.}

(19. Nxe5+ Kf6
20. Qh4+ g5 21. Qh6+ Kf5 22. Qg6+ Kf4 23. g3# {A beautiful ending and
something that I should have seen. A pawn mate, with the king banished to
my side of the board and none of the Black pieces taken except three

19. .. Bxf8 {Now, my win in this game was almost completely the
merit of my opponent. I did wild and beautiful moves, but none of them were
actually accurate. At each point he could have come up on top, if he played

(19. .. Nf6 20. Rxe5 Qxf8 21. Qxf8+ Bxf8 22. Nxd5 Nf3+ 23. gxf3
exd5 24. Re3 {The computer would have quickly simplified the position and
taken advantage of its material gain. It would have made quick work of my
apparent king safety as well.})

20. Rxe5 Nf6 {I believe at this point Black
was considering cornering my queen. It would have required freeing the
rook, though, which was impossible.}

(20. .. Qf6 21. Re3 g6 22. Qh7+ Qg7
23. Qh4 Nf5

(23. .. Nxc2 24. Rf3+ Kg8 25. Nxd5 Qxb2 26. Rxf8+ Kxf8 27. Qe7+ Kg8 28. Qxe8+ Kh7 29. Qe7+ Kh6 30. Qh4+)

24. Rf3 Be7 25. Qf4 Bf6 26. Qb4 {A
long dance leading nowhere. My queen banished and the Black king

21. Nxd5 {I saw this move that would have gained a pawn, freed
my rook and removed the only Black developed piece.} exd5

(21. .. Be7 22.
Qxd8 Bxd8 23. Nb4 Nf5 24. Nd3 {The computer would not have gone for it.})

22. Bxd4 Be6 23. Rae1 Bg4 24. Qh4 Qd7 25. h3 Bf5 26. R5e3 Nh7 27. Qh5+ {At
this point I was despondent. I had time trouble, my beautiful attack ended
in a big flop and the only thing I could think of was harassing Black's
pieces in an attempt to catch one off guard and gain the material

(27. Bxg7 Kxg7 (27. .. Bxg7 28. Re7+ Qxe7 29. Rxe7+ Kf8 30. Qb4
Bf6 31. Rxh7+ Kg8 32. Qxb7 Rf8 33. Rc7 Bg6 34. Qxa6)

28. Re7+ Qxe7

(28. .. Bxe7 29. Rxe7+ Qxe7 30. Qxe7+ Kg8 31. Qxb7 Rd8 32. Qxa6)

29. Rxe7+ Bxe7 30.
Qxe7+ Kg8 31. Qxb7 Rd8 32. Qxa6 Rd7 {The computer saw this continuation
which is pretty much forced. An interesting combo, but I doubt I could have
mated the king with only a queen against three pieces. I doubt I could have
won.}) 27. .. Kg8 28. Rf3 Bxc2 29. g4 {At this point I only had one idea
left: moving the g pawn front and use it to mate the king. It was as
transparent as it was desperate, but I think my opponent was completely
thrown off his game by the crazy maneuvres I had used.}

(29. Rc3 Be4 30. f3
Bf5 31. g4 {Houdini would also have pushed the g4 pawn, but with backup and
tempo. Again, something to be learned from that. Check out the wild
continuation it found.} Be6 32. Qe5 Re8 33. Rc7 {threatening the queen, but
also g7.} Bxg4 {completely crazy: this is a queen exchange, but the
computer saw the possibility to gain a pawn in the process.} 34. Rxd7 Rxe5
35. Rxg7+ {two can play that game. See how White is going for the pawns in
this insane position, as well.} Bxg7 36. Bxe5 Ng5 {Again, insane! Why not
move the bishop? because the knight can be developed and a new threat (f3)
can be declared.} 37. Kf2 Nxf3 38. Rd1 Nxe5 39. hxg4 Nxg4+ 40. Kf3 Ne5+ 41.
Ke2 Nc6 42. Rxd5 {White would not have won this, but was crazy game.})

29. .. b5 {His plan, to push his passed pawns and gain huge material advantage
or completely block my pieces from attacking would have worked, but it
needed some preparatory moves on the king side, which were not made.} 30.
g5 Be4 31. g6 {The bishop move came too late. I was threatening mate and
the only option to save the situation was the sacrifice of the bishop.}
Bxg6 32. Qxg6 b4 {Again, Black helps me out with a useless pawn move.} 33.
Re5 b3 34. Rxd5 {Enamored by wild moves I did this. The idea was that if
the queen was not defending g7, I could then take the f8 bishop with yet
another sacrifice and mate at g7. I completely missed that the rook could
be taken by the king, avoiding the mate.}

(34. Rh5 {Houdini went instead
for a safe mate in 7 which I missed, even if my initial plan was to move
the rook to h5, but I then forgot about it.} Ng5 35. Rxg5 Bd6 36. Qxg7+
Qxg7 37. Rxg7+ Kh8 38. Rf5 Bh2+ 39. Kxh2 a5 40. Rh5# {Another beautiful
computer mate.})

34. .. Qxd5 35. Rxf8+ Nxf8 {My always greedy opponent was
kind enough to not see the mate. I had time trouble and no matter the
material advantage, I had no time to finish the game without a blunder such
as this.}

(35. .. Kxf8 36. Qxg7+ Ke8 37. Qxh7 Rc8 38. Qh8+ Kd7 39. Qg7+ Kd6
40. Qg3+ Ke7 41. Qh4+ {The only solution for White was to check ad
infinitum, which was not possible if both sides played well. The game was

36. Qxg7# 1-0

The game started as a whim. I wanted to do something, I didn't really feel like anything, so I started a chess game, expecting to lose. I am usually a fan of aggressive, off the book, starting positions so, when I was confronted by the Sicilian defence, I decided to try the Wing Gambit. Now, I know I wrote a blog entry about it, but I did not remember anything from it and it would have been unfair to read the blog entry while playing, so I went with the first three moves and then winged it (get it?).

I want to thank Black for helping me along, as with the silly moves I did it was impossible to win if it weren't for his valuable assistance >:)

There are comments in the game as long as several variations. What I want you to pay special attention to is the variation at move 19. If I would had seen it, and I should have had, the game would have been over in a spectacular fashion in only 25 moves. Other variations show how the game could have ended if Black has played well.


Friday, December 28, 2012

Genetic Programming: On the Programming of Computers by Means of Natural Selection (Complex Adaptive Systems) , by John R. Koza

Book cover Oh, the monster of a book! If you want to learn to do genetic programming, then this is the book for you. If you need an interesting presentation of what genetic programming is, then this book is way too heavy.

Let's start with the beginning. Genetic Programming: On the Programming of Computers by Means of Natural Selection (Complex Adaptive Systems) is a scientific book written by John R. Koza to explain why, how and what to do to make your computer find solutions to problems by using natural selection algorithms to automatically create programs to solve them. This is not a new field and a lot of research has been done in it, but this book takes it almost to the level of encyclopaedic knowledge.

First, Koza submits the idea that genetic programming can be used in most problems where computers are been used. That's a bold claim, but he proceeds on demonstrating it. He takes problem classes, provides code to create the programs that solve them, shows results and statistical analysis on the results and explains what the algorithm did to create said program at specific iterations. That's a lot to take in. If you are working on a program and you are using the book, you are more likely to find it extremely useful, both as a source for information and as a reference that can always be consulted.

However, if you are a casual reader like myself, reading all that code and statistical analysis in the subway can be difficult. And it's a lot of book, too. So, after some consideration, realising that I have no current project on which to apply the knowledge within the book, I've decided to stop reading it. I got to about a quarter of it, so I can safely say that it is a very thorough and well written book. You just have to need it in a certain way.

Thursday, December 27, 2012

Guns, Germs, and Steel: The Fates of Human Societies , by Jared Diamond

Book cover

I have to say that most of the books I start reading, I am also finishing, no matter how bad they are. I will not be finishing Guns, Germs and Steel, but not because it is a bad book, but because it is too thorough.

I know, it sounds bad for me, but this book, as with the next one I am going to review, are true science books, going through all the arguments, all the proof, anecdotes and theories before making a point. It is not an overly large book, but each passage has meaning and there is a ton of data that must be assimilated in order to be able to say I read the book. Alas, I don't feel like assimilating this much and reading it to the end, just in order to pretend I've read it would be pointless.

The book, written by Jared Diamond, is trying to explain why some regions of the world are more developed than others, why some people are oppressed, while other are the oppressors, why some people get along fine having farms and cities and a thriving economy while others are fighting to stay fed or secure. The author immediately dismisses the idea of racial superiority. Given the biological incentives to stay alive and the selection process that still goes on in less developed areas of the globe, it would be silly to consider those people genetically inferior to well fed Westerners from countries where the leading cases of death are random diseases or accidents. So the reason must be something else.

Having done a lot of living and studying in Papua New Guinea and Polynesia, he has direct knowledge of the way people live there and extensive knowledge of their history. Especially Polynesia he considers a rich bed of "natural experiments" as the many islands have spawned numerous social, political, military and food systems that eventually had to interact. He doesn't stop here, though, giving examples from all parts of the world, the native Americans, Africa, Eurasia, etc.

As far as I could ascertain reading only half of the book, the reason the world looks like it does today is because of a lucky assortment of domesticable animals and crop plants that appeared in the Fertile Crescent. The advantage of such a food surplus allowing for all kind of social and administrative developments was too great to compete with. The culture that spawned from that area quickly overwhelmed the world. In the few areas where resistance appeared, technological advances, immunity to disease that they would still spread and the general historical knowledge gained from the written word made the dominance of said culture a certainty.

For a sociologist, a historian or a palaeontologist, this book should be a must read. It explains a lot, using a lot of arguments on very well documented facts. The style is sometimes too formal, eventually repeating some questions and answering them with overwhelming detail, but none of it is superfluous. As such, it was an interesting read, but a very difficult one. Something that would have ended up eating a lot of time and yielding little lasting knowledge.

So, having faith that I got the gist of it and hoping that maybe I will watch the PBS documentary based on the book to get to the end of it, I will end by recommending it to anyone in the field, but not so much for a casual reader.

The Center of the Cyclone: An Autobiography of Inner Space, by John C. Lilly

Book coverI wanted to read this book as I knew the author experimented with LSD and sensory deprivation tanks. He was the inspiration for the brilliant film Altered States, which I enjoyed immensely. The third book of John C. Lilly, The Center of the Cyclone starts as an intense book, an exploration of the deep mind using arcane and sometimes forbidden techniques. A magnificent beginning... and a horrid ending.

Let me start from the beginning. Lilly is a psychoanalyst and a neuroscientist at the same time, perfect skills to explore and understand the limits of the human mind. He first starts his experiments with dolphins, trying to understand them and communicate with them. He starts an entire institute in order to research this field, but the book is not about that, but about the period starting with LSD experiments. At the time he begins taking the drug, it was legal. Parties were held where people would share the experience and entire schools of therapy were using LSD to facilitate access to the mind.

Having previously tried experiments of sensory deprivation, a sort of shutting down of all outside stimuli in order to explore inward, he attempts to mix the two techniques: LSD and sensory deprivation tanks. Something opens up and he gains access to repressed memories, deep understanding of self and incredibly fast and precise advances in pinpointing psychological hurdles, trauma points. Till this point, I have gobbled up the book, resonating profoundly with the scientific method of exploration aided by chemical substances that eliminate the barrier between consciousness and subconscious. But then it all changes.

If you intend to read the book and make up your own mind, I suggest you stop reading the review now and start with the book. I am going to express my own opinions on what I read there.

What I think happened is that Lilly had the spiritual openness that allowed him to connect empathically with himself and others, something I believe resides in the right hemisphere of the brain. This openness is facilitated by the catholic upbringing that he is subjected to as a child. He himself, under the influence of LSD, retrieves a repressed memory inside a church where he starts seeing angels flying around. He confesses this to a nun and she, bitchy as she was, gets terribly upset and tells him that only saints can have visions, not a seven years old boy. This makes him forcefully lock the door that he had opened in himself. But now, after he has dedicated himself to science and logic, he stumbles upon this drug which unlocks the memory and so the initial skill.

This should have been a momentous occasion, something to combine perfectly the scientific mind with a strong spiritual/emotional side. Unfortunately, he was truly unprepared for it all. From a scientific book, it quickly devolves into yogi and Eastern spiritual practices, combines knowledge gained from experiment with hearsay from ancient texts, mixes hallucination with perception. He acknowledges that he started writing the book, then, after experiencing all of this spiritual avalanche, he decided only the first three chapters were worth keeping. Unfortunately, those are the first three chapters that I loved and that made sense.

It is not just my own subjective disgust for his abandonment of reason that makes me think the book follows up with personal involution, but also the way the book is structured, the writing style, the use of information at the end which had not been introduced previously... it all gets worse.

Now, he is the second scientist I've read that reports some sort of mental or at least emotional connection at a distance, the first one being Kary Mullis, who also seemed rather wacky and experimented with drugs. I really wanted to believe that, as well as many of the extraordinary things reported in the book, and wanted to explore them for myself. But now... I am not so sure. Be it the LSD or some sort of giving up to the emotional side, I see this book as a diary of going bananas and not realising it.

That doesn't mean that the book doesn't contain valuable knowledge. The fact that, single or under guidance, the man could access hidden memories and background "programs" after the first LSD experience makes the entire business of psychotherapy laughable with their lengthy discussions and careful probing. Various methods to access the trance necessary to explore your inner spaces that don't even involve chemical aid (like the looping of a word and listening to it until entering the desired trance state) I bet are perfectly functional. Also, there was one collaborator of Lilly's, Ida Rolf, that used a technique combining deep tissue massage and trance to unlock the repressed memories that affected body stance.

Many more interesting and very useful facts are hidden in the book. Alas, it is difficult if not outright impossible to separate wishful thinking from actual fact, garbage from science. Or maybe, who knows, I am so biased that I can't understand some essential truths in the book. I guess it is up to you to read the book and decide for yourself. I loved the beginning and loathed the ending.

Wednesday, December 12, 2012

Forge of Darkness, by Steven Erikson

I really wanted for Forge of Darkness to be great, something that would wash away the disappointment of the tenth and final book in the Malazan Book of the Fallen. And, in a way, it is. However, with increases in the inner philosophical monologues and a downplay of magic, with a plethora of characters that, for anyone not reading (or remembering, like me) the entire Malazan series, don't yet make sense, it felt raw, pretentious, more in line with Steven Erikson's admission that after 20 years of writing, the voices have stopped nagging him (for a while at least, as evidenced by this book). If this was supposed to be a book to be read, understood and loved, then I cannot see it as a success. If it was only a way to unload the chaos of characters demanding voice in the author's head, then it is quite a realization.

I won't describe the plot in detail. Enough to say that it is all happening in the Tiste realm and it is the story of the beginning of the high magic used in the Malazan cycle. The Azathanai, magic creatures of unknown potential, start interacting with the world on a more personal level. Draconus marries a queen, while K'rull starts bleeding magic as a gift for anyone to use. Eleinth break open into the world and gates for the major flavours of magic are opening as a result of Draconus' love gift. Through all of that, the division of the Tiste and the break of civil war are preparing to shatter the realm of Kurald Galain.

I imagine the second book will be a lot more active, with magic breaking out wild in a world unprepared for it, however the first was more about presenting characters (a zillion of them) and setting the stage. My impression was that, even if Tiste people live for hundreds of years, not every soldier and common man can have pages of internal monologues about the philosophical aspects of living. That is the biggest failure of a book that is otherwise brilliant. I will continue reading the Kharkanas cycle (I doubt it will end as a trilogy), of course, but I am starting to ask myself when the next book of Ian Cameron Esslemont will come out.

Monday, December 10, 2012

Video refresh for the Flash impaired (read Apple)

For a long time now, Flash was the de facto "cross browser video" technology. That is why many of the posts in this blog containing videos had embedded Flash videos in them. That until Apple came along and did not support the technology. As a result, more than half of my posts with embedded video were not available on an iPad, for example.

Today I've made sure the embedded videos were not deleted or otherwise unavailable and also replaced them with versions that also work on the iPad. If you browse the "video" tag in the blog and you see something that doesn't play on your device and it doesn't mention anything in the text about that, please let me know so I can update the post accordingly.

So, stop despairing, iPad people, now you can listen to the music and watch the movies Siderite style. ;)

Friday, December 07, 2012

Tuesday, December 04, 2012

Vezi - Coma

I thought about translating the lyrics to English, but there would be no point. It is pure poetry and it is beyond me. For the non-Romanian visitors, I just hope you like the song.

Friday, November 30, 2012

Writing a blog post from my iPad

I have to admit that after using the iPad a little, I got to enjoy it and find some uses for it. Most enlightening was using it with a cover. Without it, the iPad is just a thing to make your hands tire; with a cover one can place it somewhere, watch a movie, hold it in a myriad of ways and alternate the muscles needed to support it, if any. I still hate Apple and everything it stands for, but I'll admit that I stopped disliking my iPad.

I was thinking the other day what would my father do with a device such as that? His job at the moment is a translator, that even without it, he would like to comment on things and write content. So I have experimented by writing a blog post on the iPad (see previous post) to see how it holds for data entry.

My conclusion is mixed, but it borders on the positive. The first thing to notice is that, since I was writing English, the autocomplete was very helpful. I doubt that it would have been as easy to write in Romanian, for example. Then, the solution for writing on the iPad was not the split keyboard (keys too small and cumbersome use), but placing the device on my belly (in it's cover that allows for this) and typing with two fingers. The writing went pretty fast, but my hands soon got tired. I had to pause at regular intervals. That is not something bad when creating, though.

Of course, there have been problems with stuff like punctuation or writing non letter characters. Writing about code on the iPad would have been suicidal, I think. Also, I was a little put off by the fact that the blog post entry did not look too good on the iPad browser (the interface on the right, like labels, was inaccessible). I know this is a Google issue and they should fix their Blogger interface to fully support devices like the iPad, but also an Apple issue, since that interface works in every desktop browser and it should have worked in Safari as well (btw, have you seen how cool and cross browser is my blog even on the iPad? :) ).

Bottom line: I really would have wanted to say using a keyboard is so much better, but with my incredibly bad typing I have to always backspace and fix words, while in the iPad autocomplete enabled, one "key" at a time writing style, this was a non issue. My hands got tired though, even if I found a relatively comfortable position and in the end I had to Publish the post from the desktop just because I also needed to set the labels for the post. Overall, a usable experience.

The need to do something

As an experiment in blogging from the iPad, I am also trying to say something about my thoughts lately. One of them is about the need to be active, to do something, no matter what.

There is obviously nothing wrong with the first part, more with the latter: we are content when we do all kind of stupid things. We might regret them later, but while we are engaged in them we are enjoying it. A brilliant example is my grandmother; when she retired from her job she had a crisis, she did not know what to do, so she came to our house and catalogued every book we had. And we had hundreds. In a recent film Maggie Smith's character said that her apartment is so small that she can make it spotless in 30 minutes; then what is she supposed to do? Why did she need to do anything?

I also remember the times when, no matter what idiot designed the feature and what moron asked for it, I was happy to feel useful coding it. I imagine that people with jobs that I consider inferior, like housecleaning for example, would also feel better doing that instead of nothing at all. We sometimes curse the people that use us for their own benefit: the faceless corporation, the greedy boss, the slave driver manager. But isn't that a bit two faced if we actually enjoy it and feel that it gives purpose to our lives anyway?

What is this obsession with doing something? I can imagine that during our evolution, individuals who needed to do something to keep occupied were more successful than the ones sitting around doing nothing. That we are obsessive by design is a bit unsettling.

I guess the true test of this hypothesis would be to get into a situation where I am neither constrained to do something nor having a particular craving at that moment. Alas, this is hard to achieve. Even during holidays, there is first a time of respite from the stress of work related thoughts, then a bit of relaxing, then some things that we had planned before and then... it's over: we need to get back to work.

There have been rare occasions when I would become bored with sleeping, watching movies, reading books and news, playing games or learning whatever held my fancy at the moment. It is a time of creativity, of sifting through previous ideas and dreams and deciding some are not worth the effort or the resources to complete (or are damn impossible) and, yes, of doing. And yet the doing is never as good as imagined before starting it and never as satisfying as expected after having been done it. Yet the sheer pressure of sitting still and doing nothing forces on.

Of course, being a rather ordinary human being, I can hardly consider myself free of constraints. The rare occasions mentioned are just that: extremely rare. Having a lot of money might enable this kinds of situations, but even then I suspect the real hurdle would be to actually get to be alone. Alone with one's thoughts, alone from incessant distractions, free to let the mind roam. Would I then do something great, as I often daydream? Would I find the situation satisfying enough to not do anything? Or would I bore myself and be forced to seek the very distractions I have been fleeing? And before feeling left out and ignored, dear wife, I have to mention that this is an exploration of myself, outside any context, and that includes you, not forgotten, just off topic.

The answer to the question above is that I don't know, really. I just feel that the true test of one's life is to have the opportunity to imagine its next steps free of constraints and the resources to follow that path. Until then, we are just absorbing stuff, like biological capacitors. And sometimes we die before we get to discharge. I refuse to even consider people that learn nothing from their experiences.

There was a TED talk about the evolution of computer intelligence. We are at the edge of a revolution when computers get as smart as us and then exceed that intelligence. It is inevitable. People will be replaced by machines in increasingly more fields of expertise until there is nothing left to do. Can you imagine how that would be? I can't at the moment. Like pets to exceedingly smarter computers, we would either explore new avenues of thought or just sit and eat and sleep and fornicate. The pessimist that I am, I predict the latter. We will drown in the thing that defines us next after intellect: socialization. You already see hints of this now (I am talking of you, Facebook!), but this will only get worse.

I am torn right at this very moment between exploring this scenario (and of course, finding a solution) and the very subject of this post: doing or not doing something because we need to. Of course, this post must win for now. I can save the world later (I am putting it in my todo list).

My life is really quite uneventful, but I wonder if it should ever be different. The Chinese do have that curse "Be that your life is an interesting one". Is that truly that awful? Why is it that whenever I feel content with my life I also feel the need to change it? And when I do not, I feel the need to be content. Must I journey to find myself, as in so many bullshit movies and books? And if so, what will I find? Will I even want it after finding it? Is my life like a boring movie that must pick up the pace and, if so, who is watching it besides myself and who gets to direct it?

Tuesday, November 20, 2012

The Evans Gambit

After such a long pause it seems only natural that I come up with a good chess blog post and I think this one, about the Evans Gambit, fits the bill. Since it is a gambit employed in the Giuoco Piano/Italian Game opening, it has been widely used from the 1820s when it was first documented. There are numerous videos on it on YouTube, but the one I consider the best is the one below, from GM Gregory Kaidanov.

I have also explored the gambit with ChessBase, but there it is difficult to see the spectacular games, the ones that lead in traps or quick wins, as they are often studied and the mistakes there not repeated in high level games.

1. e4 e5
2. Nf3 Nc6
3. Bc4 {The Ruy-Lopez (Bb6) is twice as common, but this is the second most popular move for White.} Bc5 {The main Black response to Bc4, almost on par with Nf6.}
4. b4 {The Evans Gambit, giving material for speed. It is interesting to note that this gambit is the second most popular way to go from here, after the mainline c3.}
(4. O-O {When first invented by Evans, he castled first.} d6 {Here is a trap in the original Evans Gambit.}
5. b4 Bxb4
6. c3 Ba5
7. d4 Bg4
8. Qb3 Qd7
9. Ng5 Nd8
10. dxe5 dxe5
11. Ba3 Nh6
12. f3 Bb6+
13. Kh1 Bh5
14. Rd1 Qc8
15. Rxd8+ Qxd8
16. Nxf7 Bxf7
(16... Nxf7
17. Bb5+ c6
18. Qe6+ Qe7
19. Qxe7#)
(16... Qh4
17. Bb5+ c6
18. Qe6+ Qe7
19. Qxe7#)
17. Bxf7+ Nxf7
18. Qe6+ Qe7
19. Qxe7#)
4... Bxb4 {The overwhelmingly more used move to accept the gambit, rather than decline it.}
(4... Bb6 {A possible run for the lot less employed gambit declined variation.}
5. a4 a6 6. Nc3
(6. a5 Ba7
7. b5 axb5
8. Bxb5 {This transposes into a sort of Ruy-Lopez.})
6... Nf6
7. Nd5 Nxd5
8. exd5 Nd4
9. a5 Ba7
10. d6 cxd6
11. c3 Nc6
12. O-O O-O
13. d4 h6
14. Re1 Qf6
15. Nd2 exd4
16. Ne4 Qg6
17. cxd4 d5
18. Bxd5 Nxb4
19. Bb3 d5
20. Ng3 Bg4
21. Qd2 Nc6
22. Bc2 Qf6
23. Qd3 g6
24. Bxh6 Bxd4
25. Bxf8 Rxf8 {0-1 Santos,M (2245)-Martins,C (2278)/Americana 2000/EXT 2001})
5. c3 {Multipurpose move to defend d4, make way for the queen to go to b3 and doing it with tempo as it is attacking the Black bishop.} Ba5 {Bishop retreats, keeping an eye on the White king.}
(5... Bc5 {Bc5 transposes easily, but also has the disadvantage of giving White an extra tempo after d4.}
6. d4 exd4
7. O-O)
(5... Be7
6. d4 Na5
7. Nxe5 Nxc4
8. Nxc4 {Beautiful center and development options.} d5
9. exd5 Qxd5
10. Ne3 Qd8
(10... Qa5
11. O-O Nf6
12. c4 O-O
13. Bb2)
11. O-O Nf6
12. c4 O-O
13. Nc3)
(5... Bd6 {Not used a lot, as it cramps the d pawn.}
6. d4 Nf6
7. O-O O-O
8. Re1 h6
9. Nbd2 {Leads for a closed game for both sides, not really in the Evans spirit.})
6. d4 {Defended by queen, knight and a pawn that is, at the moment, pinned, White aggressively makes a claim on the center.} exd4 {The defending pawn can not move and taking with the knight invites a host of unpleasantness}
(6... d6
7. Qb3 Qd7
8. dxe5 Bb6
9. Nbd2 Na5
10. Qc2 Nxc4
11. Nxc4 d5
12. exd5 Qxd5
13. Qa4+ Bd7
14. Nxb6 cxb6
15. Qb4 Ne7 {Three games in the database for this, two White wins and a draw.})
(6... Qe7
7. O-O Bb6
8. Ba3 d6
9. Bb5 Bd7
10. Bxc6 Bxc6
11. Nxe5 Bb5
12. Re1 Qe6
13. Nf3 O-O-O
14. Bb2 a5
15. Nbd2 Qd7
16. c4 Ba4
17. Nb3 Ne7
18. Qd2 Nc6
19. Bc3 Rhe8
20. d5 Nb4
21. Bxb4 axb4
22. Qxb4 Bxb3
23. axb3 {1-0 Sveshnikov,E (2560)-Sofieva,A (2370)/ Cappelle la Grande 1995/EXT 1997})
(6... Qf6
7. O-O Nge7
8. Bg5 Qd6
9. d5 Nd8
10. Qa4 b6
(10... f6
11. Bc1 Bb6
12. Na3 c6
13. Rd1 {Tchigorin})
11. Na3 a6 {Two games between Chigorin and Steinitz in 1889 from here: one won by White, the other by Black.})
7. O-O {Main themes in the Evans: keep your king safe, develop as many pieces as possible and prevent the Black king from castling.} Nge7 {Nge7 is the move masters have found most effective against the Evans gambit, as well as d6, but at amateur or club level it is more likely you will see Black take the pawn on c3.}
(7... d6 {Meant to protect against the push of the White pawn to e5 and liberating the bishop.}
8. cxd4 Bb6
9. Nc3
(9. d5 Na5
10. Bb2 Ne7 {And again: Nge7.}
11. Bd3 O-O {At this point we can assume that the gambit has failed, as Black has achieved castling, but they are not out of the woods yet.})
9... Bg4 {Black is planning to castle queen side and their position is getting better.}
(9... Nge7 {At this point, Nge7 is a mistake.}
10. Ng5 O-O
11. Qh5)
(9... Nf6
10. e5 dxe5
11. Ba3 {Not taking the e pawn, but preventing Black from castling!} Bxd4 {let us see how it could go down from here.}
12. Qb3 Qd7
13. Rae1 Na5
14. Nxe5 Nxb3
15. Nxf7+ Qe6
16. Bxe6 Bxe6
17. Nxh8 {White wins a lot of material here.})
10. Bb5 Bxf3
11. gxf3 {Take with the pawn to continue to protect d4.} a6
12. Ba4 Ba5
13. Bxc6+ bxc6
14. Qa4 Bxc3
15. Qxc6+ Kf8
16. Qxc3 {Now material is even, but Black cannot castle and does not control the center.})
(7... dxc3 {Taking the pawn, accepting this second gambit, might seem a good idea, but it only allows White to develop a powerful attack.}
8. Qb3 {attacking e7, b7, c3 as well as getting close to the lightly defended Black bishop.} Qf6 {The only options for Black to defend the e7 pawn are Qf6 or Qe7.}
(8... Qe7
9. Nxc3 Bxc3
(9... Nf6 {The usual move in this situation is Bxc3. The Nf6 variation is what happened in the Fischer-Fine game from 1963, the one in the video above. The rest of the moves are from that game.}
10. Nd5 Nxd5
11. exd5 Ne5
12. Nxe5 Qxe5
13. Bb2 Qg5
14. h4 Qxh4
15. Bxg7 Rg8
16. Rfe1+ Kd8
17. Qg3 Qxg3
18. Bf6#)
10. Qxc3 f6 {At this point Black has not yet achieved safety, but it is pretty close. I continue with the main line, without annotations.}
11. Ba3 d6
12. Bd5 Bd7
(12... Qd7
13. Rac1 Nge7
14. Rfe1 Qd8
15. Nh4 Bg4
16. Qg3 Qd7
17. h3 Be6 {Rajaboz-Smeets 1995, ended in draw.})
13. Rfe1 O-O-O {Black castles (Steinitz Gray 1872), although White manages to win.})
9. e5 {The pawn cannot be taken due to the threat of Re1.} Qg6 {Only good square for the queen.}
(9... Nxe5
10. Re1 d6
11. Qb5+ {and if Black protects the knight with the pawn on d7, they open themselves to this fork.})
10. Nxc3 {Gaining back a pawn and bringing yet another piece into the game. White has brought almost all the pieces out, while Black is cramped.} Nge7 {And here it is again, Ne7. If playing correctly, it seems Black cannot move that knight anywhere else in any variation.}
11. Ne2 {Very sophisticated idea, as it attempts to lure Black into castling and losing their queen or some other piece in its attempted rescue.} O-O {Black falls into the trap. The next few moves demonstrate it.}
12. Nf4 Qe4 {The only acceptable move for the queen.}
(12... Qg4
13. h3 Qf5
14. Bd3 Nd4
15. Nxd4 Qxe5)
(12... Qh6
13. Ne6)
13. Bd3 Qb4 {Only safe square.}
14. Qd1 {The Black queen is still in trouble, as Rb1 follows.} Ng6 {This is the only move that is giving respite to the queen, but White still gains advantage.}
(14... d6
15. Rb1 Qc5
16. Rb5 Qc3
17. Bb2 {Queen is trapped.})
15. Rb1 Qe7
16. Nd5 Qe6
17. Rb5 {threatening to take on a5 and then fork queen and rook at c7.} Rb8
18. Ba3 d6
19. exd6 cxd6
20. Ng5 Qd7
21. Qh5 h6
22. Nf6+ gxf6
23. Qxh6 fxg5
24. Bb2 Nce5
25. Rxe5 dxe5
26. Bxe5 f6
27. Bc4+ Rf7
28. Qxg6+ Kf8
29. Bd6+ Ke8
30. Qg8+ Rf8
31. Qxf8#)

For more background you can scour the net for videos on the Evans Gambit, there are a lot. There are a multitude of traps in the Evans as well, for the unprepared. One video that I do recommend, though, is Ruy Lopez vs Italian Game where it is explained why the Giuoco Piano is less favoured than the Ruy Lopez, even if it seems to open up more avenues of attack, and also what are the goals of White in the opening, thus explaining a lot about the coices made during the Evans Gambit.


Thursday, November 15, 2012

The medicine you do not need

Close friends and family of mine live in the world of alternative medicine. They believe and practice homeopathy, all kinds of massages that use bio energy, they take drugs made from plants and use all sorts of essences and stuff like that. I, on the other hand, live in the world of provable science, double blind studies and technology. And yet, after resisting the influence of my peers for so long, there are three stories which, ironically, are from the world of scientific (OK, let's call it commercial) medicine, which make me doubt the validity of my faith in it.

First of all there is a TED talk which I embed here.

This guy, Ben Goldacre, tells the story of experiments that form the basis of our medical beliefs and of the drugs and methods doctors prescribe to patients. As an example, from 53 published experiments on cancer, 47 were NOT replicable. That means only 6% of them were. Why is that? Because scientific papers are being published with overwhelming bias if they present positive results. Therefore if I make 2 experiments and one of them shows success, it is more likely to be the only published. So for everyone reading scientific papers it would appear I was successful 100% of the time.

The second story is slightly related to the first, since the wonderdrug Tamiflu was also mentioned in the above talk. Here is Peter Gotzsche, leader of the Nordic Cochrane Centre in Copenhagen, wondering why Roche, the firm that created Tamiflu and made billions on the bird and porcine flu scares, did not release any of the relevant data on the workings of the drug for over three years now. One might argue that the tonnes of Tamiflu stockpiled by different governments could be completely useless.

But the third story is truly baffling. NewScientist published this article that says two recent studies have shown that beta-blockers, a type of drug used for over 40 years for treating heart problems, has NO effect. It works by blocking the effects of adrenalin and noradrenalin and, it was believed, it helped minimize the risk of heart attack. Apparently, they don't.

So, when I read these stories in no more than a month, how can I trust anything in the world of medicine? It is a highly lucrative business and it was to be expected to be filled with corruption and misdirection, but never have I thought that its basic functionality could be affected. Entering a drug store, I see that the shelves are filled with useless dietary supplements in colorful boxes and bottles, but I always assume that the drugs I get for specific ailments or by name are the real deal, that what is written on the label and prospect is correct. I also feel that people that die or suffer because they chose the wrong kind of medicine do so in a sort of natural selection; I just didn't believe that one of those people could be me.

Sunday, October 21, 2012

My first encounter with custom web fonts

Spurred by the story of the OpenDyslexic font, the one that is now included in this blog as an option for dyslexic people, I started exploring this concept of custom fonts for a web page. First of all, I wanted that the dyslexia option would work in all browsers, so I checked it in Chrome (my default), FireFox and Internet Explorer 8.

I was not surprised to see that Internet Explorer was not showing the fonts as Chrome did, but I was a little that FireFox did not render the font. I had FF 3.0.11 installed at that moment. I've updated FireFox, checked it, seemed to be working. Then, on a whim, I started to look into web fonts for Internet Explorer. And the option exists! Even better, you can use web fonts since Internet Explorer 6! The catch is, though, that Microsoft are using a proprietary font format which only recently was submited to the W3C as an open standard.

Now about the dyslexic fonts people. I went to their site using Internet Explorer and I got that annoyingly condescending message "You are using an outdated browser.". In other words if you are dyslexic they will make and host a free font for you, but if you use Internet Explorer, screw you! I found this behaviour at least weird and more towards offensive.

So I downloaded their font, converted it from OTF to EOT format using the online free font converter Font2Web, then went to find some sort of font hosting site that would allow me to upload and host my custom font. And I found one called TypeFront. They are only offering for free only a single font that can be accessed 500 times daily, but still better than the other services that ask for money for every single option. So close to making the dyslexia option cross browser! And FAIL. TypeFront only allows the upload of fonts with the formats OTF, TTF and WOFF. They are not even mentioning EOT. I wrote them an email, but I don't expect much. Meanwhile, if you know of a decent free font hosting site, please let me know. Update: I was wrong. The TypeFront service allows for uploading only a few formats, but then it converts and publishes all formats, including EOT and even SVG. I am happy to report that the dyslexic font works now on all browsers!

Update April 2016: It appears that the TypeFront site is completely down, the domain gone.

It occurred to me that there is an interesting possibility, that the people at TypeFront and/or the people at DyslexicFonts do not know that Internet Explorer supports web fonts. The people at Google do. Check out this site: Google Web Fonts that allows the free embedding of over 554 font families. All you have to do is embed a script in the page. Incidentally I've included a feature in the site that allows to set a custom Google font for yourself, but there is no visual interface for it, yet. Their problem is that they did not adopt any font for dyslexics.

So, after documenting my journey, let me give you some links to resources that explain where all these formats come from, why some fonts are free and some are not, and so on:
  • True Type font format (TTF) - you will not be surprised to hear that the standard was developed by Apple in the 1980s as a competitor to Adobe's Type 1 fonts used in PostScript. This format is supported in all browsers but Internet Explorer through the CSS3 rule @font-face.
  • Open Type (OTF) is the next version of TrueType. Paradoxically, Open Type is a registered trademark of Microsoft's, so why they choose not to support it is beyond me. OTF is also supported in all other browsers.
  • Developed in 2009, the Web Open Font Format is a container with compression and additional metadata for all the other formats. The specification was submitted by Mozilla, Opera and Microsoft. And while all browsers support it (Internet Explorer 9+, FF 3.6+, Chrome, WebKit browsers, Safari, etc., they are still limited by which of the wrapped formats they can interpret. Thus, IE9 can open a woff file, if it contains EOT inside.
  • Embedded OpenType (EOT) is Microsoft's attempt at a web standard for fonts. It allows compression and has some sort of protection against copying. These little files work (somehow) since Internet Explorer 6, when CSS3 was a dream and all "modern browsers" had nothing.
  • Comparison of layout engines (web typography) - a small article discussing browser support for web typography.
  • The history of fonts - how typefaces evolved over time.
  • Intellectual property protection of typefaces

Saturday, October 20, 2012

Låt den rätte komma in, by John Ajvide Lindqvist

I used the original name for the book, but I didn't read it in Swedish, I read it in English for obvious reasons. John Ajvide Lindqvist wrote this 2004 book and the screenplay for the 2008 Swedish movie with the same name, but not for the American version Let Me In, made in 2010.

Let the Right One In, as the title of the book translates into English, is the story of a bullied 12 year old that forms a relationship with a child vampire. And not the sparkly or stylish vampires, but the ones that kill for a living. The title comes from verses of Morrissey's song Let the Right One Slip In. Of course the Americans could not help but remake the film using beautiful people and more romance. Actually, I didn't see that version and maybe I should before I start saying bad things about it, but I did watch the Swedish version and it was a beautiful film and it was the reason for me reading the book. If you haven't seen any of the versions I highly recommend you read the book first. The film is more mellowed down, but also preserves some hints of the story in the book and has that same eerie alienated feel to it.

The movie transforms the story in a sort of romantic late childhood thing, but the book is only slightly like that as it covers uncomfortable subjects like the poor and artificial Socialist suburbs in Sweden, child gangs, bullying, paedophilia, homosexuality, murder. The story is both spooky and disturbing, but also weirdly comforting. I really don't want to spoil it, so I will end with the link to my review of the Swedish film and a short conclusion: the book is not brilliant, but it is decently written and has a good story. It would be a shame not to read it.

Friday, October 19, 2012

Showing the progress of a long running operation in a web page

We had a legacy import page in our application that took a very long time to perform its operation. Thus, the user was faced with a long loading empty page and no feedback. We wanted to do something to show the user the progress of the import without fundamentally changing the page. Of course, the best solution would have been to make the import an asynchronous background operation and then periodically get the status from the server via Ajax calls, but limited by the requirement to not change the page we came up with another solution: we would send bits of javascript while the import went on.

An attempt was made but it didn't work. All the scripts were loaded and executed at once. The user would still see an empty page, then a progress bar that immediately gets to 100%. Strange, that, since we knew that in certain circumstances, the scripts are executed as they are loaded. The answer was that browsers are caching a minimum bit of the page before they are interpreting it, about 1024 characters. The solution, then, was to send 1024 empty spaces before we start sending in the progress. This value of 1024 is not really documented or standard; it is a browser implementation thing.

Our design had the page loaded in an iframe, which allowed for scripts and html to not be loaded in the import page (thus making us stumble upon this behavior), and allowed for them to be loaded in the parent page. The scripts that we sent through the ASP.Net pipeline (using Response.Write and Response.Flush) accessed the resources from the parent page and showed a nice progress bar.

In case the page would have been a simple ASP.Net page, then the html and the CSS would have had to be sent first, perhaps instead of the 1024 spaces. There would have been problems when the page would have finished the import and the output of the page would have followed the one sent via the pipeline, but for our specific scenario it seems mere spaces and script blocks did not change the way browsers interpreted the rest of the page output.

A secondary side effect of this change was that we prevented the closing of the connection by some types of routers that need HTTP connections to have some traffic sent through them in an interval of time, providing a sort of "keep-alive". Before we made this change, these routers would simply cut the connection, leaving the user hanging.

Sunday, October 14, 2012

Blog new features

I've added functionality to remember the settings of a user in cookies, so that when you return, the choices you made are persisted. These choices include the use of important quotes, the presence of flies and cats on the blog as well as the use of dyslexic fonts! If you are dyslexic you should definitely check that option. The tools are available from both the left side of the blog as well as from the new toolbar (which doesn't seem to appear on tablets).

The toolbar I've added has more options than these tools, including a one button RSS subscription feature, a nice button for sharing the content with your friends, a list of people online on the blog, miscellaneous notifications, as well as a chat! I will try to be present in the chat so that I can answer your questions, but I am not promising anything.

Please tell me what you think of the new features. (especially if you are dyslexic :) )

Sunday, October 07, 2012

True Horror

Bear with me here, this is one of those posts that come from an idea and result in a completely different thing.

This one started with the idea that religions have an expiration date. There were a lot of religions before Christianity took hold of the world, some of them really really old. The innovation of both Christianity and Islam is that they introduced prophets, new versions of their Gods and proof that they are not dead, uncaring or otherwise absentee. So, I asked myself, is it possible that a religion has an expiration date, after which it can't support the hold on its followers and they drift away to other things, like Scientology?

Then, the second idea. In order to create a new religion, one that can be called something more than a sect, we need a prophet. Someone with a history so outrageous that people can associate it with divinity. He or she must also sacrifice themselves for their strict ideals and/or people. We also need someone who came about sooner than 2000 years.

Idea number three: Hitler! He affected the entire world, he had pretty strict ideals and has sacrificed himself for them and (presumably) for his people, whoever they might have been. Outrageous life: check. New to the scene: check. Fanatic following: check. He is the perfect prophet! Add to this his deep hatred of Jews, who can only be reasonably differentiated from other people only by their religion. Add to this the mysticism that consumed Hitler before he died and his fascination with the occult. You get a prophet that burned the world for religious reasons.

Idea number four: That idea number three must piss both sides equally much. Neonazis would probably consider it blasphemy (thus unwittingly giving strength to it). Jews... well, they are pretty pissed at Nazis. Any cult based on them would probably disagree with them, too. The other people, they would bring into the argument the horror of war and the Holocaust and other things like that. Admittedly, the God that Hitler would have been a prophet for has to be pretty twisted, but we've seen worse, as gods go. The present ones are Gandhi compared with the old bunch.

Idea number five: we've discussed a ridiculous idea and the arguments against it are pretty much liked to the horror that Hitler brought onto the world. While over 70 million people have died as a consequence of World War II, we fixate on the religious connotations of the Holocaust and the directed persecution of one people. I hope I am wrong, but when I imagine the angry masses, terrified by this idea of mine, I imagine people bringing the Jew massacre in the forefront, with pancards and signs with "Never again". And that leads me to this fifth idea: that if 6 million people being massacred for their religion and nationality is horror, then the rest of 64 million being ignored or considered casualties of "regular" war, the idea that people can be killed in the millions and it is OK, if there are political and economic reasons for it... that is true horror.

Friday, September 28, 2012

Darkness Visible, by William Golding

Book cover William Golding writes difficult books. They are not only complex in prose and detail, but dissecting difficult subjects as well. Best known for Lord of the Flies, which is a pretty dark and twisted tail of children getting trapped in what is basically a social experiment, he manages to write something even darker in Darkness Visible.

The book follows the story of several characters. There is Matty, a child that emerges from the burning wreck of a bombed building during WWII with half of the body burned. He grows up in the state social system, interacts with Mr. Pedigree, a teacher who is also a raving paedophile, and then spends the rest of his life seeking redemption. He is a simple, almost stupid person, easily influenced, but taciturn and withdrawn most of the time. There there are the two beautiful and very smart daughters of a rich man. With every opportunity given to them, they prefer to dwell on the remoteness of their father and screw their lives completely. And finally Sim and Edwin, two old men passionate about books and good friends, who despite their best intentions and education are not capable of understanding the world and people around them.

Golding uses themes I've seen before: the way people can perceive so differently a shared event, like in Rites of Passage and the almost clinical dissection of the motivations characters have in doing what they do, as in both Lord of the Flies and Rites of Passage. The way he explores the inner, most private triggers of his characters is almost creepy.

The book is not exactly a success. I had a hard time reading it, mostly because of its overly verbose prose, and the presentation of people's lives sometimes goes to incredible extremes, escaping the main story completely. That doesn't mean it is not a brilliant book. One just has to be in the right mood to be able to finish and understand it.

Thursday, September 27, 2012


A little known (at least by the people I've talked to) feature of Transact SQL (the Microsoft SQL engine) is the setting of ROWCOUNT. Usually ROWCOUNT is used to get the number of rows an operation has returned or affected and it is actually @@ROWCOUNT. Something like this:
UPDATE MyTable SET Value = 10 WHERE [Key]='MySetting'
SET @RowsUpdated =  @@ROWCOUNT

Instead, setting ROWCOUNT tells the SQL engine to return (or affect) only a specified number of rows. So let's use the example before:
UPDATE MyTable SET Value = 10 WHERE [Key]='MySetting'
SET @RowsUpdated =  @@ROWCOUNT
In this case a maximum of one row will be updated, not matter how many rows exist in the table with the value in the Key column 'MySetting'. Also, @@ROWCOUNT will correctly output 1 (or 0, if no rows exist).

Now, you will probably thing that setting ROWCOUNT is equivalent to TOP and a lot more confusing. I had a case at work where, during a code review, a colleague saw two SELECT statements one after the other. One was getting all the values, with a filter, and another was selecting COUNT(*) with the same filter. He correctly was confused on the reason why someone would select twice instead of also selecting the count of rows returned (or using @@ROWCOUNT :) ). The reason was that there was a SET ROWCOUNT @RowCount which restricted the number of rows returned by the first SELECT statement.

Here comes the gotcha. Assuming that setting ROWCOUNT is equivalent to a TOP restriction in the SELECT statement (in SQL 2000 and lower you could not use a variable with the TOP restriction and I thought that's why the first solution was used) I replaced SET ROWCOUNT @RowCount with SELECT TOP (@RowCount). And suddenly no rows were getting selected. The difference is that if you set ROWCOUNT to 0, the next statement will not be restricted in any way. Instead, TOP 0 will return 0 rows. So, as usual, be careful with assumptions.

There are other important differences between TOP and SET ROWCOUNT. TOP accepts both numeric and percentage values. Also, SET ROWCOUNT will NOT work on UPDATE, DELETE and INSERT statements from the version of the SQL server after 2012, so it's basically obsolete. Also, the query optimizer can consider the value of expression in the TOP clauses during query optimization. Because SET ROWCOUNT is used outside a statement that executes a query, its value cannot be considered in a query plan.

Update: in SQL 2012 a new options has been added to the ORDER BY clause, called OFFSET and FETCH, that finally work like the LIMIT keyword in MySQL.

Monday, September 24, 2012

Chess Fundamentals, by José Raúl Capablanca

Book cover Any person that is remotely interested in the history of chess knows the name of José Raúl Capablanca. He was a great chess player and the world champion for 7 years in a row. I've just finished reading one of his books, entitled Chess Fundamentals, and I thought it was great. It featured clear chess principles, backed by real master games and, what I believe it is most important in the book, all the matches featured in Chess Fundamentals are annotated by Capablanca, who focuses on what moves he saw best, the ones he didn't like and, most fortuitous, what he thought when he played those moves, as many of the games are his.

Unfortunately, as with any chess book, one must spend time to focus on the details and to revisit it as many times as it takes to understand and learn what Capablanca wanted to express. I've read the book as part of an iPad application called "e+books". You get the free application, this Capablanca free book, then you have to pay for any other there. What I found really nice is that the positions and moves in the book are mirrored by a chess board that allows navigation between moves, variations, going back and forth, etc. It really helps reading the book and I recommend it, especially for beginners. Using a real chessboard to mirror the moves might be best, but it adds a layer of discomfort and complexity that might deter someone from finishing the book.

The book is structured into 6 chapters, the last being a series of 14 games in which Capablanca either lost or won. He begins with some principles of the endgame, the part of a game that he considers the most important. If you recall, Josh Waitzkin also highly recommended focusing chess training on the endgame, where there are few pieces and the principles become clearer. Also, since some chess games end with mates somewhere in the middle game, there is less opportunity to learn that part of chess. For openings Capablanca has only a few words, focusing on the healthy development of pieces, which he considers the most important. As stated previously, the games are the most important and their complexity is pretty high. Some say that the book is not fit for beginners for that reason alone, but I disagree. Even the most complex strategies are explained in the annotations and I believe they are a rare opportunity for anyone to glimpse in the mind of a chess master and realize where their aim as chess players lies.

All in all a rather easy to read book, with the help of the iPad application, but very hard to completely understand and remember. I intend to return to it, several times perhaps, in order to internalize some of the cool patterns of thought I saw in there. I warmly recommend it.

Sunday, September 23, 2012

Patents and ideas

I had an idea one of the previous days, an idea that seemed so great and inevitable that I thought about patenting it. You know, when you have a spark of inspiration and you tell no one about it or maybe a few friends and a few years later you see someone making loads of money with it? I thought I could at least "subscribe" to the idea somehow, make it partly my own. And so I asked a patent specialist about it.

He basically said two things. First of all, even if it is a novel idea, if it made of previously existing parts that can obviously be put together, then it doesn't qualify as a patent. If the concept is obvious enough in any way, it doesn't qualify. Say if someone wrote a scientific paper about a part of it and you find the rest in some nutjob blog about alien conspiracies, then you can't patent it. The other thing that he told me is that a true patent application costs about 44000$, in filing and attorney fees. I don't imagine that's a small sum for someone in the US or in another rich country, but it is almost insane for anyone living anywhere else.

But there is a caveat here. What if the nutjob alien conspiracy blog would be this one? What if, by publishing my idea here, no one could ever patent it and the best implementation would be the one that would gather the most support? It's a bit of "no, fuck you!", but still, why the hell not? So here it is:

I imagine, with the new climate of "do not track"ing and privacy concerns that search engines will have a tougher and tougher time gathering information about your personal preferences. Google will not know what you searched for before and therefore will not be able to show you the things it thinks you are most interested in. And that is a problem, since it probably would have been right and you would have been interested in those things. The user, seeing how the search engine does not find what they are looking for, will not be happy.

My solution, and something that is way simpler than storing cookies and analysing behaviour, is to give the responsibility (back) to the user. They would choose a "search profile" and, based on that, the search engine would filter and prioritize the results in a way specific to that profile. You can customize your profile and maybe save it in a list or you can use a standard one, but the results you get are the ones you intended to get.

A few examples, if you will: the "I want to download free stuff" profile would prioritize blogs and free sites and filter out commercial sites that contain words like "purchase", "buy", "trial", "shareware", etc; it would remove Amazon and other online shops from the result list and prioritize ThePirateBay, for example. Some of the smarter and tech savy Googlers are using the "-" filter to remove such words, but they are still getting the most commercially available sites there are. A search profile like this would try to analyse the site, see if it fits the "commercial" category and then filter it out. Now, you might think that sites will adapt and try to trick the engine into thinking they are not commercial in nature. No, they won't, because then the "I want to buy something" profile would not find them. Of course, they will adapt somehow and create two versions of the site, one that would seem commercial and one that would not. But the extra effort would remove from their profit margin. Or try a search profile like "long tail", where the stories that get most coverage and are reproduced in a lot of sites would get filtered out, allowing one to access new information as it comes in.

Bottom line is, I need such a service, but at the moment I am unwilling to invest in making one. First of all it would be a waste of time if it didn't work. Second of all it would get stolen and copied immediately by people with more money than me if it did work. Guess what? It's in my free blog. If anyone does it, they can't patent it, they can only use it because it is a good idea and they should make it really nice and usable before other people make it better.

Friday, September 21, 2012

Death and Decay

For a few hours, as I stood in the line at the Bucharest prefecture for getting new licence plates after one of them fell down, I had a single word throbbing in my head like a bad headache: decay.

You see, I went there,in Pipera, near the Oracle offices, only half a year ago and I was amazed of the apparent efficiency of the place. You would go and ask at the Information desk on the proper procedure to solve your particular problem, you would take an order number and you would wait until an electronic display would show your number. You could see that the current number is 1 and that it changes every ten minutes or so, so if you have number 20 you have to return in approximately three hours. The building was new, large, with a lot of parking spaces, lit up inside, with clean toilets; in short everything you would want of a governmental building. I then thought: "Belonging to this European Union thing has its perks". The only problem were these peddlers waiting outside the offices, trying to sell you stuff like covers for documents or supports for licence plates. It reminded one you were in Romania.

This time, the electronic displays were dead. The chairs that were in the hallways for people to sit on where mostly broken, and not because of some sort of vandalism, they were just so badly designed that after sitting on them a few times, their backs would bend. Trying to right them back would strain the metal so in the end they would just fall. Half of the neon lights were defective. The male bathroom was just closed and if you wanted to wash your hands or whatever a written sign would direct you to the first floor. The functionaries, never an example of enthusiasm, managed to look even more despondent and despaired at their job. People would stand in long queues, the old Romanian system, waiting for hours to get to one of the few desks that were occupied in order to sign a few papers. The sound system, that was previously used to announce important messages, was now spewing music from a local radio station. At one time, one of the usual announcements also came out of the speakers, but at a lower volume than the music, so you wouldn't understand anything. A woman in the line got sick and went to sit down. Or she just swindled us in order to keep her spot while not standing in the line.

And thus I have wasted three hours and a half there for a signature and two new licence plates. When I got out of the building a female peddler asked me if I wanted covers for my documents. I said no, and she wished me a nice day. I bought a licence plate support from a guy, happy that I didn't have to go somewhere else for one. He even offered to install it for me, but I did it with my wife, like a couple thing.

In the end, the peddlers were the consistent and efficient ones, being even polite while they serviced you, waiting for people to buy their stuff in order to earn a few euros per day.

Thursday, September 13, 2012

Games People Play, by Eric Berne

Book coverGames People Play: The Psychology of Human Relationships is a sort of summarization of previous works by Eric Berne, the "father" of Transactional Analysis. It was written in 1964, but it is very actual (barring some author views that could be construed as not politically correct in this age of sensitivity). In fact it felt to me so to the point, that I am asking myself how come I've never heard of this book before.

The idea of the book is that all people are torn between their three major components:
  • the Parent - exponent of the social environment, things that "are done" in the "proper" way
  • the Adult - who reacts to the circumstances as they change
  • the Child - the emotional being who craves satisfaction and enjoys life the most
As I see it, is a separation in things one learns from others, things one thinks for themselves and things one likes or dislikes. At the end of the book the author resorts to a similar division: the Jerk, the one that does everything based on what others would think of them, and the Sulk, the one that does everything in order to demonstrate to themselves and others that they are being mistreated by the world and they are justified in their feelings, similar to the Parent and the Child.

Then there is a presentation of Transactional Analysis, an area of psychology that feels more like economics applied to human beings, where people do things in order to settle debts or gain profit. A nice example is two people that work together and say "hi" to each other in passing whenever they meet first in the day. This is equivalent to settling a debt that each have for their level of relationship. If one of them fails to say "hi", the other will feel attacked, just as if one of the two would stop and say "well, hello! How are you?" which would also feel like an attack, one that indebts the other. These transactions are being categorized into simple transactions, pasttimes, etc.

But then the interesting part comes up. It is funny, I felt for the entire length of the read that the chapters are in the reverse order. Each chapter was more to the point and more interesting than the first. I would have organized the book starting from the introduction, then reversing the remaining chapters. The interesting part is about games, which seem like normal transactions, only they have an alternate "tricky" purpose, one that is not obvious to both people in the transaction.

Quite annoyingly, many of the games described in the book apply to the reader. One feels exposed while reading it. With a structured list of these games, one can use the book as a reference to be used for further study. Each game is presented with their purpose, their "thesis" or pretext and expectations, their actors and their "antithesis". A clear warning is sent by Berne, though: the antithesis of a game is just a way to shortcircuit it and refuse to play, not a "solution" for the problems raised by the playing of said game. Indeed, when faced with a person that refuses to play or, worse, blocks their own playing of the game, they become anxious, depressed, maybe violent, depending on how "hard" they play the game.

An interesting ending is the listing of the reasons why games exist from different standpoints: social, personal, emotional, etc. The games are learned and, in that sense, inherited from parents, then from the environment. People that play the same games stick together and people that play different games are growing apart. That pretty much explains why people that come from the same settings get to have the same social standings and work and live in the same world. Sadly, it also explains why social cases need to make enormous efforts to be accepted, to "make it".

Also, the author presents his view of the best psychological mindset, the one he calls Autonomy. It requires three ingredients: Awareness, to be able to see your surroundings as they are, not as you were taught to; Spontaneity, to be able to have access to your own thoughts, unfiltered by other mechanisms; Intimacy, to be able to share what you are, as you are. A kind of a Zen philosophy. He reckons anything less is not quite living, but only going through the motions. I am not sure how I feel about this, right now.

For me, the book was very interesting. In truth, I should reread it, or at least summarize it into a logical schema that I would add to this post. I am not sure I will do that, but I intend to. Afterwards, I would use it as a tool for introspection and for analyzing my interactions with others. Yes, but...

Monday, September 03, 2012

TV Series I've Been Watching - Part 12

Another post in my series of series I've been watching. Seriesly.

Again, since it is obvious that I am also watching shows I don't particularly like, I will employ this colour coding scheme: red for shows I do not recommend, green for those I like.

  • Doctor Who - the first episode of season 7 was released. An interesting concept, but a rather unpleasant implementation. The writers chose to throw us directly in the midst of action and I felt there was no background and everything was disconnected. I do hope for the better.
  • Torchwood - the next season of the other Doctor Who spin-off has not started yet. I don't even know if will ever start. I would watch it then.
  • Eureka - Eureka has ended. A pretty weird finale, trying to save everything, give the show a chance for the future and also tie it to its very beginning.
  • Criminal Minds - a lot of episodes remain to be watched, two seasons worth, but I couldn't make myself watch them. I think I've had my fill of police procedurals for a while.
  • Dexter - I can't wait for the seventh season. Dexter's sister knows! It will be exciting, although I don't want another of those "Dexter is a daddy and he has a conscience" seasons.
  • Fringe - there was one episode where the Observers had conquered Earth and were behaving like good old fashioned Nazis (oh, come on! Where is your creativity?!) but it ended just as it started, out of context. The latest season of Fringe ended with hints that this is the direction the next season will take. I certainly don't want yet another WWII movie clone.
  • True Blood - season 5 just ended and it was pretty fun. There were a lot of boring episodes concerning the vampire authority that just didn't make sense and some other filler episodes, but all in all it was consistent with previous quality. Bill has become a super vamp, only he's nuts! Cool!
  • Weeds - the series has not ended yet and I am still watching it. I get tired of the American affectations of the show; I think that bothers me most about it. And the story has become unsaveable. And the lead character is seven years older than the hot MILF she started as. But I am still watching... hmm
  • The Good Wife - season 3 ended well. Unfortunately, Tony Scott died, too. I hope that doesn't affect the quality of the show. Season 4 is due to start at the end of the month.
  • Haven - season 3 of Haven is also to start at the end of the month. I will probably watch it, since I can do it with my wife, but the show has gotten stale.
  • Lost Girl - haven't watched this show for a while, even if I have a lot of episodes to see. I know it is a teenager show, but some of them work for me, too. This was too... Twittery?
  • Falling Skies - second season was OK. It's sci-fi, so I watch it, but the script doesn't make sense most of the time. A new alien species has arrived for season 3. Are they allies or foes? Or has Pamela dreamed again?
  • Southpark - the second half of the 16th season is due in October. It is one of the few comedy shows I watch and I really like it. The humour quality is not consistent, but it is great on average.
  • The Killing - still on my watch list, being a police show and all.
  • Suits - second season just ended and it was pretty far fetched.I enjoy watching it, though.
  • Breaking Bad - I have decided I will watch BB when this fifth and final season ends. I don't know why I couldn't bring myself to watch the last two seasons. Maybe because the main character is so desperate when he actually doesn't need to be.
  • Californication - the fifth season was pretty cool and it ended with Hank being poisoned. Will he survive? Doh!
  • Beavis&Butt-head - I am waiting to see if they make any more episodes. I was disappointed with the new episodes.
  • Homeland - still on my to watch list, mainly because my wife was watching it with me and she doesn't want to watch it now, but I bet she would mind if I watch it alone. And also I didn't feel like it much.
  • The Fades - BBC Three fucked up badly. They cancelled the show in favour of Being Human's fifth season. You see, it has vampires and werewolves in it. Wankers!
  • Hidden - Four episode miniseries from the BBC about the dirtyworks of the British political system. Still haven't watched it.
  • The Walking Dead - I am still watching it, and the new season seems to introduce a real threat: other live humans. Makes sense, but how nice can it be, after the emotional drama crap they pulled last season?
  • A Game of Thrones - The show is moving so fast, they had to change the story a little. At every episode I get to hear "Oy! that wasn't in the book!" from the wife. Of course it wasn't, dear, it had no pictures! Mean jokes aside, the show is solid, but better for those not having read the books.
  • Awake - I didn't start watching it an meanwhile it was cancelled. I have no idea if I will ever watch that lone season.
  • Black Mirror - it was brilliant. Three separate sci-fi stories in three stand alone episodes, but high quality stuff. I hope the Brits make more.
  • Boss - season 2 has started and I haven't seen one episode.
  • Great Expectations - three episodes in all, another take on the Great Expectations story. I thought the wife would want to watch it, but she did not. I don't think I will watch it alone and, anyway, it's not really a TV series, more like a three part movie.
  • L5 - the second episode of this VODO show still hasn't been released. I wonder if they will ever do release it. I liked the first one.
  • Mad Men - still great, I've watched the fifth season and can't wait to see the sixth. Jared Harris has left the show, and I really liked him and his character.
  • Misfits - next season is expected to start in late October. I wonder why so many of its stars left the show, but the show still goes on.
  • Pioneer One - I have no idea if there will ever be a second season. It seems they have gone dark, while on the site there is a request for funding for a new show, called Control.
  • Sherlock - I liked the first series and I will watch the second. The American's thought it was good, too, since they are making their own version, with Lucy Liu as Watson :)
  • Spartacus - Vengeance - I like the show. Seeing that the story of Spartacus is so vast, I had expected a few seasons of this. However, it was announced that the next season (called War of the Damned) will wrap up everything and end the show. Why?!
  • The River - horror TV show that I didn't watch, mainly because it was cancelled after the first season. I still might.
  • Todd and the Book of Pure Evil - I liked the first season, but then it got a little old. The show was cancelled after the first two seasons.
  • Touch - I have watched a few episodes of this. I can say that I did not like it. Keifer Sutherland is always out of breath in order to "act" emotion, but all he manages to do is make one wonder if he has a lung condition. The child is annoying. The story is, basically, that the child is magic and the people around him "help" him ... err... be magic? Only it's not magic, it's math, patterns and cell phones. Really.

Now for new shows:
  • My Babysitter's a Vampire - Another Canadian fantasy comedy show. And it's better than Todd and the Book of Pure Evil! Well, it's basically True Blood in a high school and made for children and young teens. But I like it! Guilty pleasure. The blonde vampire chick is hot, too.
  • Bullet in the Face - what a strange show. It's grotesquely bad acted, but in a way that makes you think they intended it like this and you are missing some kind of point. The plot revolves around a psychotic killer that gets to wear the face of the cop he killed in order to get revenge on his girlfriend who shot him in the face. It would be unconscionable to recommend it, but I watched two episodes. anyway.
  • Continuum - A sci-fi show! Yay! With cops! Boo! Actually, the premise is pretty interesting and the lead actress hot. But it feels like a police procedural either way, which sucks. The plot is that a bunch of future terrorists and a cop are teleported back to our times. The terrorists terrorize, while the cop tries to catch them. Only some of the twists and some of the scripts are painfully bad. I watch it, since it's sci-fi, but it hurts a little.
  • Copper - a BBC America drama about Irish immigrants during the American civil war. And set in New York (where else?). Have not started watching it, yet, but it's fresh.
  • Longmire - another show about a cop. Only it doesn't feel that way. I actually look forward to the episodes of Longmire. The show is about a small town sheriff and it is based on actual books (you know, paper things with letters on it). The actors play well, the stories are good and the first season had only 10 episodes, so they each were good quality.
  • Perception - another House/LieToMe clone, with this intelligent and charismatic, yet weird and rude, professor that specialises in human perception. And he helps the police solve cases. Bleah!
  • Political Animals - this is a pretty neat show, even if it is about American politics seen from within a family that is filled with political people. It is not always exciting, but I like watching it, for now.
  • Scandal - political thriller made by the people behind Grey's Anatomy. I haven't started watching it.
  • The Newsroom - this is one of those shows that decries some aspect of American life by showing us there are exceptions to the rule, which invalidates the rule and makes us all feel good. In Romania we have this saying that the exception confirms the rule, so... Anyway, it is about unconventional people working to make "real news" and fighting corporate interests that push them to do crappy popular bullshit in order to gain ratings. People are very smart, quick, socially inept, endearing, quoting statistics and old English poetry and totally fake.

That ends this post. How much time am I wasting in order to watch all these shows? Well, it took me an hour and a half just to write about it, so you do the math.