You are a god

You don’t often get an email from your boss’s boss saying that :)

I was sitting in a boring meeting when I received a call from this guy (my boss’s boss) and he explained to me that there’s a situation in which the firm loses 50mil every month. The situation was so bad the it was escalated to the CTO. One key piece in making this go away would be using a firm-wide platform to cleverly extract some data and use that to consolidate around this money. “But I heard this is something that you can do blindfolded with your hands tied together”. Some guy then pointed me to some half-baked solution that was done for something else 4 months ago. I quickly grabbed this code, ran it through some examples and voila, it was what were needing. After receiving the real population of the input data I noticed there are some problems that I’ll have to solve today then productionize the code. Wasn’t that hard for a multi-million-dollar problem. I hope this will be properly reflected in my year-end bonus! :)

foldRight is king

This morning traffic was exceptionally bad. I didn’t happen to choose the right podcast to listen to and it didn’t manage to divert my mind well enough, so I lived through the whole of the extended commute. The nice thing was thought that I didn’t have many meetings, so after a couple of weeks I finally had some uninterrupted hours to focus on coding. I started refactoring a bit that was horrendously embarrassing. While doing this, I bumped into the age-old Scala problem that is caused by some 20-year old bad decisions JVM designers made. I needed to partition a Map based on the key’s actual runtime type. In an ideal world it would’ve looked something like this:

trait Base
case class Derived1
case class Derived2

val map = Map[Base, ValueType](dervied1 -> v1, dervied2 -> v2)
val (d1, d2) = map.partition {
   case (Derived1, _) => true
   case _ => false
}

This of course doesn’t work, as generics lose their type information because of erasure, so the Scala compiler complains about fruitless type checks. This is when I got the artillery and went to fold for help. If you have given it enough thought, it’s actually easy to understand:

val (d1, d2) = map.foldRight(
           (Map[Derived1, ValueType](), Map[Derived2, ValueType]()
         )
{ 
  case(m, (d1, d2) => m match {
          case (k @ Derived1(), v @ _) => (d1 + (k -> v), d2)
          case (k @ Derived2(), v @ _) => (d1, d2 + (k -> v))
       }
  }

Which is pretty cool. If I remember correctly, there’s a theorem that fold can be used to achieve everything that the higher-order functions on the collections provide; they’re merely there for convenience :)

Completed the door project

Today I finally fully completed the door project, including painting, cleaning up and tidying. It wasn’t an easy ride, the inverse masking removed paint from the doorway, so I had to use a small brush the fix up those as well. It basically added one more day of work to an otherwise simple and easy task. Interestingly, I don’t remember much of this week – I’ve been either working or doing something around the stupid doors; basically I had no free time. But at least it’s done and I can say I’m almost completely satisfied with the end result :)

Innovation

I’m part of a firm initiative to drive innovation. I’m actually an ambassador for the local office and for this reason I was planning to do a presentation on one of our knowledge share + social events. Based on some hints I contacted some people that had previously done something as part of the program because I wanted to share real-world experience, not just a boring slide deck. I had two contacts, but they could mainly talk about what didn’t work for them, but one suggested contacting someone from middle management (a real person, not a group), so they could point me to other people with possibly more success. I wrote an email today to this guy, explaining the situation, but he hasn’t replied yet. When I hit sent I saw him online. I mean I would say that maybe a junior person would ignore such an email from someone that’s not familiar and that may be acceptable – but no, not even from them: they could at least drop a mail saying ‘Sorry I can’t help’, but I would expect from someone at his level to reply back. I’m kind of baffled as how people let themselves behave so impolitely.

The Tesa sensitive masking tape is not working

I was painting the doorways and used this masking tape to mask the walls around them. We chose this one hoping that we won’t bump into the same old problem when the masking tape actually removed half of the wall paint underneath. This masking tape seemed promising, it has much lower sticking power and has a better paper that shouldn’t soak in the paint. So last night I finished painting two doorways and this morning I started removing the masking tape. Unfortunately it still had paint chips on it, and it also removed some paint from the doorway itself. I was furious! I wish things just worked without requiring me to do the work twice. Now I’ll have to mask the doorways then repaint the walls around them. It’s so annoying! The only thing I can hope for is that it won’t remove the paint from the doorway; otherwise I’m in a cathc-22 :(

We completed the door project… almost

My dad and I finished sizing and setting up the doors upstairs. There are four of them and the old ones looked kind of terrible -you know, old fashioned, having some cracks here and there and the paint was also damaged- so we decided the they were up for a swap. The problem is that they were non-standard size -at least non-standard now- so we needed to resize the new ones. It didn’t take much, but we needed to saw a centimeter off their widths. After that, we needed to set them up correctly of course and align them in the doorway. The reason they’re not ready yet is that I still need to paint them then put the knobs on. Probably it’ll take me two more days to finish everything up but it’ll look so much better.
We also changed two roof tiles that were cracked. When I climbed up the ladder and started getting one out, a couple of wasps started flying around me. Never a good sign! They probably had a nest somewhere close and one of those bastards actually stung me on my wrist. It’s still pretty painful and I expect it to be extremely itchy tomorrow. But at least we fixed the tiles and I know that I’m not allergic to wasps. That still counts right?