Sunday 31 January 2021

Bye - Adiós (Film)

I've recenlty watched another excellent Spanish film, Adiós/Bye. I've previously praised Spanish Cinema multiple times, and this is one of the best examples of its excellence in these last years.

Adios is raw and intense, sad, social... and many more adjectives, thriller/police film. It's a combination of dramas: the drama of losing a loved one, the drama of having been born in the wrong place, the drama of poverty and drugs addiction... the drama of not being able to trust those that are supposed to protect you...

The film is set in Las 3000 viviendas, and infaumous marginal area of the city of Seville. The ultra-violent images of the police intervention (I'm not talking about "police violence", but about the violence from the inhabitants) remind me a lot of French "territoires perdus - quartiers sensibles", you just have to replace gipsy criminals by maghrebian criminals... and the images of the "hotelito", a ruined building where drug addicts rot their lives away are really extreme (I guess the La colline du Crack in Paris is not much different)

There are profoundly dark sections, both in the story and in the visuals, a trip to some of the worst aspects of our society. One can trace some similarities (not only because it shares 2 actors) with Malaka, an excellent Spanish series set in La Palma/Palmilla, a deeply marginal are of Malaga. I absolutely reccommned it too.

Sunday 24 January 2021

Mieres Modern Architecture

I was in Mieres del Camín a few days ago. I had not set foot there since october 2004, when I had gone to visit an Art Exhibition in Casa Duró to commemorate the 70 years of the Revolution of October 1934 (Ochobre'l 34).

Normally you don't go to this Asturian post-industrial, post-coalmining, post-prosperous, post-whatever... small city to do tourism, as there's not much to see there for the average person. In my case, given that this small city played a role in my life in the late 90's, when I had some friends there and played with them in a band, I wanted to bring back memories from those times, see streets, buildings, shops... that suddenly would move me back to that time in my life. Additionally, 20 years ago I did not have any particular interest in architecture, at least, not in the boring buildings and streets of an industrial, mining small city surrounded by mountains that had fastly grown in the first decades of that century and had started a deep decline... now, it's something that really captivates me...

Mieres looks as I remembered it (well, as I didn't remember it indeed). For a city that size (22.000 people right now) it looks much more "urban" (most buildings have between 4 and 7 floors, with no space between them, so it's moderately dense) than any equivalente French small city, that's why I had no particular memories of its streets, cause they just look like my neighbourhood in my 12 times bigger hometown (Xixón). Of course, it has several of those 2 - 3 stories neighbourhoods (shame the bloody dictatorship did not use for this a more "soviet style" many stories approach) that were built in haste to house the miners, those neighbourhoods that you find all over Central Asturies save for Xixon-Uvieu. These "quartiers ouvriers" are a living memory of our history and are quite different from the single family houses that make up Nothern France and Belgium Corons.

I think there are very few other places that size in Western Europe (apart from its "sister in pain" Llangréu) that have undergone such a dramatic population lost in the last decades. The municipality of Mieres fell from 70.000 inhabitants in the 1960's to 38.000 inhabitants now. I don't have the old figures for the city proper, but probably the decline has not been so steep. Anyway, with 22.000 inhabitants now, I would say that at its peak in the sixties it would have at least 35.000 inhabitants. With this in mind, there are 2 things that really surprised me:

The city looks good, it looks "alive". For sure I was not expecting that the sidewalks, parks, lightning, public buildings... would look bad. The area received much money from the EU to try to mitigate the effects of the end of the old economy (coal, steel...) so any thing maintained by the city council should look OK, but I was expecting to find tons of abandoned buildings, dilapidated ones almost empty save for 1 or 2 old dwellers, closed shops... and it's not like that at all.

Some new residential buildings have sprung up in the last years, and some of them look really "fresh". They are completely different from what you see in other Asturian (or northern Spain) cities, much more in line with what you see in some recent areas of Bordeaux (Bassin a Flot), Lyon (Confluences) or Paris. Those odd black or gold metallic facades with balconies with sliding blinds... That's something totally new here. It's a pity that they didn't rise the buildings a bit more, from their 6 floors to 8 or 9 (as in Bordeaux). Investigating a bit I've found that the most appealling of these blocks even won an architecture price in Spain. All these blocks seem to be intended as social housing (don't panic, social housing here is in no way as terrifying as HLM in France), so that has probably allowed the architects to play with concepts that quite likely would have scared the average Asturian-Spanish potential buyer, that has a more traditional aesthetic vision.

Golden facade with "hidden" balconies

"Bassin a Flot" style

Not that the building on the left is beautiful, but it looks quite unusual in Asturies

Sharp contrast with the adjacent buildings from the 50's-60's

Saturday 16 January 2021

Log Function/Method Calls

Quite often it's useful to log information about function/method calls, including the parameters values. I've coded a simple function that helps me with that in JavaScript. We could combine it with some AOP stuff to wire the call that logs the information at the beginning of each function... but that's not the topic for this post and I'm doing it manually.

The code looks like this:


//self represents the "this" value
function getFnCallInfo(self, fn, ...args){
    const serializeParameter = (param) => {
        //typeof null is "Object", but typeof undefined is "undefined"
        if (param === null)
            return "null";

        switch (typeof param){
            case "undefined":
                return "undefined";
            case "function":
                return "function: " + param.name;
            default:
                return param.toString();
        }
    };
    
    let fnStr = fn.toString();
    let start = fnStr.search(/\(/);
    let end = fnStr.search(/\)/);
    let paramNamesStr = [...fnStr].slice(start + 1, end).join("");
    let paramNames = paramNamesStr.split(",").map(param => param.trim());
    let namesValues = paramNames.map((paramName, index) => paramName + " = " + (index < args.length
        ? serializeParameter(args[index]) 
        : undefined)
    );
    let thisStr = self 
        ? self.constructor.name + "."
        : "";
    return(`${thisStr}${fn.name} invoked with:\n\t${namesValues.join("\n\t")}`);
}

//we use it like this:
class French extends Person {
    sayGreeting(toName, includeLocation){
        //arguments.callee is deprecated
        console.log(getFnCallInfo(this, this.sayGreeting, ...arguments));
        .....
    }
}

let guillaume = new French("Guillaume", "Paris");
guillaume.sayGreeting("hi", true);

//output:
//French.sayGreeting invoked with:
//	toName = hi
//	includeLocation = true


I would love not having to type the name of the function being logged (this.sayGreeting) when invoking getFnCallInfo, cause if we change the function name we have to make sure we also change it in the call. In the past we could just use arguments.callee, but that's been deprecated since quite a while... Well, it's not much of a problem, if we're using any decent IDE with rename support we're done... I don't feel much like explaining the code... just see that I use the arguments pseudo array in the invokation rather than typing the parameter names (and I convert it into a normal array with the spread operator). I leverage function.toString to get the parameter names, as I had already done in this previous post

Saturday 2 January 2021

Some JavaScript Beauties 2021

Lately I've come across some pretty interesting JavaScript projects, fragments of code... whatever

This article comparing Deno with Node is a great read, but there's something that particularly caught my eye, this code:


// http-server.ts 
import { serve } from "https://deno.land/std/http/server.ts"; 

for await (const req of serve({ port: 8000 })) {
    req.respond({ body: "Hi from Deno!\n" }); 
} 

I was used to see Web Servers implemented as event emitters. You provide a callback/handler to the server.run and each time a request is received your callback is invoked, so requests are pushed to you. This Deno server takes a quite different approach, it's implemented as an asynchronous pull stream (asyn iterator). Your code asynchonously iterates over a stream of web requests. I don't say that one approach is better than the other, I just think that it's really "fresh" and interesting.

Trying to get a basic glimpse of Machine Learning I came across tensorflow.js. I particularly liked this demo.

Those demos use pretrained models, so obviously you are not running the traning algorithms in the browser, but anyway I became curious as to whether it would be possible to run code into the GPU from browser side javascript. This curiosity is due to the fact that GPUs are important in training models cause they are very good for data parallelism, and basically model training involves running the same matrix calculations on huge datasets. And yes, we have GPU.JS! The magic that allows browser JavaScript to get access to the GPU lies in WebGL.

I've known about processing-js since a long while, and I've recently found that there is a related project p5.js that takes the functionality beyond the canvas, allowing to interact also with html5 elements. One more thing added to my list of "play with it once you find some time...".