and has 0 comments

  A while ago I had this story idea about a certain population that has something special that all others want and that they desperately need to consume. It's the exact premise of The Marrow Thieves, and the population in question is native Americans.

  Now, Cherie Dimaline is Métis herself, so I must trust that she knows what she is talking about, but from my standpoint, all the clichés I thought were stupid about American Indians are right there. It's like people have heard them so many times they started believing them. I am talking about calling themselves Indians, I am talking about the wise old man and wise old woman that guide (through restrictions of both knowledge and permission) young energetic youths, also the non violent Indian that knows responding to violence with violence makes him like the White man, the bow and arrow Indians - although they live in Canada, so who knows, the native people that are in harmony with nature, the betraying Indian - but only because of substance abuse, something the West has brought on them, and so on.

  In short, the book says "please take whatever you want from us, because we are nice, non violent and in harmony with everything. Even if we will eventually fight back, it will be only after we've been thoroughly defeated, humiliated and destroyed as a people". It's hard to empathise with such a moral for the story. I understand it was all mostly metaphor, but still.

  Bottom line: it was OK, but wouldn't recommend it.

and has 0 comments

  The reviews for this book are great and most of them say three things: it was inspired by the 1987 movie Near Dark, it has a different - realistic - take on werewolves and it's a coming of age story. As such, the main character in Mongrels is a boy that lives in a family of werewolves: people that occasionally turn into wolf like creatures, but that brings few advantages and a lot of trouble. Not only are their instincts frustrating in a human society, but turning takes a lot of energy and turning back pulls anything in the fur inside the skin of the human shape: ticks, elastic materials and as wolves they age with the speed of dogs. Since they can't adapt to the normal human way of life, they live on its fringes, as a family of white trash Americans. They steal, they scavenge, they kill animals whenever it doesn't get too suspicious, they move a lot and they are always poor.

  I can't say the book is badly written, but it's the equivalent of, I don't know, werewolf Kenny from Southpark. It's depressing, it's gray, it tries too much to make a social commentary by using the werewolf thing as a gimmick. Yes, it's a fresh take on the mythos, but it's a boring one. It certainly is not a horror book and too little of it is fantastic in nature. Instead it's the story of this boy trying to make up his mind if he is a wolf or a man. It could have just as well been a story about homeless gypsies, without any of the wolf thing, and it would have been the same.

  Bottom line: Stephen Graham Jones is clearly a good writer, but in this case he just wrote a smart book... about werewolves. And Near Dark was way better!

and has 0 comments

  Disclaimer: this is a Romanian book and I personally know the author.

  The book is a journey of a woman, starting from an 18 year old ingenue and ending as a mother and a wife considering her life choices. Perhaps ending is not the right word, since "the game" is about the journey, rather than a specific destination, and the character's story continues after the finale of the book. Split into three narrative flows, the story quickly switches between inner thoughts and external events, fantastical fairy tale concepts and their emotional connections to the character's real life.

  I started reading with dread. It's about women. They're crazy, right? And various sources, that I was actually trying to avoid in fear of spoiling the book, were whispering things that ranged from teenage sex scenes to dramatic philosophical musings. And it was all correct, only I actually liked the book. What I think happened is that it fell under the category of autobiographies, a genre that I am appreciating a lot as it opens my eyes to how other people see the world.

  Em Madara is taking pieces of her soul and crafts a dramatized version of life where she examines her life choices, but also goes further, taking the stratospheric view of people being possible versions of a single identity that they don't remember, of all life teetering between light and darkness, life or death, pleasure and pain, left or right, a choice and another.

  In Hide and Seek (the English translated title) you get hormonal infatuation, self destructive behaviors, temptations and hard personal choices, family drama, love for children, animals or life in general, self exploration, but also Daoist philosophy, Romanian, German and Russian folklore, movie, music and literary references, all bits and pieces of a mosaic that, in the end (Ende is goal in German), make up a single person.

  All in all, a solid novel and a very good beginning for a new writer.

and has 0 comments

   Has it been so long? It feels only yesterday I was reading Contagious, the second book in the Infected trilogy, and intending to read the third one. Now, more than ten years later, here I am finally finishing it. And it was pretty cool. I mean, it's no literary masterpiece, but it presents a consistent sci-fi future, compelling characters, action packed scenes, scientific accuracy. There was love put in this. Sometimes you just want to read something and not overthink it, like watching a blockbuster movie. And sometimes I wonder what do those people think when making those movies: Infected is much more interesting of a material. How come they don't make a series or film based on it?

  Anyway, as the title suggests, Pandemic sees the whole world in the grips of the alien contagion, with the same actors trying to save it. And as in the first two books, Scott Sigler mixes some great scenes with some really corny ones, some great human insight with silly lines like "Run to the chopper", "I'm getting to old for this shit!" or befuddling ones like "Seeing an American citizen being roast to a spit does that to someone". Too bad he was American, right? I have to say that most of the horror in this book comes more from the stupid decision top brass makes, rather than from the effects of the contagion. In the end, the brave souls on the ground save the day. The ending is epic and brings closure... up to the moment Sigler thanks people for carefully advising him about consistency in the 800 year spanning Sigleverse. Ugh! Sigleverse? Really? 800 years? Meaning I have to read more of this stuff to satisfy the completionist in me? Why did I have to read the Acknowledgements?

  Bottom line: action packed sci-fi horror alien invasion flick, split in three books. It is nothing if not enjoyable.

As you possibly know, I am sending automated Tweets whenever I am writing a new blog post, containing the URL of the post. And since I've changed the blog engine, I was always seeing the Twitter card associated with the URL having the same image, the blog tile. So I made changes to display a separate image for each post, by populating the og:image meta property. It didn't work. The Twitter card now refused to show the image. And it was all because the URL I was using was relative to the blog site.

First of all, in order to test how a URL will look in Twitter, use the Twitter Card validator. Second, the Open Graph doesn't specify that the URL in og:image should be absolute, but in practice both Twitter and Facebook expect it to be.

So whenever populating Open Graph meta tags with URLs, make sure they are absolute, not relative.

and has 0 comments

  Nice of the two authors pen-named James S.A. Corey to publish a novella to assuage the thirst for a new The Expanse novel. Auberon is pretty good, but on a human level, rather than on a science-fiction one. You could imagine the same story in a French or Belgian colony in Africa with minimal changes.

  The main focus is on the new Laconian governor of planet Auberon, arriving all smart and proud as the almighty representative of a regime that is rooted in discipline at all levels. Can he keep that up? No plan survives contact with the enemy, but how will things change?

  Bottom line: short, fresh, easy to empathize characters. A win.

and has 0 comments

I've changed a little the way the blog is being displayed. Now posts should present a more specific image than the general blog icon and the list of posts should display an image and then text, regardless of what is in the post. Let me know if anything goes awry.

and has 0 comments

  So I am reading this book about a Black gay man called Saeed, living in the American South and having a Christian grandmother and a Buddhist single mother and it doesn't bother me. It's personal, it's well written, it's real. It doesn't feel agenda driven, it doesn't make me feel guilty about not being Black or gay myself, it makes me feel close to the character/author. It's honest. We need more of this and less of *that*, you know what I mean and you know who you are.

  In this context, the title How We Fight for Our Lives might be a little misleading. While Saeed Jones does talk about the constant fear of being hurt, from the damning official pronouncements that hint you will die of AIDS if you are gay, to the racist or homophobic murders in the US, he describes his life rather than his worries. He is never truly assaulted or reviled. One understands how strong the concept of family is in his culture when you see how connected and even deferential he is to his mother and grandmother, even if his family is nothing if not uncommon. When he spends time with his grandmother, she takes him to Christian church, where everybody is aghast hearing that Saeed's mother is a Buddhist. When he spends time with his mother he goes to Buddhist temple and chants stuff. The author doesn't present this as an inconsistency, other than in the eyes of his grandma. The moment she realizes he is gay, her reaction is "No, no, no, no!" which is both terrifying and laughably ridiculous, depending on which side of history you feel you are.

  This is a short book. It is not something amazing, but I liked it. I liked how personal it felt, I liked that the author would focus on his thoughts and feelings, his literary heritage, his own person, rather than some mythical racial or gay social identity. I appreciated describing the sex scenes together with the conflicting feelings and thoughts he had about his encounters: part defiance, part shame, part longing, part hope. It must have been hard to describe his love for his mother and yet they kept each other at emotional distance and when she died, it was way too soon and with so many things unsaid.

  "I am a person! I am real!", Saeed Jones shouts with this book, and I feel I heard him.

and has 0 comments

When do children lose their rubbernecked quality? asks Scott Richard Shaw when talking about little children fascinated by bugs. It's a valid question for him, because Planet of the Bugs feels like a an eight year old in a toy store, switching attention from toy to another without purpose or sense, talking excitedly about each of them randomly and abandoning them in the middle of the story to start telling another.

It's not like the content of the book doesn't have the potential to be interesting, the author went to a lot of places and read a lot of material, as an enthusiast does, but with absolutely no narrative thread and no structure to the chapters, Planet of the Bugs serves neither as an anecdotal journey in the world of insects and spiders and the like, nor as a possible reference piece. I mean, even Shaw's reason to get into arthropods feels like a boring version of the Spiderman origin story. I am paraphrasing here: "One day I stumbled upon a bug and from then on I was hooked. It was a hook beetle, you see!".

Bottom line: I really wanted to like this book, but it was just not well written.

and has 0 comments

Recently I found out about custom task schedulers and I wanted to blog about all the wonderful things you can do with them. I also imagined new ways of doing await/async by tweaking task schedulers. After hours of attempts, I've come to the conclusion that custom task schedulers are incompatible with await/async and should not be used. Here is why:

  • a task scheduler is used to execute synchronous code inside tasks while async/await code is already asynchronous
  • while async/await code is transformed by the compiler into a state machine with the code that follows being turned into a task that is scheduled on TaskScheduler.Current, the state machine has nothing to do with the task scheduler (see Dissecting the async methods in C#)
  • there are no methods that are both aware of await/async code and a custom task scheduler; by design they are incompatible (see Task.Run vs Task.Factory.StartNew)
  • while a stubborn developer could reproduce the functionality of Task.Run and specify a custom task scheduler, or detect tasks that return tasks and Unwrap them, there are easier and safer ways of doing the same thing without a custom task scheduler
  • as the scheduler will be used not only by the tasks run by the developer, but also by the code separated by await boundaries, the results will be unpredictable except the most simple of scenarios

And a pretty diagram from Microsoft representing the order of the operations and how complex they are. It's not just a case of method executed somewhere, but a complex flow that uses the ThreadPoolTaskScheduler as the default task scheduler as a fundamental low level functionality that should not be changed.

If you need more convincing, consider that the code after an await instruction may not even execute on the same thread (or indeed thread pool) as the one before, even if as written appears part of the same method (see async - stay on the current thread? for more details). More on thread pools from Jon Skeet here: The Thread Pool and Asynchronous Methods.

and has 0 comments

 The Blade Itself is a very nice book. Well written, complex characters, vast world and careful world building. The story, however, is not forthcoming from only this book. Joe Abercrombie has barely managed to present (some of) the characters, build them up and get them together in this first volume of The First Law series.

 What is it about? In a imperialistic feudal world that so far seems split into the North, the Middle and the South, a union of kingdoms has all the power at the center, while her bitter rivals in the south and north are doing everything to gain power. The union is complacent and rife with corruption and bureaucracy, as any rich and safe nation becomes, so much so that is has forgotten even the real events of its formation.

 And yet magic is not dead and the magi return, apparently gathering special people to prepare for a coming event. And then the book ends :) I am curious about the other books in the series so I guess I will be reading them next.

 I recommend this book for readers of good fantasy.

I have been asking this of people at the interviews I am conducting and I thought I should document the correct answer and the expected behavior. And yes, we've filled the position in for this interview question, so you can't cheat :)

The question is quite banal: given two tables (TableA and TableB) both having a column ID, select the rows in TableA that don't have any corresponding row in TableB with the same ID.

Whenever you are answering an interview question, remember that your thinking process is just as important as the answer. So saying nothing, while better than "so I am adding 1 and 1 and getting 2", may not be your best option. Assuming you don't know the answer, a reasonable way of tackling any problem is to take it apart and try to solve every part separately. Let's do this here.

As the question requires the rows in A, select them:

SELECT * FROM TableA

Now, a filter should be applied, but which one? Here are some ideas:

  1. WHERE ID NOT IN (SELECT ID FROM TableB)
  2. WHERE NOT EXISTS (SELECT * FROM TableB WHERE TableA.ID=TableB.ID)
  3. EXCEPT SELECT ID FROM TableB -- this requires to select only ID from TableA, as well (EXCEPT and INTERSECT are new additions to SQL 2019)

Think about it. Any issues with any of them? Any other options?

To test performance, I've used two tables with approximately 35 million rows. Here are the results:

  1. After 17 minutes I had to stop the query. Also, NOT IN has issues with NULL as a value is nether equal or unequal to NULL. SELECT * FROM Table WHERE Value NOT IN (NULL) for example, will always return no rows.
  2. It finished within 4 seconds. There are still issues with NULL, though, as a simple equality would not work with NULL. Assuming we wanted the non-null values of TableA, we're good.
  3. It finished within 5 seconds. This doesn't have any issues with NULL. SELECT NULL EXCEPT SELECT NULL will return no rows, while SELECT 1 EXCEPT SELECT NULL will return a row with the value 1. The syntax is pretty ugly though and works badly if the tables have other columns

What about another solution? We've exhausted simple filtering, how about another avenue? Whenever we want to combine information from two tables we use JOIN, but is that the case here?

SELECT * FROM TableA a
JOIN TableB b
ON a.ID = b.ID -- again, while I would ask people in the interview about null values, we will assume for this post that the values are not nullable

I've used a JOIN keyword, which translates to an INNER JOIN. The query above will select rows from A, but only those that have a correspondence in B. A funny solution to a slightly different question: count the items in A that do not have corresponding items in B:

SELECT (SELECT COUNT(*) FROM TableA) - (SELECT COUNT(*) FROM TableA a JOIN TableB b ON a.ID = b.ID)

However, we want the inverse of the INNER JOIN. What other types of JOINs are there? Bonus interview question! And the answers are:

  • INNER JOIN - returns only rows that have been successfully joined
  • OUTER JOIN (LEFT AND RIGHT) - returns all rows of one table joined to the corresponding values of the other table or NULLs if none
  • CROSS JOIN - returns all the rows in A joined with all the rows in B and all the rows in B that have no match in A

INNER would not work, as demonstrated, so what about a CROSS JOIN? Clearly not, as it will generate 100 trillion rows before filtering anything. SQL Server would optimize a lot of the query, but it would look really weird anyway.

Is there a solution with OUTER JOIN? RIGHT OUTER JOIN will get the rows in B, not in A, so LEFT OUTER JOIN, by elimination, is the only remaining possible solution.

SELECT a.* FROM TableA a 
LEFT OUTER JOIN TableB b
ON a.ID=b.ID

This returns ALL the rows in table A and for each of them, rows in table B that have the same id. In case of a mismatch, though, for a row in table A with no correspondence in table B, we get a row of NULL values. So all we have to do is filter for those. We know that there are no NULLs in the tables, so here is another working solution, solution 4:

SELECT a.* FROM TableA a 
LEFT OUTER JOIN TableB b
ON a.ID=b.ID
WHERE b.ID IS NULL

This solves the problem, as well, in about 4 seconds. However, the other working solution within the same time (solution 2 above) only works as well because newer versions of SQL server are optimizing the execution. Maybe it's a personal preference from the times solution 4 was clearly the best in terms of performance, but I would chose that as the winner.

Summary

  • You can either use NOT EXISTS (and not NOT IN!) or a LEFT OUTER JOIN with a filter on NULL b values.
  • It's important to know if you have NULL values in the joining columns and it's extra points for asking that from your interviewer
  • If not asking, I would penalize solutions that do not take NULL values in consideration. Extra complexity of code, as one cannot simply check for NULL for solution 4. Also a decision has to be made on the expected behavior when working with NULL values
  • When trying to find the solution to a problem in an interview:
    • think of concrete examples of the problem so you can test your solutions
    • break the problems into manageable bits if possible
    • think aloud, but to the point
  • Also, there is nothing more annoying than doing that thing pupils in school do: looking puppy eyed at the teacher while listing solutions to elicit a response. You're not in school anymore. Examples are dirty, time is important, no one cares about your grades.
  • Good luck out there!

and has 0 comments

 The Hatching felt like a cross between The Troop and Infected, but not as cool. The premise, the style and the characters felt artificial, like someone writing by numbers. Common phobias as main subject: check. Characters acting all human and relationshippy: check. Women in positions of power and important characters: check. OK, spiders don't work that way, biology doesn't work that way. If large arthropodes would be capable of coordinating in swarms, eating people, invading a human body and hatching in a matter of hours, they would do it already. There are numerous reasons why they don't, so in fact it was a simple choice: write a less alarming story that is even remotely possible or write something quick, algorithmically and that hopefully sells. Ezekiel Boone chose the latter.

It's not that it's a bad book. Far from it: the familiar writing style and pace made it really easy to read and get into the mood of it. Unfortunately the details were all wrong: the biology, the way everything happens at the same time without any reason to, the politically correct setup that was still sexist because from three lead women characters all of them were sleeping with an underling or thinking about it, plus the extra characters including some gay ones that had no role in the story at all. Now, I understand this is a trilogy or something and those characters will probably play a role later on, but as it stands, The Hatching is simply a bland average book that doesn't even provide closure. If you were caught by the story, you will need to wait until the next book in the series comes out. And for what? To hear about even more people who can't kill spiders or study them in any scientific way until providence saves them because they love their children. Oh, loving ones children as a reason to survive: check.

Bottom line: utterly average and strangely not scary for such a horrific subject.

I got this exception that doesn't appear anywhere on Google while I was debugging a .NET Core web app. You just have to enable Windows Authentication in the project properties (Debug tab). Duh!

System.InvalidOperationException: The Negotiate Authentication handler cannot be used on a server that directly supports Windows Authentication. Enable Windows Authentication for the server and the Negotiate Authentication handler will defer to it.
   at Microsoft.AspNetCore.Authentication.Negotiate.PostConfigureNegotiateOptions.PostConfigure(String name, NegotiateOptions options)
   at Microsoft.Extensions.Options.OptionsFactory`1.Create(String name)
   at Microsoft.Extensions.Options.OptionsMonitor`1.<>c__DisplayClass11_0.<Get>b__0()
   at System.Lazy`1.ViaFactory(LazyThreadSafetyMode mode)
   at System.Lazy`1.ExecutionAndPublication(LazyHelper executionAndPublication, Boolean useDefaultConstructor)
   at System.Lazy`1.CreateValue()
   at System.Lazy`1.get_Value()
   at Microsoft.Extensions.Options.OptionsCache`1.GetOrAdd(String name, Func`1 createOptions)
   at Microsoft.Extensions.Options.OptionsMonitor`1.Get(String name)
   at Microsoft.AspNetCore.Authentication.AuthenticationHandler`1.InitializeAsync(AuthenticationScheme scheme, HttpContext context)
   at Microsoft.AspNetCore.Authentication.AuthenticationHandlerProvider.GetHandlerAsync(HttpContext context, String authenticationScheme)
   at Microsoft.AspNetCore.Authentication.AuthenticationService.ChallengeAsync(HttpContext context, String scheme, AuthenticationProperties properties)
   at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)

This translates to a change in Properties/launchSettings.json like this:

{
  "iisSettings": {
    "windowsAuthentication": true,
    "anonymousAuthentication": true,
    //...
  },
  //...
}

and has 0 comments

  What is burning so white? Love, of course. Brent Weeks ends his Lightbringer saga with a huge book that completes all started threads, brings closure to the grieving, love to the survivors, second and third chances to just about everyone. I liked it, as I did the entire series, but for me Burning White was the weakest book in the series.

  And it wasn't that there was anything wrong with the writing, there was just too much of everything. A lot of new information came along, as it did in many of the other books, but in this, everything was being upended every other chapter. People have lost their memories, then they remembered, then the memories were actually wrong, but they were right, and everybody was being connected, but they didn't actually exist, but they did and everything has a glorious design, but you never find out what the actual design was and what the hell white and black luxin actually do and why people don't use them on a daily basis, etc. There was so much to do in the book that the last ten chapters (three of them called Epilogue) were ALL epilogues and then a post credits scene and even a post book scene. And we still don't know who Kip's other grandfather is.

  I am the first to complain about straight lines in books, but in Burning White, lines go all over the place, loop back on themselves, different colors, shape of kittens, the whole shebang. So in the end, when everything has to come to a close, it all feels really really unnatural and even random. Why did that guy die? Why did this guy live? Why is anyone doing anything?

  I know I am filling this space for nothing. If you are going to read the book you probably read the others in the series and no one is going to stop you now. I am not even suggesting it; this is a great book. However, with great epic stories comes great responsibility to end them right. I don't know exactly why I feel so unsatisfied with the ending, but maybe because the author build up all of these grand heroes, only to kind of make them fail until someone changed their view of the world and helped them out. It invalidates a lot of the previous books. Also, less cool magical mechanisms in this one and a lot more talking and feeling.