Overcomplicating Images

Sometimes a user's "It doesn't works" becomes a story. This "It doesn't works" was about uploading images on a website. A simple task to achieve, which becomes a little more complex when a live preview is required by the usual "I need images in every page! Big images! Always!" designer. And degenerates in a complete pain in the ass when are involved photos coming from a smartphone. Somewhere, somehow, someone decided that photos (in particular, those shooted by a smartphone) had not to be saved in the final format by…

Keep reading

They Are Many

In a complex Laravel application I'm working on, I had to implement a dynamic system to integrate external and heterogeneous sources of data. So I built on the ServiceProviders feature provided by Laravel and created a ContentsDriver abstract class including the internal events handling flow and to be extended by the different effective files each implementing a source. Now I have to dynamically create those drivers on behalf of a configuration got from the database, and the whole construction breaks down: each ContentsDriver handles a single source, I would have…

Keep reading

Electrified

Recently, I wanted to prototype a simple desktop application to manage color palettes on Linux. So I fired up GNOME Builder, enjoyed his scaffolding feature for a new GTK+ Python application (still incomplete when compared to the previously mentioned tool, but far easier to use), and... as usual, I got lost on GTK+ Python documentation, trying to figure out how to obtain a proper ListItems for the initial menu using an (apparently) convenient GtkBuilder XML file. After half an hour of frustation I decided to catch the opportunity and try…

Keep reading

DNS, The Masquerade

Scenario: a RaspberryPI primarily acting as access point, assigning IPs by DHCP and catching all DNS requests to redirect all HTTP traffic to himself, which may eventually switch to connect as a client to an existing wireless network (and delegating DHCP and DNS to another access point). 90% of this stuff may be easily achieved with nmcli, the powerful and convenient command line interface for Network Manager. nmcli c add type wifi ifname wifi-device con-name myconnection \ autoconnect yes ssid myconnection nmcli connection modify myconnection \ 802-11-wireless.mode ap 802-11-wireless.band bg…

Keep reading

Signed in Blood

As I'm now a business holder under the Italian laws jurisdiction, I had to ask a legally recognized "digital sign": a USB key containing some spare applications, libraries and a set of public and private certificates to produce recognizable digital signs identifing myself. The certificates are in an unknown and very specific codification, so the embedded applications are required to actually use them: a classic RSA key pair GPG-style would have been to easy... Today I've been to the local "Chamber of Commerce" to obtain my personal USB key, as…

Keep reading

Assets Minification Salt and Pepper

Recently I discovered this awesome Laravel module to minify and aggregate assets. My only issue was about generated hashes for aggregated files: as I had to distribute the files on different balanced servers I could not depend on mtime timestamps to salt them (as last git pull time could slightly change on different servers), I could not leave the hashes depending only on original filenames (as they never change, and so did the hash, leaving rotting copies of the assets on the users' browser caches), so I had to leverage…

Keep reading

The Distro You Like

I need to get some practise with d3.js, the Javascript library used to display complex data and relationships, so tonight I've produced a first sample. It is a visualization of the popularity of Linux distros between 2002 and 2016, accordly to the data published by Distrowatch. The larger the circle, the more "hits per day" the distro's page got within the given year. Position of the circles is randomized at each load, so if you don't like it just reload this page. var data = [{ "2002": 0, "2003": 0, "2004"…

Keep reading

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