This post was born from the need of calculating some kind of server response time during a page request. Although this is not perfect, because doesn’t account for the time that the response takes to reach the user, it’s pretty accurate on the server side.

In order to have the request start time I added this header in the Apache configuration server:

RequestHeader append Request-Started "%t"

I didn’t use a simple before_filter because it would have not considered the time spent in rack middlewares, for example.

Now in my action I can count on a request header like this:

Request-Started: t=1460473552166899

Note that this timestamp is in microseconds.

Now in the page view template I can get the total request time doing some simple math:

Some weeks ago in Mikamai we started using codewars, a website that aims to improve your programming skills via gamification with code challenges.
Since I’m a junior developer willing to improve my Ruby knowledge I have used it a lot lately, so let’s see how it works.

After signing up and completing a simple code problem, you can start browsing some kata and boost your programming skills.

Why kata? Codewars has this oriental, martial arts flavor so you’ll find words like kata and train for quizzes, kyu and dan to classify user rankings.

Personally I’m really enjoying the site and the learning process.
The number of Ruby katas is huge, and I find expecially nice the chance to see other users solutions after you complete a kata, so you can see super-compact solutions such as: