Invoke (Pyinvoke) is great

I recently started using Invoke to automate common tasks for my projects, such as building and deploying documentation pages. Naturally, I started using Invoke to maintain this blog, so here's a quick guide on how to use Invoke.

What's invoke?

Invoke is a Python library for managing shell-oriented tasks. It was inspired by Ruby's Rake, which is a tool designed to write Makefiles using Ruby. The main advantages Rake provided over simple Makefiles is that they are easier to write, and extremely versatile, as you have the whole Ruby programming language to describe tasks.

Invoke is similar to Rake, in that it attempts to provide an alternative to Makefiles for automating tasks. Similarly to Rake, Invoke provides full Python to describe and automate tasks.

How to use invoke

You first need to install invoke, you can install it globally using pip:

pip install invoke

However, and I have written before, I like to use poetry to manage virtual environments an dependencies, so I just add invoke as a "dev" dependency to my projects:

poetry add --group dev invoke

Now that you have invoke available, you need to create a tasks.py file on your project's root directory. The tasks.py …

more ...

Getting started with Ruff and Poetry

I manage most of my Python projects with Poetry, I really like how it handles dependencies, configures projects and manages virtual environments using simple commands.

Normally I include linting tools as part of my Poetry projects, specifically flake8 and pylint. They served me well, but recently I saw a lot of hype around ruff in online tech circles, so I decided to give it a try.

And I'm glad I did, ruff and poetry are a match made in heaven. I'm really enjoying working with ruff, and how I can have really good static code analysis, and really fast.

In this article, I give a quick guide on how to setup ruff the way I use it on my Python projects, and how to integrate the ruff-lsp to Neovim.

Add ruff to you poetry dependencies

Assuming you already have a poetry project in place, you can add ruff as a development dependency:

poetry add --group dev ruff

This will create the following entry in your pyproject.toml file:

[tool.poetry.group.dev.dependencies]
ruff = "^0.4.2"

Configure ruff

The ruff documentation is pretty good, and the tool is pretty versatible, so you can set ruff to however you like …

more ...

Building a blog with Pelican and Netlify

It's been more than a year since I last posted on this website. I've been busy and I didn't have something to write about, until now. As I wrote before, I've been running the classic Jekyll/GitHub Pages combo, but I wanted to try something different, something that gave me more control over my website, so I found Pelican.

Similar to Jekyll, Pelican is a static site generator: its output are plain HTML/CSS files that you can upload anywhere, you don't need a backend nor a database. This is great because finding cheap (free) hosting is easy, and Netlify's Started Plan is perfect for this type of websites.

Just like Jekyll, Pelican also supports a wide variety of plugins and themes. The main difference is that Pelican is written in Python, and being a huge Python fan myself, I decided to give it a go. This is the write-up of how I got it working.

1. Setup the project using Poetry

I really like Poetry for managing my dependencies and virtual environments.

You can create a new Poetry project by running:

poetry new new-blog

You can find more information on how to use Poetry by reading the docs.

Now …

more ...

Getting started with the ESP-IDF running under WSL2

I'm really excited about this post, because it's the first post slightly related to Embedded Systems, and that's the topic I was expecting to write about when I started this blog. The second reason is because I love the ESP32, specially using the ESP IoT Development Framework. It's been a while since I worked with an ESP32 using the IDF (2019 actually), and the framework changed a lot since, so after all this time, I decided to get myself a dev board and explore the IDF again.

When I started working with the ESP32, I followed the excellent Neil Kolban's Book on ESP32, but I've heard it's slightly outdated now, so your best bet is definitely the also excelent IDF Documentation from Espressif.

As I wrote before, I've been using mostly Windows 10 with WSL2 for my development work, so setting up the IDF under WSL2 might be a little different to the average process you follow if running under an actual Linux distribution. This guide is a quick guide on how to start working with an ESP32 using WSL2.

1. Install the CP210x USB to UART Bridge VCP Drivers

Assuming you're using one of the very common ESP32 DevKit …

more ...

PowerShell for the (Unix) masses

Screenshot of how my PowerShell setup looks like Screenshot of how my PowerShell setup looks like

Last time I wrote about my development setup on Windows 10, I suggested using the Windows Subsystem for Linux (WSL), and I still think this is the best (or most confortable) approach for most Unix people. However, you might find yourself in a situation where you can't really use WSL, such as needing to compile Windows native binaries or your company-issued laptop just won't allow it.

I actually am in one of those situations, so at first I tried a Cygwin setup, and it did work, but not painlessly (it took me some work to get to a place where I was confortable) and it was slow and buggy at times.

After much pain and unwillingness to dedicate more time to Cygwin, I said "screw it" and went the Windows-way (not without some initial resistance of course) and found out that you can get a pretty "Riced Unix" feel with PowerShell easily, and that PowerShell is actually good. So here's a writeup on how I got it working the way I like.

1. Install Git

You know you need it. You can get Git for Windows here.

2. Install Windows Terminal

The …

more ...