Besseggen ridge hike.

Some pictures from my hike.
Besseggen is actually a very nice 15k hike, it is not too harsh as long a you are not afraid of heights as I am.
This hike is well know because of the spectacular view you get when you reach the ridge itself: a glacier lake with green water on a side and a darker lake on the other side.
Besseggen is in Norway, circa 4 hours drive from Oslo.

Annunci

Libvmod-rtstatus: metriche, statistiche e vari numeri di Varnish in tempo reale.

Sono felice di introdurre un nuovo VMOD che colleziona counters e statistiche di Varnish in un JSON file e mostra questi dati tramite un’ user interface. Se vuoi sapere in tempo reale come Varnish e backends stanno lavorando, allora questo e’ il VMOD che devi usare. Questo VMOD ti permette di avere un’overview di alcuni counters di Varnish dedicando particolare attenzione a quelli relativi ai backends e alle statistiche per backend. Trovo che tutto cio’ sia assolutamente fantastico soprattutto se usi Varnish come load balancer e vuoi sapere che transazione stanno avvenendo e come Varnish sta performando.

Il VMOD si trova qui: https://github.com/varnish/libvmod-rtstatus.

Il VMOD ha due funzioni:

  • rtstatus(REAL delta): questa e la funzione responsabile della creazione del JSON file contente counters, statistiche ed altri numeri. Il parametro delta viene utilizzato per calcolare hitrate e request load, questi sono valutati su basi differenziali.

json

  • html(): il JSON file creato dalla sopracitata funzione viene passato a questa funzione che lo utilizza per creare una UI.

frontend

Riguardo quest’ultima funzione vorrei aggiungere che si tratta di un c-wrapper per un’applicazione HTML/Javascript. Questa applicazione viene presentata a Varnish come una grande stringa che poi viene utilizzata per generare un synthetic object in vcl_synth. La UI proposta nel VMOD e’ quella di default, ma puo’ essere modificata a secondo delle esigenze.
Per utilizzare il VMOD dovresti scrivere nel tuo VCL qualcosa del genere:

import rtstatus;

sub vcl_recv {
        if (req.url ~ "/rtstatus.json") {
                return(synth(700, "OK"));               }
        if (req.url ~ "/rtstatus") {
                return(synth(800, "OK"));
        }
}
sub vcl_synth {
        if (resp.status == 700){
                set resp.status = 200;
                set resp.http.Content-Type = "text/plain; charset=utf-8";
                synthetic(rtstatus.rtstatus(5));
                return (deliver);
        }
        if (resp.status == 800) {
                set resp.status = 200;
                set resp.http.Content-Type = "text/html; charset=utf-8";
                synthetic(rtstatus.html());
                return (deliver);
                }
}

Raw food diet is bad for you!

I’ve been eating raw food for the last 5 days. I don’t really believe in those hipsters’ diets, but I decided to try it out to check if it is actually GREAT for the body and the mind. It is NOT.
The rule is simple: eat what you want as long as it is raw or cooked under a temperature of 42 degrees. This means you can’t have things such as potatoes; well, you can have them but you need to put them in the oven for at least 8 hours before they can be eaten. No, this is not doable if you have a job.

What have I been eating? Mostly green vegetables, I felt like a cow, feeding myself all they long, unable to work out as usual. I had to eat once every hour to survive.
I refused to make things such as zucchini’s lasagna or raw vegetarian hamburger; goddammit if you have to make those stuff then you are definitely not happy with your choice of having just raw food!!
The good things are that I’ve discovered some nice recipes(zucchinis with pesto sauce at bottom)and that I’ve lost 1kg in 4 days, so this diet is actually great if you want to loose weight, but it is bad for everything else!
Having a balanced diet is still the best choice you can take, please allow yourself to eat everything in the right doses.

Raw food people says the human body is not made for cooked food, this is bullshit: the human body is not made for industrial products or colourants or hormones used for feeding the animals we then eat, but it is absolutely made for consuming any kind of food.

Zucchini with pesto sauce(for 1):

  • 1 small zucchini, ends trimmed
  • 1 cup packed fresh basil leaves
  • 1 cloves garlic
  • extra-virgin olive oil

What to do:

  • Use a julienne peeler(if you don’t have it a potato peeler is fine)to slice the zucchini into noodles.
  • Combine the basil and garlic in a food processor and pulse until coarsely chopped. Slowly add the olive oil in a constant stream while the food processor is on. Stop the machine and scrape down the sides of the food processor with a rubber spatula. Season with salt.
  • Combine the zucchini noodles and pesto. Toss until zucchini noodles are well coated.

zucchini

Varnish come load balancer e sessioni “sticky”.

Versione originale di questo blog post (in inglese): https://www.varnish-software.com/blog/proper-sticky-session-load-balancing-varnish – scritto da Per Buer.

Assumiamo che state usando varnish come load balancer e che la vostra web application abbia necessità di mantenere determinati “dati”(ad es. un cookie_hdr)finchè la sessione è attiva. Ora, per evitare che uno user acceda a dati destinati ad un altro user, bisogna che Varnish sappia cosa sta succedendo e che una determinata sessione è relativa ad un determinato user. In pratica vogliamo che un visitatore che torna abbia tutte le volte lo stesso application server.

La soluzione è facile: basta generare una random string prima che al client(aka user che ha fatto la richiesta) venga assegnato un backend. Dopodichè bisogna rendere “persistente” la stringa generate, usando un cookie, e assicurarsi che venga ri-letta da uno user che “ritorna” sulla pagina.

Ecco il VCL d’esempio:

vcl 4.0;
import std;
import directors;
import cookie;
import header;

backend s1 {
        .host = "127.0.0.1";
        .port = "8080";
}
backend s2 {
        .host = "127.0.0.1";
        .port = "9090";

}

sub vcl_init {
    new cdir = directors.hash();
    cdir.add_backend(s1,1);
    cdir.add_backend(s2,1);
}

sub vcl_recv {
    cookie.parse(req.http.cookie);
    if (cookie.get("sticky")) {
        set req.http.sticky = cookie.get("sticky");
    } else {
        # The cookies will have floats in them. 
        # Whatever, ehh, floats your boat can be used.
        set req.http.sticky = std.random(1, 100);
    }
    # use to be client.identity in V3
    set req.backend_hint = cdir.backend(req.http.sticky);
}

sub vcl_deliver {
    # persist the cookie
    # we need to use the header vmod as there might be a set-cookie 
    # header on the object already and
    # we don't want to mess with it
    if (req.http.sticky) {
        header.append(resp.http.Set-Cookie,"sticky=bar" + req.http.sticky + "; Expires=" + cookie.format_rfc1123(now, 60m));
    }
}

Hvordan lager vi italiensk pizza.

Ok, first I’ll write this in English since my Norwegian is pretty crap, but if you want the Norwegian version just ask(sooner or later I’ll write this in Norwegian as well).

Let’s be honest pizza in Oslo is super expensive and most of the time is pretty bad, I’ve found 1 and half places serving a quite authentic Italian pizza(no, it’s not the place you’re thinking of, one it’s in the city centre and the other one is in Skøyen). Baking pizza it’s easy and cheap.
Here’s what you need:

  • white/Manitoba flour = 1kg
  • yeast(the one sold in 50gr cube next to the butter) = circa 25 gr
  • water = no more than 500 ml *olive oil(if you don’t have it, don’t use anything else)
  • sugar= half tea spoon.

Put the yeast and the sugar in some(200ml) tepid water and wait for it to become liquidish, use the spoon if needed. Pour the flour in a pot and then, in the middle, pour the 200ml of water with yeast. Add salt(let’s say 1 tea spoon, but this really depends on tastes, you can add the salt later).

Start massaging the dough. Add 100 ml of water. Keep massaging. The dough has to be compact and not wet. At this point you can add some more water, but don’t make it soak! (I honestly never use more than 400ml of water). Add 2 spoons of olive oil, if you have it. Keep massaging for other 15 minutes.

Now the dough is a compact, regular ball, take it, put it in a pot and “store” it under your duvet or your wool pile. Keep it there for at least 4 hours. After this time the dough should have doubled its size. Now you can use it for making your pizza!! (From 1Kg flour you should get 4 regular pizzas).

Cut the giant dough in 4, and massage again each mini dough. Roll out the dough shaping it as an Italian pizza,thickness should be between 4mm(if you like it thin) and 7mm(if you like it tall).

Topping: Just use “polpa mutti”,600gr are enough. Add some olive oil, salt and origan. Remember you can taste while cooking!! Now, put 3/4/5 spoons of this tomato sauce on your regular round pizza. Meanwhile the oven should have been switched on to the top temperature (pizza has to cook faster than possible). Chop down some mozzarella(no other cheeses allowed) and add it to your pizza. When the oven is ready put in your pizza(on a tray) and let it cook for 5/6/7 minutes. Your result should be something like this!

Libvmod-bodyaccess: un VMOD per accedere e modificare il req.body

Recentemente ho lavorato su un VMOD, chiamato libvmod-bodyaccess che ti permette di accedere al request body.
Il VMOD ha un set di funzioni che espande la funzionalità(già esistente) di buffering il request body.
La cosa cool di questo VMOD è che, “raccogliendo” il request body puoi farci un pò quello che vuoi, ad esempio regular expression matching o cache su POST/PUT requests, prima di spedirlo a Varnish o ad eventauli backends.
Il VMOD è disponibile per Varnish 4 e Varnish-Plus 4 e, per ora, ha 4 funzioni:
buffer_req_body(BYTES size): buffers il request body se è più piccolo di “size”.len_req_body(): ritorna la lunghezza del request body.

rematch_req_body(STRING re): regular expression match sul request body.

hash_req_body(): aggiuge body bytes all’input dell’hash key.

Il VMOD con esempi e documentazione può essere trovato qui: https://github.com/aondio/libvmod-bodyaccess.

Il blog post in inglese e con maggiori dettagli può essere trovato qui: https://www.varnish-software.com/blog/introducing-libvmod-bodyaccess-reqbody-access-functions.