Building multi-architecture Docker images: why and how

Docker is quite a famous piece of tech. It solves the problem of making software that runs easily across machines (mostly for Linux servers). I won’t get into details, but it uses Kernel level functions to isolate containerized programs so that we don’t need to bother about installing the right dependencies on every machine we want our software to run. Instead, we build a docker image, publish it and whoever has docker in their machine can then run it as well as long as the machine has Docker installed. ...

January 22, 2022 · 8 min

A Shell Configuration

I spend a lot of time on the terminal. I started with vanilla terminals on Ubuntu and macOS. Later I learned about terminals with a few "batteries" included like iTerm2 and HyperJS. I have also used tmux extensively before, but ended up switching a few months later to use window splitting from iTerm2 and also profiles, which can login to a shell session automatically. Well, enough of history. This post will introduce you to a basic shell configuration. Ok, it is not basic. However, for me it is the difference between bearing and loving my terminal setup. Topics I will talk about are the following: ...

April 10, 2020 · 7 min

How to succeed in the software industry

Continuous improvement. This post's purpose is to help students and professionals in the software industry get better at what they do by continuously improving. I share points that helped me mature as a person in the last few years and that, in my humble opinion, made my software developer mind-set much better than when I started. What I show here is not going to make you a great developer, but helps you have ideas on making a plan to become one. A great deal of content here is applicable for other areas. ...

March 31, 2020 · 11 min

One Consumer, Multiple Producers in F#

I have been learning F# by reading the Expert F# 4.0 book by Don Syme, Adam Granicz, et al. I am really enjoying the concurrency chapter and decided to take on a small challenge involving agents (MailboxProcessor). I settled on the following requirements: 1 consumer agent with two-way communication accepts arrays of doubles and stores their sum and count internally allows other to fetch the current average 4 producer agents generate arrays of doubles sends them to the consumer agent fetches the current sum and count waits for a specific interval then generates next one Stats and Messages Let’s start by defining a Stats type that will store our sum and count: ...

January 5, 2020 · 4 min

Get number of common divisors in OCaml

Hi, everyone! In this challenge I used OCaml sets again. The goal was to get the number of common divisors for each pair of numbers in the test cases. The first function I wrote was to define a limit until when I would be checking if the number was divisible or not: (* Need to check divisors just up to sqrt x *) let max x = Int.of_float (sqrt x) |> (+) 1;; After that, I wrote a function to get the number of common divisors of a single number n. Inside it I wrote another function, divs responsible to get all the divisors up to the limit define in the max function. This is just half of the divisors. The other half is obtained by dividing n by its divisors and adding each result in the set. For instance, if n has divisors, up to max n in the set set, then I add the rest using: ...

March 28, 2017 · 3 min

Dedup chars in a string using OCaml

Hi there! The goal of this challenge is to remove all duplicate chars in a string. The following input/output will explain it by itself: # input abcabczabczabc # output abcz I tried to write the functions to explode and implode from what I remembered, but in the end I had to take another look at their code here. Those were auxiliary functions to help me to write remove_all_dups. open Core.Std (* string -> char list *) let explode str = let len = String.length str in let rec expl str i = if i > len - 1 then [] else str.[i]::(expl str (i+1)) in expl str 0 (* char list -> string *) let implode clist = let len = List.length clist in let str = String.create len in let rec impl i = function | [] -> str | c :: l -> str.[i] <- c; impl (i+1) l in impl 0 clist (* string -> string *) let remove_all_dups str = let char_list = explode str in let s = Set.empty ~comparator:Char.comparator in let rec remove s no_dup_l = function | [] -> no_dup_l | c :: t -> let f = fun x -> x = c in let found = Set.exists s ~f:f in if found then remove s no_dup_l t else let s = Set.add s c in remove s (c :: no_dup_l) t in remove s [] char_list |> List.rev |> implode let a = read_line();; print_string (remove_all_dups a);; If you take a look at the function remove_all_dups, there is a set that is used to keep tracks of the chars that were already seen. First I tried to use a map, but it was too much overkill and more complicated in my opinion. Sets are more specialized and ideal for that. ...

March 27, 2017 · 2 min

Mingle strings in OCaml

Hi there! The problem that I solved this time was a little cumbersome initially, cause even though I knew well how to iterate over lists, I had no idea how to iterate over strings. The solution I found was inspired in the functions to explode and implode strings . These functions use the string indices to explode the string, creating a char list, or implode a char list, creating a string. My goal was not to implode nor explode, but mingle two strings, alternating the chars in each of them. Example of input and output, together with the final result is below. ...

March 26, 2017 · 2 min

List Replication

Hi there! The idea of this problem is just to read some numbers from stdin and replicate them, but using lists. The input would be like this: 3 // # of repetitions 1 // first number ... 2 3 4 // end of input, last number Then the output would be a list with each number repeated the amount of times given. For the case above, it would show “1” three times, “2” three times and so on, each element on a different line. I was given the IO functions by HackerRank and filled the function to create the new list. The result is below. ...

March 24, 2017 · 2 min

Hello World printing in OCaml

Another simple problem from HackerRank is to print Hello World multiple times in a functional language. Well, I am using OCaml and I suppose I should avoid loops. The way I solved it is the following: open Core.Std let n = read_int ();; let rec print_hello n = if n > 0 then begin printf "Hello World\n"; print_hello (n-1); end else ();; print_hello n Problems I had: I lost some some time to discover the ;; was required to make it compile properly. I am not sure exactly why yet. For instance, if I use else (); (just one semicolon) it doesn’t print anything, even though it compiles. Usually the semicolons are required on the toplevel, but on scripts it shouldn’t be always needed. If you know something about this, let me know in the comments. ...

March 24, 2017 · 1 min

Compare Triplets in OCaml

Hi there! It has been a while since I played with OCaml, so I am solving a simple problem from HackerRank. The problem says the following “Alice and Bob each created one problem for HackerRank. A reviewer rates the two challenges, awarding points on a scale from 1 to 100 for three categories: problem clarity, originality, and difficulty”. For each category, we must check who had a greater score and give a point to that person for each category. This way, the maximum grade is 3 and the minimum is 0. An example input/output is: ...

March 24, 2017 · 3 min