Down the rabbit hole, again…

Geremia

I have always been a great fan of Marco Vichi’s novels. The main character, commissario Bordelli, is intriguing. In one of the last novels, Dr. Diotivede, a pathologist, gives a human skull to Bordelli as a Christmas gift. The skull is then named Geremia and lives in commissario Bordelli’s kitchen. Ok, a little bit weird, I agree.

I could not resist doing the same, so I headed to Amazon and treated myself to a full-sized skull to keep on my desk as a headphone holder. Same name, Geremia.

A couple of weeks ago, I looked at Geremia and said to him, “Hey, you look dead. We should do something about that.”

Since we are in 2023, adding a couple of LEDs for his eyes, an mp3 player to make him speak, and a servo motor to make his jaw move according to the audio file played would be easy. I played a bit with Arduino in the past, which would be the perfect choice for this kind of project. I reached into my drawers and took out everything I already had. I used circuit.io to design the electronic circuit and wrote a state machine on Arduino Sketchin to make Geremia talk with my PC over a serial port. The idea is to use Geremia for notifications.

And then it started. The circuit worked perfectly on the simulator, but I was missing a voltage regulator, a few capacitors and resistors, a good servo powerful enough to move the jaw, and a prototyping board… It started. I have spent too much money on Amazon in the past few weeks to gather all the needed pieces. Now the prototype is sitting on my desk, working.

I will transfer the prototype to an Arduino Proto Board in the next few days. But, wait, I do not have a soldering station… buy one… Well, you get the point; I could not stop.

In the meantime, I browsed YouTube to get some knowledge of electronics. I found a guy who built a 4 bit computer completely on breadboards. I already know which is going to be my next personal project. For the time being, I am having fun reading “Digital Computer Electronics,” which talks just about that.

I am the product, no more

Photo by Roman Martyniuk on Unsplash

It is quite funny, but the reality is that it is incredible to realize that social media is not free anymore.

Twitter wants eight bucks a month to let me use MFA and other features that will give me the famous “blue check.”

Facebook and Instagram want twelve bucks a month to give me the “blue check” and more visibility for my posts.

So, at the end of the day, they want all of my personal data and my money as well.

The Internet is becoming a wild place.

A quick and dirty test

Photo by Artturi Jalli on Unsplash

I found myself in the position of writing a small command line Python tool for one of my colleagues. Something pretty simple. Get a contacts list from a Google Sheet and create Lead objects on Salesforce. 

Easy stuff. It should not require more than a couple of hours, testing included.

I decide to take a test with this.

I would not write a single line of code.

I describe every single function in the application as a comment and let GitHub CoPilot do the coding for me.

Well, It took twenty minutes to have the application up and running—a few tweaks here and there, mostly on prompts and error messages.

The exciting thing is that those functions are written using my programming style. Honestly, I would have written those functions in the same way. It must be said that GitHub CoPilot has access to all of my private repositories, most of them coded with Python, so it is pretty easy to guess my (not so pythonic) programming style.

It’s not the tool; it’s your brain

Photo by Josh Riemer on Unsplash

I was browsing our Slack channel this morning. I entered one of those and found a reference to useGalileo.ai. 

The basic idea of this service is to write a sentence that describes the UI design you need, and it will provide you with a complete UI design that you can edit later in Figma. 

I guess that out of the box, you could think: “The designer job is going to die!”

Read the previous sentence carefully. There is a verb: think. 

That’s the key.

The most important responsibility of a designer is to think, not to build a nice-looking UI design. That’s the last part of any project, like 10% of the total work. It is pure execution. Be careful; I am not talking about the design language you will use in your UI design. I am talking about asset production.

If there is something that, in a more or less smart way, can cut off production time, that’s welcome. I would be keen to pay for it. 

The reality is that the designer’s work is being able to write that sentence. And that’s where the talent resides. And the money too 😉

A blog in 2023?

Photo by Cristian Siallagan on Unsplash

I have written a couple of times about why correntedebole.com still exists.

It costs me a few hundred bucks every year. I could find some cheaper hosting, but I am comfortable with who I am right now, and I can also run some personal things over there that are not profoundly exposed. 

From time to time, I have to argue about this approach. These are the most common comments I get:

  • It is a waste of money.
  • There are dozens of spaces where you can write for free.
  • Having a personal blog does not make any sense in 2021, 2022, or 2023…

Yes, it costs me money to run the blog. I need hosting space and an SLL certificate. The point here is that it is my own space. I administer it, and I can run the software I like the most on it. 

Yes, there are dozens of spaces where I can write for free. LinkedIn, Facebook, Medium, and Twitter, just to name a few, where I republish what I write on Corrente Debole. 

There are big disadvantages to doing so:

  • Not in every place what I write is going to be mine. 
  • If they are free, they probably monetize my writings somehow. I am still fine with the current terms, but these terms may change over time.
  • I have to comply with the Terms and Conditions of the site where I write. I have never had issues with those, but again, those terms may change, and I want to be free to publish whatever I want.
  • Those free space may change their attitude towards users, and it is their absolute right to do so. Again, I want to be free. Look at what happened on Twitter in recent times.
  • Does it make sense to have a blog in 2023? The answer is definitely yes.

So, as far as I will have the money to keep Corrente Debole alive, it will continue to exist.

On being laid off

Photo by David Clode on Unsplash

Being laid off sucks. I have gone through it, and it definitely sucks.

You are being laid off even if you have successfully reached your goals.

I still remember every minute of that day as if it were today.

I remember the people around me not being able to look into my eyes as I walked away. The removal process had already begun in their minds.

I remember driving home with my card boxes, trying to figure out how to tell my significant one I no longer had a job. 

At least it was a human being telling me I was fired. If you consider a General Counsel a human being, he was a human.

I did not sleep that night, but I remember that I got out of bed thinking: “Well, your loss. I know what I am worth. Fuck you.” 

It was tough.

The news spread fast. After a couple of days, I started receiving offers from other companies. I decided to take six months off before thinking about my next move.

I understand how thousands of people feel when they are fired from big tech companies. The numbers are impressive. It is estimated that more than 107.000 people lost their job between 2022 and 2023. 12000 by Alphabet, 18.000 by Amazon, 3740 by Twitter, 9090 by Salesforce, 4100 by Cisco, 11000 by Meta, 10000 by Microsoft, and 3900 by IBM, to name a few. If you are strong enough, you can read the numbers here.

It is interesting to look at how these big tech companies laid off people. Some of them disabled physical access to the workplace, others just fired an e-mail, others held an all-hands meeting, and others locked out people from their work accounts or locked their company’s personal computer.

If you are going to fire thousands of people, is there a “correct” and “fair” way to do it? Every company I cited before has critical assets they need to protect when an employee is fired. Think about it multiplied by thousands.

No, there is no good way to do it.

It is also interesting to notice that while you are firing thousands of people, you are running an event with a concert from a celebrity, or you just announced a 10 billion dollar investment in another company.

Corporate inconsistency.

So, do companies have to have a soul? That is not the case. The distance between how companies represent themselves and how they really are is still abysmal. This is true for every company size.

There must be hundreds of managers that had to make a decision on who and when. Did it hurt? I don’t know. I have been there, and it is the most challenging thing I have ever managed. As I remember the day I was fired, I remember the day I fired someone. 

Being laid off sucks. 

What I can say to those people is to look ahead. I went through it, and it was not easy, but it was the only way.

If I can help any contacts, even with a friendly chat, do not hesitate to get in touch. 

WiFi is looking at you

Photo by Misha Feshchak on Unsplash

You can detect people’s location in an area with WiFi coverage since years ago. Retailers were looking at it to understand customers’ behavior in their stores. Triangulation over airwaves is not new.

I came across a research paper: Dense Pose From WiFi.

An interesting read.

The basic idea is to determine human pose using inexpensive hardware like WiFi routers.

Here’s what you can do:

Given three WiFi transmitters and three aligned receivers, we can detect and recover dense human pose correspondence in cluttered scenarios with multiple people.

The researcher states that they can do this with a couple of WiFi routers at around 60 US dollars. Interesting.

You can easily detect and monitor people’s behavior using video cameras. It is as cheap as the solution documented by Carnegie Mellon University researchers. The main difference is those video cameras come with more significant privacy problems. People can be identified and tracked over time. Something, I guess, is intended.

The WiFi solution can be considered much more privacy aware than video cameras.

While I was reading the paper, I was impressed by the result. Just look at the pictures in the document to understand the potentiality.

I am impressed by what you can achieve using inexpensive hardware and open-source software. If you have the knowledge, you can build advanced systems that, a few years ago, were available only to big companies and government agencies. 

This is really exciting to me. 

Here’s the link to the original document: Dense Pose From WiFi

Debugging Streamlit with PyCharm

Photo by path digital on Unsplash

Streamlit is a Python package that allows you to build beautiful dashboards from Python without the need for a deep knowledge of front-end development. This is my case. I have never been interested that much in front-end development. I was, and I am a backend developer type.
Since I am playing with different data coming from our systems, I found Streamlit incredibly useful for organizing and visualizing the data I collect. You can run your dashboard locally and deploy it in the cloud when you need to share it with others in your organization.
I love PyCharm, which I use for my Python development.
As for every application, you need some debugging to ensure you are doing the right thing.
When you develop locally, you run a local Streamlit, dedicated web server. How can you debug my script in PyCharm?
I spent some time thinking about it and found a solution that may be helpful to other people out there. This will work in Visual Studio Code as well, but I didn’t try it since I don’t love Visual Studio Code so much.
You can add a Run/Debug configuration to PyCharm like the one you see below:

PyCharm – Add Run/Debug Configuration

Now you can set your breakpoints in the script and debug it as you usually do in PyCharm.

Home Assistant and NFC Tags

Source: Wikimedia Commons

I am experimenting with NFC Tags and automation on Home Assistant. I have bought a few writeable NFC tags for these experiments. They are cheap, but I wouldn’t say I like wasting them while testing.

Since Flipper Zero can simulate NFC tags, I decided to use it for my tests.

If you want to do the same, here is what you need to do.

Flipper Zero stores NFC Tag data in a plain text file with a .nfc extension. There is a simple command line python script that allows you to write an NFC tag in the Flipper Zero format. Thank you to evilpete for making this available.

#!/usr/bin/env python
"""
    Generates NFC with URL address data and outputs Flipper NFC "save" file
    this is a 5 min hack, No Guarantees

    ./nfc_gen_url.py https://youtu.be/dQw4w9WgXcQ "Rick Roll" > rickroll.nfc

    requires ndeflib

    Written By: Peter Shipley github.com/evilpete

    From pkg https://github.com/evilpete/flipper_toolbox
"""

import sys

try:
    import ndef
except ImportError as e:
    print("Failed to import ndef")
    print("https://github.com/nfcpy/ndeflib")
    sys.exit(0)

# make sure output is utf-8
sys.stdout.reconfigure(encoding='utf-8')

# for debuging
verbose = 0

nfc_header = """Filetype: Flipper NFC device
Version: 2
# generated with flipper_toolbox
Device type: NTAG215
# UID, ATQA and SAK are common for all formats
UID: 04 10 56 01 74 48 03
ATQA: 44 00
SAK: 00
# Mifare Ultralight specific data
Signature: A5 80 A4 CC A0 C3 A1 F6 8B BE 6F EE 83 A6 B9 EE 36 F8 FB C8 14 5A 23 AA 29 DB 78 56 07 B9 6B 92
Mifare version: 00 04 04 02 01 00 11 03
Counter 0: 0
Tearing 0: 00
Counter 1: 0
Tearing 1: 00
Counter 2: 0
Tearing 2: 00
Pages total: 135
"""

data_static = [
    0x04, 0x10, 0x56, 0xCA,     # 01 serial number
    0x01, 0x74, 0x48, 0x03,     # 02 serial number
    0x3E, 0x48, 0x00, 0x00,     # 03 serial number, internal, lock bytes, lock bytes
    0xE1, 0x10, 0x3E, 0x00,     # 04 Capability Container
]

conf_pages = [
    0x00, 0x00, 0x00, 0xBD,      # 130
    0x04, 0x00, 0x00, 0xFF,      # 131
    0x00, 0x05, 0x00, 0x00,      # 132
    0x00, 0x00, 0x00, 0x00,      # 133
    0x00, 0x00, 0x00, 0x00,      # 134
]


def print_nfc_sub(t_data, file=sys.stdout):

    print(nfc_header, end='', file=file)

    p = 0
    for x in range(0, 540, 4):
        print(f"Page {p}: {t_data[x]:02X} {t_data[x + 1]:02X} "
              f"{t_data[x + 2]:02X} {t_data[x + 3]:02X}", file=file)
        p = p + 1


def gen_nfc_sub(tag_data):

    tag_message = []
    data_list = []

    for x in tag_data:
        if x[0] == 'txt':
            tag_message.append(ndef.TextRecord(x[1], "en"))
        elif x[0] == 'url':
            tag_message.append(ndef.UriRecord(x[1]))

        if verbose:
            print(x, file=sys.stderr)
            print(tag_message[-1:], file=sys.stderr)

    buf = b"".join((ndef.message_encoder(tag_message)))

    m_len = len(buf)

    if verbose:
        print("buf", m_len, hex(m_len), buf, file=sys.stderr)

    data_list.extend(data_static)
    data_list.append(3)         # Message Flags
    if m_len < 255:
        data_list.append(m_len)         # Type Length
    else:
        data_list.append(0xFF)
        lenStr = hex(m_len)[2:].rjust(4, "0")
        data_list.append(int(lenStr[0:2], 16))
        data_list.append(int(lenStr[2:4], 16))
    data_list.extend(list(buf))

    data_list.append(0xFE)      # end of Data

    data_len = len(data_list)

    if verbose:
        print("data_list", data_len, data_list, file=sys.stderr)

    x = 520 - data_len
    data_list.extend([0] * x)
    data_list.extend(conf_pages)

    return data_list


# url_str = "https://youtu.be/dQw4w9WgXcQ"
# title_str = "Rick Roll"

if __name__ == '__main__':

    arg_data = []

    for a in sys.argv[1:]:
        if a.startswith("http"):
            arg_data.append(("url", a))
        else:
            arg_data.append(("txt", a))

    if not arg_data:
        print("requires at least one URL argument\n"
              "Please provide URL and optional Title\n\n"
              f"{sys.argv[0]} : https://some.url  'Title'")
        sys.exit()

    nfc_data = gen_nfc_sub(arg_data)

    print_nfc_sub(nfc_data)

    sys.exit()

Copy the script on your computer (e.g. nfcdata.py) and run it:

python3 nfcdata.py "Test data"

This will create a file that you can upload to your Flipper Zero using the qFlipper desktop application.

You will now be able to emulate the tag on the Flipper Zero.

Complexity

Photo by John Barkiple on Unsplash

I am working on a personal project that uses python as the primary programming language. I am definitely in love with Python. Coming from an extensive experience with C, I am very comfortable using it, allowing me to dig into OOP when doing it.

I can use dozen of libraries that make my life easier. Salesforce, Harvest, and Google are easily accessible from any application. For this specific project, I have to deal with Pandas, Numpy and Plotly. I had never used them before.

I confess that everything is new and, sometimes, confusing. 

The documentation for these libraries is humongous, and I thought I could not read it all before starting to write my code. 

The feeling that everything is much more complex than before is overwhelming. Thirty years ago, there was little around programming languages and libraries. Better said, there was a lot, but much less than nowadays. 

You had to be careful about scarce resources. Today the computer I am using to write this post is hugely more powerful than any server I used to work on. I can easily waste resources without running out of them. My programming life is more straightforward.

On the other side, the complexity is increased. You have dozen of options to solve any problem you are facing. I always try to understand what I am doing, but I confess sometimes I Copy and Paste the snippet I need to solve a specific problem. 

I feel guilty when I do that.

Nevertheless, I wanted to complete the task I was working on and see it fast and dirty. I will make it elegant, concise, and unique later on. Truth said, it never happens.

If it works, it will stay the same forever.

Adventures in digital transformation

Photo by CHUTTERSNAP on Unsplash

My car insurance expires on the first of January. I always just remembered that I needed to renew it when I received an email from the insurance company telling me I was late.

My insurance company is one of the most prominent Italian companies. It is supposed to be among the most innovative in its specific field.

That’s not the case.

As soon as it was available, I installed the company mobile application guessing it would have made my life easier. I registered on the website, logged in on the application with my credentials, and completely forgot it (i.e., I never opened it after my first login.)

I thought the application would be smart enough to alert me that my insurance was about to expire. It wasn’t. I had to rely on the email message received from the insurance broker.

I thought I would have been able to renew my insurance from the application. No, I couldn’t. No online payment options were available in the application.

I phoned the insurance broker to ask him to send me the amount due and the payment details via email. They were kind to me, but I did not receive any email messages.

I sent an email asking for the same information. They have yet to reply.

End of the story: I drove to the insurance broker’s office and paid my renewal. Lucky me, they accept credit cards.

It’s 2023, and digital transformation is not happening. As we say in Italian: lo stai facendo male.

Refactoring

Photo by Markus Winkler on Unsplash

I wrote yesterday about my coding during these holidays. Everything is working as expected and pretty smoothly. There is a vast space for optimization, but I am okay with it for the time being.

Today, I looked at my code before committing it to my private repository. I was not happy. Parsing an Excel file row by row and validating every single column is a stupid exercise. At least, it is a silly exercise for me.

After ingesting the data, I played with my database using pandas and Numpy. Great tools, by the way.

And then I realized how bad I was when I was writing that code.

I realized I should have used pandas from the very beginning. 

Something like 500 hundred lines of code turned into 30 lines or so.

I’m getting too old for this, I guess.

Annus horribilis

Photo by Kelly Sikkema on Unsplash

I can’t tell you how happy I am 2022 is over.

Ok, this is my usual “end-of-year rant,” continue at your own risk. 

I look back at what it was meant to be, and I must admit it has been a complete failure. All of my plans went south as soon as February started.

No matter what I did to follow my designed path, external influences have taken me personally and professionally elsewhere.

The truth is that you can’t program everything, even though you want to. 

I will not fail into this mistake again.

Nevertheless, there are some lessons that I have learned along the journey:

  • Uncertainty is the new constant. The pandemic, the war, the rising inflation, and the energy crisis are something no one expected, and the result is that every decision taken may change the next day.
  • Everything became more complicated. Every single process out there has been designed by an insane bureaucrat. No matter what you do, you have to fight hard.
  • Many people find refuge in an Oz World and want you to think you are part of the same world. Trying to escape the uncertainty, they built their private world with their rules.
  • A lot of business decisions are made in a very conservative way. People tend to stay on the safe side or, even worse, decide the best way to please their boss.
  • I need to redesign my habits to be more consistent. Think more and act more—no impulse decisions.
  • Distance is a huge problem. I tend to stay away from people much more than before, and that’s wrong.
  • Nobody is listening, and everybody is talking. Me too.
  • In a more general way, there is less beauty out there than before. 
  • There is a dystonic approach to business planning. Everybody wants to grow without considering the impact on people, society, and the world. Not to talk about the strange idea of growing without considering the potential effect of all external factors.
  • I need to care for myself. This year has been terrible from a physical perspective. I am not young anymore, and I should consider that. 
  • From a business perspective, it has been an incredibly tough year. There is an incredible amount of things that need to be fixed to be able to continue our journey. This is the biggest challenge for the following year.

Those issues will remain in 2023. The good news is that I am aware of them and will act accordingly.

It looks like there has been a lot of negativity in 2022, but I have to admit I have to save something:

  • I have spent valuable time with incredibly talented people. I have learned a lot. 
  • I read a lot, much more than in my entire life.
  • I enjoyed my personal hobbies more than before. Coding, guitar, and magic have significantly improved and helped me understand what was happening around me.
  • I loved spending time with my significant one. Definitely a big change.
  • I have spent less money on things and have been able to manage my money more effectively.
  • I have learned to let things go. 

No, I do not have a new year’s resolution list. It never worked for me; it is just wishful thinking. 

The strange world of coding

Photo by Priscilla Du Preez on Unsplash

The good news is that I am still on holiday. These days I am playing with some python code to read data from some of our systems and perform some analysis before the new fiscal year officially starts.

It started as a small project and a relaxing activity. It was not strictly work; I was playing with data and python. I love coding, and I always do something when I have some free time.

I ended up with five thousand lines of code.

This specific exercise was an ETL (Extract, Transform, Load). Two main systems were involved: Salesforce and Google Drive. I wanted everything on a Sqlite database to wrangle data with pandas and NumPy. 

Extracting data was easy. Both Salesforce and Google Drive have very well-documented APIs. The transformation was tricky. Every system has its way of representing data. Specifically, date and time management is always a massive pain between different systems. The load was a breeze.

Finally, I made it. My database was loaded with data.

I ran the tests against data integrity, and something was wrong. After a SQL join, I expected 3036 rows and got 3108. It took me an hour to find the culprits: I forgot to disallow duplicates in a database field, and there was duplicated data in Google Drive.

I could have deleted the duplicated data in Google Drive, but I did not want to do it. I am not the only one accessing and using that data.

I modified my code to cope with duplicated data. Well, it almost doubled the size of my codebase. I could not simply discard the duplicate. I had to merge the data in a table with 32 different fields. Each field with specific requirements.

It was exciting and intriguing.

Sometimes you spend more time coding edge case management than the core application logic.

You need an account!

Photo by Gabriel Heinzer on Unsplash

As I said a few months ago, a lot of software is moving to subscription models. Many of these applications offer a free tier with more or less advanced functionality. If you want more, you need a subscription and have to pay for it. I’m not too fond of this, honestly.

Nevertheless, I am always in the mood to try new applications, especially if they are applications for developers or system administrators.

I am a long-time user of if they are applications for developers or system administrators.

I am a long-time user of iTerm2 on my Mac. The combination of iTerm, tmux, zsh, and powerlevel10k are the best for most of my use cases.

I always try new terminals, but I go back to iTerm.

Yesterday I was trying the last one I heard of. No, I will not name it because it does add much to what I am writing. I headed to the developer’s website, downloaded the application, and installed it.

When I opened it, it asked me to create an account on the developer website. There is no way to use the application without a user account on their system.

Seriously?

Come on, folks. It’s a terminal. Why should I need an account to use a terminal application?

We have gone a little bit too far.

In the last few years, I have limited my accounts around the web to what I need. It is a pain to see that the world out there is moving in another direction.

OK, back to iTerm, then.