Improve your developer skills with Codewars

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:

def anagrams(word, words)
  words.select { |w| w.chars.sort == word.chars.sort }
end

or regular expressions usage to solve a wide range of problems:

def pig_it text
  text.gsub(/(w)(w+)*/, '21ay')
end

and you can write your own tests while you’re training a kata.

You can choose among many programming languages (I’m looking forward to see Elixir or Rust in the future).

Ruby builtin Hash

Today I was really debated whether to publish another post about SQL (it was a reflective post on how ORM may have ruined us) and a post about the introspection of a ruby builtin feature.

I hate to be repetitive (the SQL post would have been my third post in a row) and I always find enlightening to study language internals because there you can see the real programming magic. So, why not to post on the Ruby Hash and its lookup complexity of O(1)?

Then I realized there’s plenty of blog posts about the Hash object. And one of these is written so well that I could never compete.

What I really liked of this post is that the author is not only explaining the theory behind Hash, but he also try to reimplement it.

Why do you need Arel?

In my opinion Arel is one of the greatest and most underestimated gems. Of course today Arel is also one of the most used gems because it’s shipped in Rails, but how many people use it actively? And why would they?

Since Rails 3 Arel is the base block of ActiveRecord. Every time you pass a hash to where, it goes through Arel eventually. Rails exposes this with a public API that we can use when we have to write complex queries.
Continue reading “Why do you need Arel?”

Metaprogramming in OpsWorks recipes

The last time I worked on OpsWorks I needed to implement a recipe to handle the setup and configuration of cron jobs.

Actually I had already written some code to handle this functionality in the past. However, the recipe I ended up with wasn’t particularly flexible.

Continue reading “Metaprogramming in OpsWorks recipes”

Writing Ruby extensions in Go – an in depth review

For a very long time the only way to extend Ruby with native estensions has been using C.
I don’t have the numbers with me, but I guess C is not the first choice for Ruby programmers when they have to pick up a secondary/complentary language.
So I started investigating the possibility of writing them in other languages, taking advantage of the favorable moment: in the past 3-4 years we had an explosion of new languages that compile down to native code and can be easily used to produce a C equivalent shared library that Ruby can pick up and load.

My main goal was to find languages that a Ruby programmer would understand effortlessly or with a minimum investment.
This first episode will focus on Go.

Continue reading “Writing Ruby extensions in Go – an in depth review”

Configuration made easy

Recently I was writing a simple program (more a script than a full-fledged program) to report the number of commits for each dev on all repos owned by a given organization.

Following the will to develop something extensible I set up a CLI tool (actually a gem) based on the famous gem Thor.

In order to have full power to configure my gem I choose to rely on another gem called configuration.

Continue reading “Configuration made easy”