Hacktoberfest 2016

hacktoberSome days ago ended Hacktoberfest 2016 an event created by DigitalOcean in partnership with GitHub.  The event is a month-long celebration of open source software where  the people are invited to contribute towards issues on projects hosted on GitHub in order to help move the them forward. The contributes can be bug fixes and documentation updates. Who contributes with 4 pull-request win a free, limited edition Hacktoberfest T-shirt.

Unfortunately I win just the sticker pack (like the other participants), but I like to participate to it. I always think that is important to participate on open sourced project but usually I do very few things about it… probably due of my bad time management, too many ideas that I want to do and sometimes the need to just relax on couch or go around somewhere (if I remember correctly it is called “live”). Anyway I really appreciated the initiative and I will participate again the next year, hopefully to win the T-shirt :).

[UPDATE 11/January/2017]


Pubblicato in open source, programming | Contrassegnato , | 1 commento

Passing a Python callback to C++ in Cython


in these days my work involve the porting of one of mine C++ library to Python, to accomplish this I’ve used Cython. The use of Cython is simple and very well documented but I’ve encountered a problem porting a callback from C++ to Python so I’ve decided to write down a post about my problem and the solution that I’ve adopted.

C++ Library

The library that I’ve wrote is a client library used to communicate with a server, it provide a class with a very poor API, the meaning of this library is out of scope but below you can find the basic actions provided by the library.

class ClientLibrary{
    init(std::function<void(const unsigned int &, 
                            const std::string &)> log = nullptr,
         unsigned int log_level=NORMAL_LVL);
    connect(const std::string &ip, unsigned int port);
    ...  // others methods

As said it has a simple API, just one function has need of explanation, the init(). This method initializes the library (or class) itself, it accept a function pointer and an unsigned int. The first parameter is used in order to let the user specify its own  custom log method and the second to set the level of the log in which is interested.

Let the user to specify its own log method is important, in this way it can save it on file or handle some casuistry in some way. The constraint is that the function specified must accept as first parameter an unsigned int and for second parameter a string, these are the log level  and log message.


The problem is that the porting in Python use Python code (well… kinda obvious) which C++ library don’t understand. In fact even if you use Cython some where you call the C++ code of the original library, in this case it means that when the user pass the callback in Python the C++ part get angry because it expects a function pointer.


To avoid it I’ve created a  Men In the Middle function with the same interface expected from a log callback function in C++ which call the Python callback.

# create a MIM function for log callback
# it has the same interface expected from C++ version
cdef void log_mim(unsigned int log_level, const string message)
    pylog_cb(log_level, message)

# Python class
cdef class PyClient:
    def init(self, log_cb=None, log_lvl=0):

        if log_cb is not None:
            # Python 2.x support
            if not callable(log_cb):
                raise TypeError("""The first parameter MUST
                                   be a function.""")
            # store the Python callback on global variable
            # pylog_cb
            global pylog_cb
            pylog_cb = log_cb
        return self.client_ptr.init(log_mim, log_lvl)

The init method accept a callback  log_cb and the log level log_lvl, the first is stored on the global variable pylog_cb. At the end it will call the C++ init passing the function log_mim. When the C++ code will call the callback log_mim (C++ function pointer) it will call the Python pylog_cb.


This solution to “callback problem” works pretty well, the MIM function allows to avoid the incompatibility between the 2 languages.

On PyClient is missing all the source code about the allocation/deallocation of the object and how to link Python and C++ code cause it is beyond the scope of the post.

Pubblicato in programming | Contrassegnato , , , | 2 commenti

Linkedin is not Facebook

today I’ve received the N e-mail from Linkedin which says that someone on my Linkedin network has confirmed or “added” a skill on my profile even if he/she doesn’t know the field in which I work and/or doesn’t know anything about my skill. so I’ve decided to write down a post about how the people is using Linkedin. First of all Linkedin is not Facebook hence stop adding useless post which not regards your work, field, hobby or something that has any sense; I don’t belive that a video with kittens has something to do with your job unless you’re a vet. As others social networks which makes use of reputation (that will be ‘like’, karma points and so on ) on Linkedin happens that the people share the ‘skill validation’ between them, a user endorses the skill of another in order to have a skill validation too. This kind of behavior do not help Linkedin and its users because the skill endorsement lost its value… ok in my work (sw developer) I don’t belive in something like ‘skill validation’ on social network anyway, in fact I prefer to see the source code or something else (documentation, tests etc) that give to me the idea of the capabilities of a person. For these reasons I don’t accept the endorsement of persons that don’t have the skill to understand my work (even if they don’t do my same job they can be a great developer even if they do it for hobby) or that haven’t see one single line of my code or haven’t worked with me (for hobby or job). I guess that everyone should at least ask himself  if the ‘skill validation’ of someone has any sense and not try to collect as many as he can ( we’re not playing to Pokemon so we can’t have to ‘catch em all’). So be honest with yourself and accept only the endorsement from people who you know and make honest endorsements.

Pubblicato in Uncategorized | Contrassegnato , | Lascia un commento

An unexpected Alibaba


today a friends of mine suggests me to make a challenge between Google and Alibaba on my site GitHub Battle. Well long story short the challenge was won by Alibaba; OK I admit that the formula used to compute the score isn’t perfect and some parameters may missing but anyway it has highlighted the fact that Alibaba is a great contributor about open source and has a great number of repositories. This is an unexpected event, well at least for me, and this made me think that GitHub Battle can be used in some way to discover some particular/funny event. So until I make some improvements I will ask you to notify me if you find something that seems interesting while you are using GitHub Battle :). At the end of this post you can find a screenshot about the “challenge” between Google and Alibaba.


Pubblicato in Uncategorized | Contrassegnato , , | 1 commento

GitHub Battle


some time ago I’ve seen the site Github Awards. This site shows the rank of GitHub’s users, you just need to write the username of a user and it shows his world, national and city ranks for each programming languages that he used. I’ve played a little with it, looking my ranks and the ones of my friends so after a while I’ve started to thought to see who, between me and my friends, have the highest rank. Well from that idea I came up with a site which allows anyone to make challenge 2 GitHub’s users and see which one has the highest score. The way in which the score is computed is quite simple and different from the one used in GitHub Awards. The site compute the score for each repository using the following formula:

repo_score = stars + 1.5*forks + 0.2*watchers

the scores are grouped by programming languages and the total score is the sum of all programming languages score.
For which is interested to play the site is available at GitHub Battle instead for which wants to contribute can find the repository on GitHub.

Pubblicato in programming, Projects | Contrassegnato , | 2 commenti

SCTR a tool for reporting tagged comments


today I’ll introduce you my new project called SCTR (Source Code Tags Report). This project is born, as usual, due my laziness and bad memory. In my current job I work both in front-end and back-end part, each of them composed by different part i.e. different services written in C++ (for back-end) or JS/HTML (for front-end). So I’m moving frequently, really frequently, in different files due the current priority, so to not forget what I should do I put comments with tags (Wikipedia). May happen that some TODO, FIXME etc will be forgotten in the mass of code because I’ve changed where I’m working on and/or, as I said before, due my bad memory. Thus my code have, for my sake, comments with some tags but I didn’t remember in which files they are. Long story short, to avoid this I’ve write a script in Python which parse a file or a directory searching for tags and reporting them in a file. For readiness the report is a HTML file which shows for each files there are the comments body grouped by tag name as showed in the example below.


At the current version the script recognize TODO, NOTE, XXX and FIXME tags and .cpp, .h, .py and .js file. Anyway it is easily customizable, in fact you can add your own tags and new file type (with its own comments style). Everything is explained in the README file.

You can download SCTR on GitHub.

Note: SCTR was used to collect the comments of SCTR itself.

Pubblicato in programming, Projects | Contrassegnato , | 2 commenti

Italians do it not so bad

Here in Italy may happens to hear people say that to do something good, in the world of IT, you MUST go away from Italy or at least go in a big city like Milan, Rome, Turin etc.
Well I don’t think so because in the world of IT distances do not exist or perhaps are resized. I think that if you have a good idea you can do it in your own home, thanks to the NET it can be reached everywhere and if it is an interesting project collect a set of fan/contributors/etc. In order to discredit this common belif I’ve decided to write about some italian people who are part of that set. Obviously they are not the only ones so I would appreciate all your reporting.

Salvatore Sanfilippo (antirez)

Salvatore live in Sicily and it has created Redis (REmote DIctionary Server) the most popular key-value store. I heard about him watching Hacking Italia, a news collector similar to Hacker News. I suggest to take a look to his blog, there you can find very interesting post about Redis evolution and something else.

Luigi Rizzo

I was lucky to have had him as a university professor and followed his course. I think that has worked in almost every field related to IT, his knowledge is impressive and even if many will turn up their nose reading the following I really appreciated its course and I find the topics he mentioned well-treated, complete and not at all dated. He did a lot of things to talk about all; here I report the last one, a framework for high speed packet I/O called netmap. For more information take a look to his personal page.

Marco d’Itri

It’s very active and well known in the Debian world, many people know him thanks to his whois client that is used as default in every Linux distribution. He’s the maintainer of about 20 debian package.

You can follow his twitters here.

You can find an article about the first 15 years of his whois client here, look for Fri, 3 Oct 2014.

Luca Deri

He is a reasercher of IIT-CNR of Pisa and he’s the creator of ntop a software for network monitoring that shows network usage in a way similar to what top does. Take a look even to his personal page.

Vincenzo Colucci

He’s an Android developer who lives, and works, in Manfredonia (his hometown). He developed SmartLauncher, a famous launcher for Android phones, that counts about 10-50 milions of download. You can see here a video made by those of Google which tells about his story.

NOTE: the title of this post wants to be a contrast about the phrase “Italian do it better” and the common belief that I mentioned above.

Pubblicato in Uncategorized | Contrassegnato | Lascia un commento

I’ve no Internet connection at home


In May/June 2014 I’ve changed home, I decided to go to live alone in an apartment because I found a job at C.N.R. of Pisa (maybe I’ve already talked about this). I thought that I would stay only a year and I thought that I would be always at work or to train ( Karate Shidokan) or walking through the city (I really like walk.. I can’t stay at home). Thus I will be never at home so I decided to not have any Internet connection in it. Now I’m starting the second year at work, so my prediction was wrong, but the decision to not have Internet connection at home isn’t completely wrong. Ok,  I admit that sometimes I will appreciate to have some full functionally connection (may happens in a while that some of my neighborhoods use some WiFi connection without any protection… thank you) but this force me to do something else without fall through the ocean that is the Web.

When I work at home for one of my, sadly many and incomplete, side projects I can focus on the problem and try to solve it without being groped by the solutions on the network or let me stray from some post interesting but not relevant. Just say above, I don’t like to stay at home and instead I prefer to go out and take a walk , seeing people , my friends, etc. So in the weekend may happen that I go to some cafe that a hot chocolate/coffee/slice of pie and work using the WiFi connection. It will be right for me, I can search new cafe, try something new and work in a comfortable place and use the WiFi :D. So at the end my decision isn’t so bad.

Now begin the problem of what I use to work… I have a 14″ notebook of Acer with Debian on it. It is a good notebook but I’ve some problem with the battery consumption; with WiFi is about an hour and many of cafe doesn’t allow to plug it in to the power grid, well for me a work session shouldn’t be more than 2 hours thus I can design for an hour and use the other one to develop but even in design part I may have the necessity to check something on Internet. In addiction my laptop weight is about 2kg so in these days I’m looking for a replacement, something with a more battery duration and maybe less weight. It isn’t a easy choice because I’m starting just now to understand what I need for, but maybe I will talk about this in a future post.  

Pubblicato in Uncategorized | Lascia un commento

My old master degree thesis


Occasionally I check the web pages of my college professors in order to see what they are doing. Usually I see the pages of Luigi Rizzo and Gianluca Dini. The first should be well known in the IT world, instead the second one was my supervisor of my master degree thesis. Looking on Dini’s page I saw something very interesting a link to a page about ASF++ and surprise it is the project of my master degree thesis. I’m happy to see that the project didn’t die after my graduation but now there is another person (except Marco Tiloca) who works on it. There is a link to github page so I decide to fork the project in order to contribute again; for now my contributes are focused to respect the PEP8 style.

If you’re interested to take a look or contributes here you can find my fork on GitHub.

P.S. I admit that the first thing that I’ve checked on source code was if my name appear in the files in which I’ve worked on.

Pubblicato in Uncategorized | Contrassegnato , , | 2 commenti



today I will spend some words about the project Portolan. This project born with the efforts of the University of Pisa and the Informatics and Telematics Institute of the Italian National Research Council (IIT-CNR). The aim of this project is to discover the topology of Internet with the contribution of volunteers.

Portolan is a crowdsourcing-based system that use smartphones (Android only) and desktop computers as measuring elements. So the system ask to your device (PC and/or smartphone) to perform some measurements, in order to accomplish their goal, and in exchange their provides you some diagnostic network tools like Ping, Traceroute, BitTorrent Test etc. I’ve used this application and for the ones who are worried about the battery life of the smartphone the measurements are limited, in fact your smartphone can perform a fixed number of measurements, and if the smartphone has less than 20% or 30% (I don’t remember) the app doesn’t perform any measurements request by the system.

I think that you should download and install at least one of the version of the application, may be the desktop if you’re worried about battery life of bandwidth consumption, because it is important help the research in some way. Anyway if you’re not sure check the page of the project, the link is at the beginning of the post.

Have a nice day

Pubblicato in Uncategorized | Lascia un commento