Tango with code

A blog about frustration and anger

Multithreaded K-Means in Java

| Comments

Single-threaded algorithms are fine and intuitive. There’s an single execution flow running our program in the exact order we specified it. However, modern CPUs have multiple cores sharing the same memory space, meaning that many instructions can be executed in the same clock cycle. Having an single execution flow would be a wasteful use of the resources we have available. That’s where multithread applications come in: It allows the use of true parallelism.

Mixing Assembly and C

| Comments

In many applications, mixing Assembly and C is routine (pun intended). There are many reasons for it, but, in general, you want to use Assembly when you want to deal with the hardware directly or perform a task with maximum speed and minimum use of resources, while you use C to perform some high level stuffs that don’t attend the former requirements. In either case, you’ll need one integrated system.

There are three ways to mix Assembly and C:

  • Using Assembly-defined functions into C
  • Using C-defined functions into Assembly
  • Using Assembly code in C

We’ll explore them all in this tutorial.

Is It a Cat or a Dog? A Neural Network Application in OpenCV

| Comments

Who is the good boy?

From time to time, a website named Kaggle hosts several competitions in the fields of Data Science and Computer Vision. One of those competitions was the Dogs vs. Cats challenge, where the objective was “to create an algorithm to distinguish dogs from cats”. Although this particular challenge already has been finished, I thought that it’d give me a pretty good material to a tutorial. Let’s learn how to solve this problem together using OpenCV!

Creating a Telegram Bot in NodeJS

| Comments

Hi there, people and fellow bots! In this tutorial, I’ll show you how to create a Telegram bot in NodeJS framework (that I consider the easiest approach).

If you live in a cave and DON’T know what Telegram is, I’ll tell you: Telegram is an awesome multi-platform messaging app. More than that, it’s an (partially) open source infrastructure for developers to design their own instant messaging apps.

Solving the Sliding Puzzle

| Comments

Sliding puzzle is a game composed by 2n - 1 pieces dispersed along a board and a blank space. Those pieces are then shuffled and the objective is to rearrange them back to their original form, where the disposition of pieces is on ascending order, like shown below (go on, it’s interactive):

You can rearrange the pieces “moving” the blank space across the board. Since you can only move it in four directions, it’s a hell of a task to solve this game for a human, sometimes taking hours. Luckily, we dispose of some good algorithms to solve it, taking only few milliseconds even for the worst case. Let’s explore them in this tutorial! :)