Latest posts

Luca Lanziani

Read file in chunks in bash

How to read a file in chunks. You can optionally specify the starting point and the chunk size.


function read_file_in_chunks { # FILENAME [START_FROM_LINE] [CHUNK_SIZE]
   FILENAME="$1" && shift
   START_FROM_LINE="$1" && shift || START_FROM_LINE=1
   CHUNK_SIZE="$1" && shift || CHUNK_SIZE=10

   FILE_LINES=$(wc -l < "${FILENAME}")

   while [[ ${FILE_LINE} -le ${FILE_LINES} ]]; do
       CHUNK …

Luca Lanziani

Post from mobile

Just for fun.

printf("Hello Franco");
printf("Hello Federico");
printf("Hello Enrico");

Luca Lanziani

Browser as notepad

From time to time I need to note something down, from a snippet of code to some lorem ipsum.

Of course I can open a text editor and paste the text there but is it worth it to keep another window around when I have already a browser open in …

Luca Lanziani

Juniper vpn on linux!

Are you running a 64bit linux flavor and you are having problem to connect to a Juniper vpn system, even using a 32bit firefox with a 32bit jre plugin as many online pages suggest?

I have the solution for you, it is openconnect:

sudo openconnect --juniper https://endpoint

that is …

Luca Lanziani

It's a Trap!

I do a big use of shell scripts, and many of them contain a for loop, do you know what normally happen when you press CTRL^C and the script is executing an action inside the loop?

for i in test{6..10}.com; do
    echo "pinging ${i}"; ping -c …

Luca Lanziani

Gmail signature

For a while I had no signature on my email then I started to add a simple "Luca Lanziani" and now I have the following format:


Luca Lanziani - Software Engineer
e-mail : [email protected]
site :
skype : luca.lanziani

It is a simple html table with some inline …

Luca Lanziani

Python - validate command line args

Ok, in the last article I've shown you a tool to write a nice command line interface, but it doesn't help you on validation.

    level = int(args['--log-level'])
except ValueError:
    raise ArgsError('--log-level has to be a valid integer')

Manual validation? There is a much better way to do …

Luca Lanziani

Python - command line interface

How to write a better command line interface with python...

Writing the Nth python shell script I found myself looking again at the documentation of argparse, A NIGHTMARE. After 15 minutes spent trying to understand how to use it I gave up.

Is in that moment that I've found docopt …

Luca Lanziani

[Ita] Redis - introduzione

  • Quali sono le particolarità di Redis?
  • Quando conviene usarlo?
  • Come lo installo?
  • Come lo uso in nodejs?

Luca Lanziani

[Ita] Expressjs - Api per risorse

Vediamo come è possibile combinare quanto visto fin'ora per creare 5 semplici rotte che permettano di fruire di una risorsa. Introduciamo il metodo param e testiamo l'applicazione con curl.

Capiamo inoltre come simulare una PUT o una DELETE in caso in cui il client non supporti tali metodi.

Express-resource: https …