Lazy Developer Portfolio

I'm a professional freelancer, and it is useful to highlight my activities for self-promotion. Most of my peers have some kind of online portfolio listing previous works and personal projects, and so I do on my website. But I'm also a lazy developer, and often I forget to keep it up-to-dated and meaningful. So, I've just deployed a little script to do it for me. You can find the code here. The concept is: all items are listed in a sources.json file, with informations about the repository where the…

Keep reading

UDisks2 Python Automounting

Yet another full evening spent reading forums and mailing lists trying to hack together a few lines of code. Thanks, DBus. The following Python snippet auto mounts USB drives (I needed on an appliance with no any running evoluted desktop environment doing it). import dbus from dbus.mainloop.glib import DBusGMainLoop DBusGMainLoop(set_as_default=True) bus = dbus.SystemBus() def callback_function(path, interfaces): try: obj = bus.get_object('org.freedesktop.UDisks2', path) iface = dbus.Interface(obj, 'org.freedesktop.UDisks2.Filesystem') path = iface.get_dbus_method('Mount', dbus_interface='org.…

Keep reading

Transparent Caching of Eloquent Models

In a Laravel application I had to iterate a large set of items and, for each of them, access to a related other item which, in most cases, is selected within a smaller set. The reference example: a lot of food products, each having a unit measure such as "kilos", "liters", and a few others. $products = Product::get(); foreach ($products as $product) { echo $product->measure->name; } This triggers a new query for each access to the measure attribute of each $product, since each product has be to populated…

Keep reading

Fullscreen Navigation

Me: Well, it's 10 days to the deadline. Back-office panels are mostly done, but still I've seen nothing about design. Do you have some template, a mockup, a wireframe, a layout drawn on a Post-It...? Designer: Errr... Nope... But it have to be like this. How elegant! How smart! Do this. As usual, designers have no idea about what they are doing and what they are asking. And a pretty simple website expected to be published in a short timespan became an implementation challenge within five minutes, with a mere…

Keep reading

The Perfect Object Storage

Me: Will this stuff be hosted in AWS? $Customer: No, we are going to host on infrastructure of $PopularTLCOperator! $PopularTLCOperator: Yes, come to us! Me: Fine. Do you have an Object Storage? $PopularTLCOperator: Errr... Nope... In this way I started my review of existing solutions for DIY files storage and management. And of course I began looking for something interoperable with AWS S3 API, the de-facto standard for that kind of activities, supported by the Flysystem abstraction layer included in Laravel. First option: Swift, the object storage included in OpenStack.…

Keep reading

Creative

Given that I'm now an autonomous and independent freelance, I had to choose a logo for myself. I'm not a designer for sure, but I like to try and above all play with Inkscape. Following the many iterations through I worked on, with advices by my wise girlfriend. .............. and the final result.............. As you see, the hammer has been included almost from the beginning: I liked the idea of using a symbol so uncommon in my field of interest (ICT, of course), yet so common in my routine language: "hammering…

Keep reading

WKT to SVG, the Hard Way

I needed an SVG with boundaries of "circoscrizioni" (administrative sub-municipal areas) in Turin (the city in which I live). The only thing I found was a CSV with the coordinates, in WKT format. "No problem, for sure a geo-hacker published some tool to convert the data!", I thought. I was wrong. A lot. The only hint I found, aside installing dedicated geo-applications and import and modify and correct and export random stuffs, was about crunching the informations with a JS library to convert them in GeoJSON, then use another JS…

Keep reading

CryptoLocker vs Photorec

A very short note about a very hot topic: ransomware viruses spreading across the Internet. Some day ago a man bring to me a USB disk infected by one of those malicous applications, asking to recover the many family photos collected there (of course, stored in single copy). I had no way to decrypt encoded files, and little experience with that kind of issues (you know: I use Linux...), the only idea I had has been to pass the disk with photorec, popular and powerful recovery application able to scan…

Keep reading

Cookies from the Dark Side

I spent some hour trying to get Laravel and Varnish live together peacefully, and mixing various sources from the web I obtained some result. The base issue is that Laravel drops a session cookie for every users, even when not authenticated, and this fools any evaluation about pass/hash contents in Varnish. The secondary issue (more related to my own deployment) is that authentication happens via OAuth through another instance, so I cannot just relay on pass'ing POST login requests and replying a doors-opening cookie. Mashing up many ideas and…

Keep reading

ReloadOrRestartUnit

Given that I just spent two hours to write three lines of code, I share here my initial problem and the final solution for those looking for the same thing in the future (including myself). The problem is: in a graphical Python application running as a normal user, obtain authorization to restart a system service. The quick and dirty solution involves the execution of a command starting with gksu, but this method has been discouraged in favor of PolicyKit. So I started looking for PolicyKit documentation. Which lacks any viable…

Keep reading