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.