Book Review: “The Black Swan”

October 30, 2016 Book Reviews No comments

The Black Swan - Book Cover

A black swan is a highly improbable event with three principal characteristics: It is unpredictable; it carries a massive impact; and, after the fact, we concoct an explanation that makes it appear less random, and more predictable, than it was. The astonishing success of Google was a black swan; so was 9/11. For Nassim Nicholas Taleb, black swans underlie almost everything about our world, from the rise of religions to events in our own personal lives.

Description by the publisher

I have listened to the audio version of “The Black Swan” twice. First time at the beginning of the year and the second time just recently. The book is philosophical in a way. It is not very easy to fully comprehend conveyed message as author frequently diverts to fictional stories, terms in French, and thinkers that are long time dead.

There were two striking statements in the book “anyone can be a president” if someone like “these people can get a Nobel prize”. Sounds actual? Think of Trump vs. Clinton presidential race and Bob Dylan receiving Nobel prize in Literature if you are not reading this in Autumn 2016.

bill-and-hillary-clinton-discuss-becoming-president

This does not mean that Nassim Taleb is any sort of predictor or prophesy maker. He himself says that he cannot make predictions, instead he highlights over and over again that rare events that seem improbable do occur more frequently than most of us would imagine and at the same time it is impossible to come up with mathematical models that would somehow calculate probabilities for these events. Unfortunately, we cannot know what we don’t know, therefore the best strategy for any of us is to build robustness to black swan events.

Application of the ideas expressed in the book is very wide. Starting with building financial portfolio consisting of 90% of very safe investments and 10% of extremely risky ones, therefore exposing yourself to probability of catching a black swan, like Google or Facebook. Ending with applying it to your life by exposing yourself to variety of endeavors. Careful here: event’s consequences are even harder to predict than occurrence of such events.

There is one aspect of the book that I don’t like. The author almost throughout the book despises other people imagining them as aggressive apes and suggesting nasty things like putting a rat down someones shirt. I do not exclude that he imagines his readers in the same way: silly monkeys reading higher caliber philosophical work. This, though, does not disqualify his book from being a really valuable contribution to human knowledge, but, in my opinion, it is only thanks to the black swan event of him benefiting from the 2000 crisis that made him successful and subsequently allowed him to write this and other books.

Conclusion

This book is definitely worth reading. It may make you look at the world as sequences of improbable events that change everything around. It could also make you way more skeptical about the theoretical modeling suggested by economists and other tie wearing experts. The book is not an easy read. On the contrary, it requires a lot of attention and thinking. Maybe leave it for a time when you are in a “philosophical” mood.

Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedInEmail this to someone


No comments


How to add Microsoft.Extensions.DependencyInjection to OWIN Self-Hosted WebApi

October 17, 2016 .NET, HowTo, WebApi 1 comment

I could not find an example showing how to use Microsoft.Extensions.DependencyInjection as IoC in OWIN Self-Hosted WebApi, as a result here is this blog post.

Let’s imagine that you have WebApi that you intend to Self-Host using OWIN. This is fairly easy to do. All you will need to do is to use Microsoft.Owin.Hosting.WebApp.Start method and then have a bit of configuration on IAppBuilder (check out ServiceHost.cs and WebApiStartup.cs in the gist below).

It becomes a bit more complicated when you want to use an IoC container, as OWIN’s implementation takes care of creating Controller instances. To use another container you will need to tell the configuration to use implementation of IDependencyResolver (see WebApiStartup.cs and DefaultDependencyResolver.cs). DefaultDependencyResolver.cs is a very simple implementation of the resolver.

In case you are wondering what Microsoft.Extensions.DependencyInjection is. It is nothing more than a lightweight DI abstractions and basic implementation (github page). It is currently used in ASP.NET Core and EF Core, but nothing prevents you from using it in “normal” .NET. You can integrate it with more feature-rich IoC frameworks. At the moment it looks like Autofac has the best integration and nice documentation in place. See OWIN integration.

Rest is just usual IoC clutter. See the gist

I hope this blog post helps you with integrating Microsoft.Extensions.DependencyInjection in WebApi hosted via OWIN.

Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedInEmail this to someone


1 comment


Ember upgrade from 1.7.0 to 1.13.13

October 4, 2016 EmberJS No comments

EmberRelease Obviously there are general upgrade guides provided by Ember team and many fellow bloggers. This is just to document one of the experiences with upgrading from ember 1.7.0 to 1.13.13.

At the moment of this writing Ember latest stable version is 2.8. My team was one of the early adopters of Ember. I believe the team started incorporating it in late 2013, which is very soon after the 1.0 release. We went live with the version 1.7 at the beginning of 2015 and since that time we didn’t do any updates for “penny wise and pound foolish” reasons.

Upgrade itself was a bit of pain as it spread for couple of months. We allocated few days per sprint and at the same time continued developing new features the old way in other branches. Bad idea.

Another pain was that we adopted Ember Data while it was still beta. As a result we have custom code altering adapter’s and serializer’s behaviour. There are many breaking changes between beta versions of Ember Data, so using it while in beta was a very bad idea.

One of great things about being on Ember 1.13.13 version is that you are effectively on 2.0.0 version unless you have deprecation messages in your console. This also means that you can still release your application with some parts not being completely converted to the new way of doing things. ember.prod.js doesn’t generate warnings and works just fine. I really like the way Ember tries to make upgrading easy. Here is a nice write up on handling deprecations as of 2.3.0.

List of useful links:

Gotcha list:

This list is composed from notes I took so it is not very well organized and does not contain all of the items we had to fix.

When upgrading from 1.7 to 1.8

  • Update ember data to 1.0.0-beta.11 for compatibility and as a fix for “Ember Data cannot read property 'async' of undefined"
  • Replace pushObject with addRecord to fix “You looked up the relationship on a with id but some of the associated records were not loaded.”
  • This does not work and has to be rewritten Ember.Handlebars.helpers.render.call(this, name, contextString, options)
  • Use Ember.set() whenever there was controller.isNew property with some set

When upgrading from 1.8 to 1.10.1

  • Start using HTMLBars instead of Handlebars by incorporating ember-template-compiler
  • add stripBOM to grunt file… as template compiler includes those: template = template.replace(/\uFEFF/g, ''); // remove BOM
  • Fix HTML to be correct (closing tags, missing tbody, etc)
  • ember-data 1.0.0-beta.11 has bug in findQuery asserts => upgrade ember-data to 1.0.0.beta12
  • Remove //# sourceMappingURL=ember-data.js.map
  • Ensure models are generated with {async: false}
  • Remove code that works with MetamorphView. Fixes this: Assertion Failed: A fragment cannot be pushed into a buffer that contains content because of: view.createChildView(Ember._MetamorphView, {

When upgrading from 1.10.1 to 1.11.4

At this point you start to get tons of deprecation messages.

  • You attempted to access `someProperty` from `<App.SomeXyzController:ember2661>`, but object proxying is deprecated. Please use `model.someProperty` instead.
  • Convert this {{action bubbles=false preventDefault=false}} to this {{action "ok" "close" "cancel" bubbles=false preventDefault=false}}
  • Fix dynamic compilation of HTMLBars. Cannot call `compile` without the template compiler loaded. Please load `ember-template-compiler.js` prior to calling `compile`. Ember.HTMLBars.compile(submitHtmlTemplate); doesn’t produce a correct function to retrieve HTML. Can be solved as in this SO answer.
  • Using @each at the end of a computed key is deprecated and will not work in Ember 2.0
  • Replace Ember.Enumerable.mapProperty with mapBy
  • Replace Ember.Handlebars.helper with Ember.Helper.helper

When upgrading from 1.11.4 to 1.13.13

  • Rewrite code that uses itemController
  • Rewrite properties that have setter to the new computed syntax

I hope this comes in handy for you.

Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedInEmail this to someone


No comments


Running Challenge Completed. Health, Motivation, and Other Aspects Of Running

October 2, 2016 Opinion No comments

Are you bent by scoliosis programmer? Do you spend too much time sitting? Maybe you look a bit flabby? Super tired at and after work? High chances are that some of these are true for you. Some certainly are true for me. This year I tried to improve my situation by running. Here are my thoughts and humble recommendations.

Dirty Running Shoes

Running and its impact on your Health

“Being physically active reduces the risk of heart disease, cancer and other diseases, potentially extending longevity.” – many studies show accordingly to this article. Probably one of the most accessible forms of exercising is running. All you need to start is just pair of shoes. This research paper is a good resource on learning about impact of running and other exercises on chronic diseases and general mortality.

So why running? – Because it is easy to start with and because we are made for it. “Humans can outrun nearly every other animal on the planet over long distances.” – says this article. Funnily enough there is yearly Human vs. Horse marathon competition.

If you ask yourself how you want your last two decades before death look like, most likely you would picture a healthy, mobile, and socially active person. Also you would prefer those two decades better be 80’s and 90’s. Right? Light running for as little as 1 hour a week could add as much as 6 years to your life. This long-term study showed that “the age-adjusted increase in survival with jogging was 6.2 years in men and 5.6 years in women.” (For those who are pedantic and want to know net win: (2 hrs/wk * 52 wks a year * 50 years) / 16 day hours = 325 days lost to running still gives you net 5 years).

Motivation

At my age I do not think about the death that much. My main motivation for running is improvement of my health. I know that for many people extra weight is motivating factor. For me it is not as instead of loosing weight I gained some 2-3 kg. Likely I’m so skinny there is no way to loose fat, though there is room for leg muscles growth. Unfortunately running is often boring and it is very hard to get yourself outside and go for a run on that nasty cold day. Here are few things that helped me running this year:

Run different routes

Always running at same location taking same path is boring. If you travel somewhere, just take your shoes with yourself and have a run at new place. Not only you get to have another run, but you explore the location. I ran in five different countries this year and could tell that those runs are more interesting than usual next to home ones.

Running in Ireland Gap Of Dunloe

Join friends or running club

I was going for runs rather rarely at the beginning of the year, but later as I started running with friends I started to run more frequently. It is always much more pleasant to have a conversation and learn few new things from friends, especially if areas of your interest overlap more than just running.

Running With Friends

Sign up for a challenge

Sports are competitive by nature. You can have friendly competition with your fellow runners, or you can take a virtual challenge. That works great because the clock is ticking and you want to have it done. This September I took it to the next level by signing up to Strava monthly challenges. I have completed all of them. See Trophy Case below:

Strava September Running Challenge

Be careful and avoid injury

You don’t want to walk with a cane when old because you were too stupid and run too much and too hard when young. I’m sick of running because of this September challenge. I completed it, but last two runs I ran through the pain being injured. I’m recovering now using RICE recovery technique. From now on I will take it easier. Suggesting the same for you.

RICE Recovery - Icing an Ankle

You can do it

I’m not a good runner. At the beginning of the year I could barely run 5km, I didn’t know how I will complete my planned 40 runs as it was so hard. Running 40 times was my main year goal. I did not expect that I will ran for around 50 times totaling 320 km. And it is not the end of the year yet. I also ran a Half-Marathon distance running a top Kahlenberg hill next to Vienna. If I can do it – you can!

Conclusion

I completely agree with research and studies that “for majority of people the benefits of running overweight the risks” and at the same time I voluntarily ran through the injury just to complete my challenge. Motivation is an important factor, but runners have to be careful and moderate their exercising. This is especially true if you run for the health reasons. Just try to make your runs more interesting and enjoy your life… longer.

Running under Speed sign

Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedInEmail this to someone


No comments


Book Review: What If?: Serious Scientific Answers to Absurd Hypothetical Questions

September 20, 2016 Book Reviews No comments

What if - Book CoverI read this book because of the recommendation I found online. It was in one of the Bill Gate’s reading lists. Maybe this post will have same effect on you… and you will decide to pick it for your reading.

“They say there are no stupid questions,” the author writes. “That’s obviously wrong. . . . But it turns out that trying to thoroughly answer a stupid question can take you to some pretty interesting places.”

Indeed, I remember we had a lot of hypothetical scientific discussions with my friends during my university days and these discussion would just go on and on ending sometime around 2AM. It was a lot of fun diving deep and exploring every possible twist. You get to have same fun when you read the book.

Well… it is actually more fun to read the book, since it is very nicely illustrated and thoroughly researched. Basically you don’t get to read rant – everything is cross checked with scientists by Munroe.

I guess this book also teaches to approach problems that require scaling, approximation, simplification, calculation, estimation. It also helps to understand physics better. And if you have some silly question that keeps you awake at nights you can always submit it on the xkcd web site.

This book is pure entertainment and joy. I can surely recommend this book to anyone generally interested in science.

Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedInEmail this to someone


No comments


Book Review: Coders At Work

April 26, 2016 Book Reviews No comments

coders-at-work-cover-bigThe book “Coders At Work” is a collection of interviews of famous coders. The book takes a reader through 15 career stories. It inspires and gives insight into minds of great programmers.

Most of the selected coders are of older generations, so at times, it is hard or, rather, not exceptionally interesting to follow some of their career endeavours. Especially, if the whole career was around one system or one language that is “dead” today (think of COBOL, Fortran, PDP-1, etc). I don’t mind to know the history of the industry, but I’m not interested in too much of the details (you can blame me if you wish). On the other hand, it was very interesting to try to understand how these people think and how they approached problems they had. I really believe there is a lot to learn from them.

The author, Peter Seibel, starts interviews with a usual but interesting question about how the interviewees got involved in programming. Then, the author proceeds to questions that relate somehow to what interviewees have done in their careers. There are standard questions about debugging, favorite editor, opinion on some programming language, and other.

I liked answers to the question on how they hired people and what advise they can give to the young programmers.

There were a couple of questions that I didn’t like. One was “Do you consider yourself a scientist, an engineer, an artist, or a craftsman?”. I think it is a pointless question. These nouns can be interpreted in different ways and any answer would be just fine.

Throughout the book there was a discussion about the importance of computer science education and one of the questions was if interviewees have read the book “The Art Of Computer Programming”. It was kind of introduction to the last interview with Donald Knuth. I liked the interview with him, but I’m not sure if the author had to put so much emphasis on this personality.

The list of interviews is available at book’s website with short descriptions of who those people are and what they did. To be honest, before reading “Coders At Work”, I only knew about Douglas Crockford, Joshua Bloch, and Donald Knuth.

Conclusion

The book gives insight into how some of the great programmers achieved what they have achieved. It educates and inspires, though some of the stories might not be very exciting. At times, you may think that other big names would have made the book even more interesting. Nevertheless, I liked reading the book “Coders At Work”.


Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedInEmail this to someone


No comments


Amazon Interview Experience

April 19, 2016 Career, Opinion 4 comments

Just recently I went through the amazing interviewing process with Amazon. I had really positive experience and I would like to share with you.

Amazon Logo for a blog post on Amazon Interview Experience

Disclaimer: The opinions expressed herein are exclusively my own personal opinions. To the best of my knowledge and understanding, this blog post is compliant with Non-Disclosure Agreement I have signed.

Amazon Interview in general

First of all, it is not like any other interview I ever went to. Though, I have to mention that it is also the first time I go through the interview with a tech giant company.

The interviewing process is really language and frameworks agnostic and at the same time it is very code and problem-solving centric. So what happens is that you are not asked about any specifics of any given programming language, but you are expected to write a lot of code on a whiteboard. You are expected to solve problems and your way of tackling problems and your approaches are something that is very important and evaluated.

Now I see how Amazon manages to build great teams and deliver awesome products. In my opinion, this is because they hire problem solvers and people capable of coding and thinking. I believe bias factor is greatly reduced because of the way they do interviews.

Let me take you through my Amazon Interview experience. I have signed NDA, so I cannot share any specifics of projects they are hiring people for, nor it is appropriate to mention exact questions I was asked.

Stage 0: How to get into the process?

Amazon was organizing Hiring Event in Vienna (Austria) and one of their recruiters contacted me on LinkedIn. I don’t know whether there was anything interesting in my profile or not, but it is how it happened.

If you are actively looking for a job and want to get to the interview with one of big tech companies, seeking a direct referral from within the company is probably the best bet.

In my case, it was one of those rare HR messages which I didn’t want to ignore and decided to pursuit further. I was asked to share my resume. After it was reviewed, I was asked to do an online coding test.

Stage 1: Pre-screening coding test

To know whether you are even worth talking to there is a coding test. It is organized online, but you also have the option to program live with some coder.

You can program in any language you feel comfortable with, as long as it is one of the major ones.

My test had three problems to solve, two of which were writing code. It is very similar to what you can get on programming competitions (ACM, TopCoder, etc), but less formalized and with fewer tests. I personally spent way too much time on the first task, because I decided to implement an efficient solution using BFS. Later I realized that any solution that passes tests would be ok as well. So instead of mine O(n), O(n^2) would be fine to get me to the screening session. Two of solutions were passing their tests. I didn’t have time for the third question, so I just wrote that I didn’t have time and explained how I would have solved it.

Stage 2: Screening

Screening is just 30 minutes chat. They would only ask you basic computer science fundamentals. Questions would be completely agnostic to programming languages or technologies. I believe, they just want to check that you know basics of programming, you can express yourself and that you will feel comfortable during the interviews.

Stage 3: Interview Day

This is something awesome. My right thumb still hurts because of holding whiteboard marker. Something I really liked was that there was challenge, there was coding, there was problem solving.

Almost all other interviews I had before with other companies were standard boring questions about one specific technology stack, starting from persistence layer moving towards presentation layer. I never had to write code during my interview (maximum few lines of code). And only once I was asked to solve a specific problem for a start-up company.

I had four interviews during the day lasting for 50-60 minutes. For me, it looked like I would get a bit more senior level questions with every next interview, but I may be mistaken. I also don’t know if this is the way interviews are usually organized at Amazon.

Interview 1: Answer few situational questions, write code!

So, as I said, I cannot tell exactly what I was asked, but my first interviewer was a person who writes a lot of code himself. He would slowly transition me to the coding task, which was to implement some data structure of some sort. I guess I could be something else as well. I messed up the beginning, but later it was fairly easy and I had the implementation on a whiteboard.

Interview 2: Write code!

The second one was really interesting. It didn’t have much introduction. There was a coding problem right away. Unfortunately, I was a bit too sloppy on this one. I jumped to writing code too quickly. So, as first solution I implemented three loops O(n^3) and then, with guidance from my interviewer, I switched to writing O(n^2) solution. Somehow, even I was able to solve the problem, I feel I was too quick to jump to writing code and didn’t think enough up front. So, remember – less rush!

Interview 3: Answer few situational questions related to projects on a bit higher level, write code!

The third one was way more smooth at the beginning. Many situational questions. When we switched to writing code, I believe the problem was also more complex. I fairly quickly identified that the problem had to be solved using XYZ technique, but I struggled a lot with an actual implementation. I didn’t manage to have a complete solution, but I hope I was able to convince my interviewer that if I had a bit more time I would have had a complete solution in place.

Interview 4: Solve designing problem. Draw diagrams! And finally, ask some real questions about projects, teams, learning.

This one was the easiest for me. There were two designing questions. The first one was object-oriented design for some system. And the second one was system design for the very same system. I didn’t have issues with either one of those (at least I think so).

I was very quick with OO design. I’ve done a lot of design in the past and I believe in core principles of OOD. Besides, I have even written a book on design patterns. That had to play some role.

The system design part also went very smoothly. Probably because I have very relevant experience working for a big web company. Scalability, availability, performance principles for system design isn’t something new to me. I’ve never configured load balancer nor I ever setup Master-Slave-Replica, but I just knew these things and how they are supposed to work. Just by coincidence recently I read “Release It!” book and that could have played some role as well.

In the end, I could ask questions that were most important to me. Like questions about the team, learning and growth opportunities, projects, and technologies.

Stage 4: What happens next?

I don’t know. I’m not there yet.

Preparation

There is one aspect I don’t like about the interviewing process like this. Amazon, Facebook, Google, Microsoft are huge tech companies that have somewhat similar standardized interviewing process. You can read online about how it looks like and what are common questions. There is even book “Cracking the Coding Interview” that has 189 coding questions.

So hypothetically, let’s imagine there are two deep copies of me. And by “deep” I mean that we both have absolutely identical personalities, knowledge, background, experience. Now we are both to be interviewed in one month. Copy One doesn’t have time to prepare and just looks up what are the main types of questions. Copy Two takes a month of vacation and sits at TopCoder in practice rooms solving, say 300-500 problems. Copy One is also capable of doing it as both of us did some ACM in university 8 years ago. Now when the interview comes, Copy Two just shines and cracks all questions. Copy One struggles with solving problems but manages them somehow. So when the performance of these two copies is compared Copy Two wins. But what hiring company gets is almost identically same with a difference of 1 month of TopCoder practice.

Definitely, there are reasons why the process has to be standardized. It could have been way worse if it was otherwise.

I did prepare myself. Not as much as I would like, though. Buying a whiteboard for kids was definitely a good investment from my side. I did couple of problems on the whiteboard, watched couple of MIT lectures on algorithms, bought a copy of CLRS (I was even ready to use Master Theorem if asked).

Conclusion

I really liked interviewing process at Amazon. I appreciate all the time invested in interviewing me.

Disregard if I get an offer or not, or if I will have to decline it, I won’t change my opinion about this interviewing experience. Just going through Amazon Interview is worth the time and preparation effort.

Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedInEmail this to someone


4 comments