Mateo Gianolio

Engineering student, computer programmer and hobby designer

Read this first

Moving to

Hi, just notifying you that I have just moved this blog over to

View →

Haskell: Project Euler 6-10

Due to the popularity of my previous post on the same subject (click here if you haven’t read it), I decided to write a sequel tackling problems 6 through 10. It will be the last one about Project Euler and I hope this pair of articles will have served as a great starting point in learning Haskell.

I have been getting a lot of comments that the Project Euler website specifically asks not to post solutions online so I just want to clarify that the purpose of these articles is not denying you the epiphany of discovering your own solution. My intention is to spread the word about the combinatorial capabilities of Haskell and to introduce Project Euler to a broader audience, which I think is a perfect place to start learning any programming language.

With that out of the way, let’s solve some problems.

 6. Sum of squares

The sum of the squares of the first ten natural numbers is 12 + 22...

Continue reading →

Haskell: Project Euler 1-5

According to it’s website

Project Euler is a series of challenging mathematical/computer programming problems that will require more than just mathematical insights to solve. Although mathematics will help you arrive at elegant and efficient methods, the use of a computer and programming skills will be required to solve most problems.

I chose Haskell to solve the first 5 problems because

  • its resemblance to mathematics allowed me to focus more on optimisation and less on implementation.
  • its ability to be executed and modified in a command-line environment proved to be very helpful.
  • it seemed like the perfect way to learn a new programming language while simultaneously getting better at problem solving.

The answers are left out (no spoilers) although they can easily be obtained by running the code in ghci.

 1. Multiples of 3 and 5

If we list all the natural numbers below 10 that...

Continue reading →

Raspberry Pi: python wrapper

A YIFY-Torrents API wrapper written in python 3.41, which combined with btstream from my previous post serves as a command-line media center.


  • Python 3.41 (included by default)
  • btstream (for torrent streaming)


Options can be found here and must be separated with the & character.

python3 list <options>
python3 search <keywords> <options>


> python3 list "quality=720p&rating=7"
#   Rating  Title
1.  7.1     Across 110th Street (1972)
2.  7.0     The Spy in Black (1939)
3.  7.1     Wendy and Lucy (2008)
4.  8.2     The Fault in Our Stars (2014)
5.  7.0     Without a Clue (1988)
6.  8.1     Out of the Past (1947)
7.  7.1     Godzilla (2014)
8.  7.8     Night on Earth (1991)
9.  7.0     A Funny Thing Happened on the Way to the Forum (1966)
10. 7.4     Generation Iron (2013)
11. 8.2     The Normal Heart (2014)
12. 7.1     Roger Dodger

Continue reading →

Raspberry Pi: Torrent streaming with 4 lines of code

I recently found a tiny sequential bittorrent downloading tool named btcat and decided to use it to be able to stream torrents on the Raspberry Pi. Turns out it only required a simple bash script with four lines of code.


Install btcat on your Raspberry Pi by following the instructions on the website (but skip installing mplayer, it does not support GPU acceleration which makes it super-laggy).


Create a file with the following content and name it btstream.

mkfifo stream
btcat "$1" 0 > stream &
omxplayer stream
rm stream

You’re done! Now you can stream any torrent containing a media file simply by issuing ./btstream <torrent_url> (it needs chmod +x).

 Follow up

Check out my python wrapper using the above bash script.

Continue reading →