and has 0 comments
We live now in a world where people get the same education, see the same movies, read the same books - if at all. We then watch the ones around us and see only ourselves and we get bored. That is why, I believe, we start to see various mental illnesses or strange behaviours as interesting. That is why, I think, The Drowning Girl, by Caitlín R. Kiernan has received so wonderful reviews.

That doesn't mean the book is not brilliant. Kiernan paints the world as seen from the eyes of a lesbian paranoid schizophrenic, combining ideas from paintings, old legends and written stories into a whirlpool of staggering creativity. However, I do have to wonder, would the book have received the same amount of positive reviews if the main character was a straight man?

All that aside, I have tried to keep an open mind when reading the book and I have found that the way the author mingles stories and goes back and forth, keeping the reader on their tows, is both excellent and terribly irritating. It builds up a lot of tension that needs to be released into a grand finale. However, the climax of the book seemed to me to be somewhere in the middle, with the ending lagging and wasting into pointless mental delusions.

It is hard for me to recommend or not recommend this book. It is clearly well written and very inspired. It not only delightfully weird, but also draws information and data from all kinds of art fields and mingles them together in an interesting way. The construction of the book aside, though, leaves a plot that doesn't really mean anything. It's the maelstrom of thoughts and feelings of a mentally troubled person with a slight mystical component which, even till the end, is not really clear if it is only in her mind or has some factual truth.

I did enjoy one thing, though, the idea that something can be "true", but not "factual". If you think about it, it makes sense, but usually words like "truth" hold an objective mask on them, when most of the uses of those words are actually subjective. Yep, it's true :) I also liked the way details about the artists led to connections to other works and facts, that a thorough analysis of art can show hidden worlds and interesting perspectives.

As a conclusion, what leapt into mind when trying to find a book that is similar to this was Geek Love, by Katherine Dunn. In a word: freaky. The Drowning Girl is much more interesting, though, and doesn't try so hard to shock with the character's sexuality or personal weirdness. But in the end, having read it, I felt like it said nothing. An interesting journey towards nowhere in particular.

We all know that the best way to prevent SQL injection is to use parameters, either in stored procedures or in parameterized queries. Yet on some occasions we meet code that replaces every single quote with two single quotes. The question arises: OK, it's ugly, but isn't it enough?

I have recently found out of something called "Unicode Smuggling" which uses the database against itself to bypass protection as described above. More details here: SQL Smuggling , but the basic idea is this: if the replacement scheme is implemented in the database and uses VARCHAR or maybe the code uses some non-unicode string, then the protection is vulnerable to this by leveraging what is known as Unicode Homoglyphs. If you feel adventurous and want to examine thoroughly the ways Unicode can be used maliciously, check out UTR#36.

Here is an example:
CREATE PROC UpdateMyTable
@newtitle NVARCHAR(100)
AS
/*
Double up any single quotes
*/
SET @newtitle = REPLACE(@newtitle, '''','''''')

DECLARE @UpdateStatement VARCHAR(MAX)

SET @UpdateStatement = 'UPDATE myTable SET title=''' + @newtitle + ''''

EXEC(@UpdateStatement)

Note the use of VARCHAR as the type of @UpdateStatement. This procedure receives a string, doubles all single quotes, then creates an SQL string that then is executed. This procedure would be vulnerable to this:
EXEC UpdateMyTable N'ʼ;DROP TABLE myTable--'

The first character in the provided string is not a single quote, but the Unicode character U+02BC . SQL will silently convert this into a single quote when stored in a VARCHAR. The injection will work.

Small demo in MS-SQL:
DECLARE @nhack NVARCHAR(100) = N'ʼ;DROP TABLE myTable--'
DECLARE @hack VARCHAR(100) = N'ʼ;DROP TABLE myTable--'
SELECT UNICODE(@nhack),UNICODE(@hack) -- Results: 700 39

More discussing this here: Can I protect against SQL Injection by escaping single-quote and surrounding user input with single-quotes?

I've often encountered this situation: a stored procedure needs to display a list of records ordered by a dynamic parameter. In Transact SQL, the Microsoft SQL server, one cannot do this elegantly in any way. I will list them all and tell you what the problem with each is.

First of all, let's start with an example. Assume we have a table called Test with a lot of rows, which has a datetime column which has an index on it. Let's call that TheDate to avoid any SQL keywords. We want to do something like this:
SELECT TOP 10 * FROM Test ORDER BY TheDate ASC

Notice that I want to get the top 10 rows, which means I only need a small part of the total. I also order directly by TheDate. In order to release a piece of code we also need to test it for performance issues. Let's look at the execution plan:


Now, let's try to order it dynamically on a string parameter which determines the type of the sort:
SELECT TOP 10 * FROM Test ORDER BY CASE WHEN @sort='ASC' THEN TheDate END ASC, TheDate DESC

As you see, I've used CASE to determine the sort order. There is no option to give a parameter as the sort order. The execution plan is this:


Surprise! The execution plan for the second query shows it is ten times slower. What actually happens is that the entire table is sorted by the case expression in a intermediate table result, then 10 items are extracted from it.

There must be a solution, you think, and here is an ingenious one:
DECLARE @intSort INT = CASE WHEN @sort='ASC' THEN 1 ELSE -1 END
SELECT TOP 10 * FROM Test ORDER BY CAST(TheDate AS FLOAT)*@intSort ASC

I transform the datetime value into a float and then I use a mathematical expression on it, multiplying it with 1 or -1. It is the simplest expression possible under the circumstances. The execution plan is:


Bottom line, there is no exception to the rule: when you order by an expression, SQL Server does not use indexes, even if the expression is easily decompilable. Don't get mislead by the apparent functional programming style of SQL syntax. It doesn't really optimize the execution plan in that way.. Even if the column is an integer, it will not work. Ordering by TheInteger is fundamentally faster than ordering by -TheInteger.

And now the solution, ugly as it may be (imagine the select is a large one, with joins and where conditions):
IF @sort='ASC' 
BEGIN
SELECT TOP 10 * FROM Test ORDER BY TheDate ASC
END
ELSE
BEGIN
SELECT TOP 10 * FROM Test ORDER BY TheDate DESC
END

Yes, the dreaded duplication of code. But the execution plans are now equivalent: 50%/50%.

This post was inspired by real events, where the production SQL server went into overdrive trying to create and manage many temporary result tables from a stored procedure that wanted to avoid duplication using the CASE method.

Update: there is, of course, another option: creating an SQL string in the stored procedure that is dynamically modified based on the sort parameter, then the SQL executed. But I really dislike that method, for many reasons.

More information from another blogger: Conditional Order By. They also explore rank using windows functions and in one of the comments there is a reference to SQL 2008 "Grouping Sets" which I have not covered yet.

and has 0 comments
You know the format, let's get this out of the way. First, the series I've already been talking about:



  • Doctor Who - a weird Christmas special introduced another companion. She is cute and perky and doesn't take commands well. Also, she dies twice already. It doesn't seem to stop her.
  • Torchwood - no Christmas special and no news on a fifth season. I wonder if it will ever reappear.
  • Criminal Minds - still on hold, but not totally rejected yet.
  • Dexter - A weird seventh season sees Dexter in love, running away from mobsters and being helped by his police sergeant to cover up kills or even commit them. Then it all ended in a ridiculous fashion. Hint: watch Dexter's face when Deb jumps at the recently shot person in the last episode: it seems to say That is NOT how this is done! Stop it, just stooop!
  • Fringe - Fringe is not better. I still watch it in order to avoid sci-fi withdrawal symptoms.
  • True Blood - I can't wait for season 6. I do fear for its quality, but I also have high hopes.
  • Weeds - the series has ended, finally, when all life has been squeezed out of it. I am glad it is over.
  • The Good Wife - season 4 is running strong... ish. There are some new ideas introduced in the show that don't really fit well or seem to be needed in the picture, like Kalinda's husband.
  • Haven - season 3 of Haven pits Audrey against a killer that takes people's skins. And she is also to disappear on a certain date in order to stop the troubles. And she is also courted by two guys who are insanely in love with her. What is a girl to do?
  • Lost Girl - removed from my watching list.
  • Falling Skies - season three has not started yet. I am curious how it will continue. Plus it's sci-fi.
  • Southpark - some funny episodes in the October batch. Could have been better. Still good.
  • The Killing - still on my watch list, being a police show and all.
  • Suits - third season is about to start. It doesn't make much sense, but I like it.
  • Breaking Bad - the fifth season has ended and there will not be a sixth. Still haven't had the inclination to watch it.
  • Californication - the sisth season is about to begin. I can't wait.
  • Beavis&Butt-head - It seems the show was quietly axed. I haven't heard anything about it for a long time.
  • Homeland - I've seen two seasons of Homeland and it's pretty cool. Claire Danes is a bipolar CIA agent that fights to prove an American soldier rescued from the Talibans has been turned. She is also in love with him. Not much sense when you put it that way, but a lot of tension. The show is another American adaptation from an Israeli show.
  • The Walking Dead - pretty hard stuff added this season, making it interesting again. Some characters even die! Almost got to "want" status.
  • Game of Thrones - the show follows the books faithfully, even when removing some bits or rearranging others. However I feel it failed to fully capture the atmosphere of the book. We'll see how it goes.
  • L5 - no second episode for a long time now and with the current economic climate, I doubt it will continue. Too bad.
  • Mad Men - season six is to premier in 2013. I will keep watching it, because it is just great.
  • Misfits - all new characters in Misfits, with some stories interesting, but now more towards shocking and/or disgusting. I've removed the "want" status from it, because the quality of the show is not as great as when it started.
  • Sherlock - the third season of the series will begin probably late 2013. I liked it, even if a bit too... Moffaty? I really don't want to see more and more people acting like Doctor Who. One is enough.
  • Spartacus - Vengeance - War of the Damned will start soon, in January. Too bad it ends the show, but then again, maybe it will be something meaningful and slim, without boring filler episodes.
  • My Babysitter's a Vampire - vampire teens, with seer and wizard friends and fighting against the evil in their highschool? It's silly, but at least it knows it is silly. I watch it because it is easy fun.
  • Continuum - a second season has been confirmed, but I don't know when it will start. Rather boring, but sci-fi, you know.
  • Copper - a BBC America drama about Irish immigrants set "Five Points". I really liked it, with its depiction of rampant corruption and racism and classism at the beginnings of the city of New York.
  • Longmire - a second season has been confirmed. I really like the show, even if about a rural cop in the middle of nowhere.
  • Political Animals - it feels interesting and profound, but it is not really so. The impression is strong, though, and I may still had watched it if it weren't cancelled.
  • The Newsroom - my wife loves this. I will watch the second season, but I can't decide if I like it or not.

And now for new shows:

  • 666 Park Avenue - A show about the devil! I haven't started watching it, and it was cancelled already.
  • A Young Doctor's Notebook - This is not really a series, but a mini series. Four episodes, each 20 minute long, about a Russian freshly graduated doctor coming to work in a really remote village. The show is brutal and funny at the same time. I doubt there will be a second season, but this one is worth it. Starring John Hamm and Daniel Radcliff.
  • Arrow - I watch this, even if I don't really know why. It is yet another superhero series where the main strength of the guy is that he shoots arrows. I can't recommend it.
  • Beauty and the Beast - Incredibly beautiful people acting as both beauty and beast in this ridiculous show that attempts to place the story in modern times. The beauty is, obviously, a cop.
  • Blackout - God know I tried to like this show about political and personal corruption in England, but I couldn't. It starts bleak and intense, but quickly devolves into the surreal.
  • Battlestar Galactica - Blood and Chrome - so far William Adama is introduced as a young and cocky pilot in a series of webisodes. The show has everything I loved about the first two seasons of BSG 2004. I can't wait for more.
  • Elementary - the American Sherlock doesn't look or feel at all like a Sherlock. Instead it looks and feels exactly like so many US shows about gifted people helping the police. I still watch it, but the show is really not what it should have been.
  • Emily Owens M.D. - I was caught into one of those times when one wants to see a true doctor show, with actual cases and medical dilemmas. No. Instead this crappy show seems like the poor brother of Gray's Anatomy, with those silly happy songs in the background whenever the female protagonist speaks with other women that are not her evil boss or highschool nemesis (I am not kidding, they added the highschool nemesis thing)
  • Hatfields and McCoys - This American Civil War miniseries was filmed in Romania and stars Kevin Costner. I really wanted to see it, but didn't get around to it, yet.
  • Hit and Miss - A new show I really know nothing about. Six episodes so far.
  • Hunted - Oh, Melissa George as a secret undercover agent (and I do mean undercover). Beautiful, smart, trained to kill and yet fragile as a woman, she leads the show well until... it is put on hold! BBC really screwed up abandoning this show. Cinemax is in negotiations to continue doing it, in collaboration with BBC. Fingers crossed.
  • Last Resort - The show started really well. An American submarine is ordered to nuke Pakistan, but through a secondary network. They request that the order be sent via the primary network, and they are shot upon. They manage to escape and hold fort on a remote island, threatening to launch on any country that even approaches the island. A great premise with very good actors. Unfortunately, the show started to lag a little, then suddenly was cancelled. I would like to believe that it was a nerve they touched with the script, but more likely there are too many stupid people deciding to watch reality shows instead.
  • Made in Jersey - they tried to make "Working Girl" a series, with a New Jersey girl, no less, making it as a lawyer in the big city. It was a complete flop and it was quickly cancelled.
  • Parade's End - another miniseries. The trailer looks really promising and I haven't read the book. As soon as I watch it you will know.
  • Primeval - New World - I can't really say I don't want to see it. It is the American continuation or spin off from the British Primeval show. But it just feels bad in every way, even if Zane from Eureka stars as the lead character.
  • Restless - a miniseries. A young woman finds out that her mother worked as a spy for the British Secret Service during World War II and has been on the run ever since. The synopsis sounds interesting. Two episodes so far, that I have yet to watch.
  • Revolution - can you imagine a sci-fi show that I refused to watch? This is a horrible show, something that combines Xena with Flash Forward. Yes, it is possible. And it sucks!
  • Ripper Street - this is not yet another Jack the Ripper show, instead it is set just after the killings stopped. A bit like Copper, with the police force of the time solving gruesome murders. Haven't got around to watch it, but it might be nice.
  • Secret State - a British miniseries starring Gabriel Byrne. Four episodes, rather captivating, but lacking a proper resolution. Not to mention a happy ending, which British seem to avoid completely :)
  • The Fear - A Brighton crime boss turns entrepreneur and then he goes crazy. Like mentally ill crazy. I haven't started watching this miniseries, but it might be interesting.
  • The Mob Doctor - another promising series that gets cancelled for no good reason. This doctor woman is forced to work for the mod in order to get her younger brother out of debt. She is a brilliant doctor and she has to jumble her official cases with the off the ledger ones. Really interesting, even if a bit bland.
  • Transporter - they decided to do a Transporter series. I couldn't get through half of the first episode. Everything that Jason Statham did well in the show, the ridiculous and pompous ass they placed as a lead did wrong. Every good redeeming quality of a movie that, let's face it, wasn't that great is lacking here. Avoid this waster of time!
  • Vegas - Well, if we have to watch series about cops, at least let them be good ones. Vegas is a good alternative to Longmire, with the action set in the early years of Las Vegas where a farmer and former MP gets to become the sheriff of the town. Interpreted by Dennis Quaid, his character and the local mobster, also well interpreted by Michael Chiklis, make this series interesting and worth watching.
  • Wizards versus Aliens - OK, go ahead: laugh! I did watch a TV series made exclusively for young children where a family of wizards fights a ship of evil aliens set to consume every bit of magic in the galaxy. It is an alternative to The Sarah Jane Adventures, only even sillier. I had fun.

There are several miniseries and shows that just arrived on my radar. No point in discussing something I know nothing about, yet. So far a lot of the shows I loved were cancelled, while stinking refuse of TV series thrive. I am almost to the point of not caring anymore. I hope my short list (yes, I was humblebragging) will help you decide which shows to watch or not watch.

Until the next post in the series about series!

and has 0 comments
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.

and has 0 comments
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
considering.})

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
pawns!})

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
correctly.}

(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
protected.})

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
advantage.}

(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
lost.})

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.

Enjoy!

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.

and has 0 comments



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.

and has 0 comments
I 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.

and has 0 comments
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.

and has 0 comments
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. ;)

and has 0 comments
It has been a while since I've posted music here. The performer is Lindsey Stirling and today is the first time I've heard of her, but I like her stuff. She is a pop violinist akin to Emilie Autumn, but not as dark. Here is the clip for Phantom of the Opera, 7 minutes long and very nice.

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.

and has 1 comment
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.

and has 0 comments
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?