martes, 13 de septiembre de 2022

Reinventing the Queue

Yesterday, this HN thread Write your own task queue got me thinking again on the NIH and "build vs buy". 

I'm sometimes an advocate for using own implementations of subsystems if you don't need the whole complexity of premade solutions. But...

I usually wouldn't write a task queue, as this is rarely my core business, and that I don't think my needs are anything custom, but I'll take whatever comes with the package.

That said, I've built one task queue in the past, the excuse being I was working on CommonLisp, and the platform already used all the AWS stack: (DynamoDB and Kinesis Streams) for similar things, and no ready-made solution was available. 

In that case, workers were really an active object with an active loop that kept polling the correct stream, and when a job came, an attribute in a dynamoDB table would be used to track the status. It was simple, and it allowed for reimplementations of the queues for local testing. So yeah, I've done it also...

But I can't see myself doing it when using Ruby/Python/... I feel it's very rare I'm gonna have a need that is not covered in your run off the mill job system.

Anyway, wakatime did the same thing, they implemented their own queue. And they all seem to complain about celery.

And more recent projects that approach queues:

- async, no threads/process

- django tailored one.

sábado, 3 de septiembre de 2022

Ratpoison news in 2022?

I've been using the same obscure window manager since about 2003. I remember using it in 'Fedora Core 2'(released in 2004).

Lately I've thought about moving to something that behaves better with Zoom, but I really couldn't find an alternative.


There's , which comes from ratpoison, and it's maintained by jcs. It has the latest ratpoison patches that didn't make it to the last stable ratpoison release, and a few new features.  Well.... it turns out one of the new features breaks my workflow, so for me, this is a "nope".

I also thought about using evilwm, which is a floating wm with ratpoison shortcuts (more or less). But I do like tiling.  So maybe the combination of ratpoison and evilwm (via tmpwm) would be the sweetest spot. I remember using that config years ago, but now you have to make sure to have the latest ratpoison built from git, because tmpwm breaks on multiple screens.

Something I discovered just this week is this youtube channel from a user called root_sti. The videos are great(great music), showing neat configurations and a million scripts and tunings, using dzen2, fzf, evilwm, ratpoison, and voidlinux. And all configs are here. Lots of shellscript there :).

Maybe using sxhkd and emulating the shortcuts via wmctl... not sure

Also, a funny video just from a few minutes ago in hackernews. The first tiling window manager (1988)

viernes, 26 de agosto de 2022

Vim and Vscode to camelcase

Earlier today I saw a post on vscode subreddit where the author explores a plugin to transform parts of the code from/to camel/snake/kebab case.

Automatically I started thinking how I'd do it in emacs/vim. Given I'm lately not doing so much text munging as I used to, I feel a bit rusty wrt editing-fu. Let's see...

In the video, the guy uses something like multiple-cursors to select the area from the beginning of line till the colon. That was the most difficult thing to me, because neither vim nor emacs have multiple cursors without installing a plugin.

So, I though there had to be a "declarative" way (whatever it means) to do it, and thought of a regexp that would convert the _x to X , for all _ before a colon.

It turns out I could do it quite successfully with vim, just researching a bit how to do lookaheads.

I took 

foo_bar_f: foo_bar,
foo_bar: foo,
foo_bar_: foo  

as my test case, because it has underscores in both sides, it has missplaced underscores, and different lenghts (so we can't use visual block)

This is what I came up with. Visual select and


I was a bit surprised that it took me a bit longer than expected, and that I had to use a few "advanced" regex features.  

I haven't tried to do it in emacs yet.  Any ideas? Any simplification to my solution?

viernes, 19 de agosto de 2022

java time

This is so helpful that I'm just putting it here for future reference.

viernes, 24 de junio de 2022

A better watch: viddy

I just found this thread in HN, and I think I'm sold already on aliasing watch to this improved version of the watch command.


Also, nice trick of aliases, where

A trailing space in value causes the next word
        to be checked for alias substitution when the alias is expanded

jueves, 19 de mayo de 2022

Hugo documentation

Some time ago I created a new homepage for, where I was supposed to migrate my blog to. The migration never happened really (that's why I'm writing this post here), but I learned hugo on the way, and that was already something. 

During the learning process, it took me quite a bit of time to understand how hugo would render the site, what were the templates, the posts, the index pages, the home page, and how they "yielded" from one to the other. I even wrote a post about it. It was nice to find I was not alone finding the docs confusing, and this link explains why it is so confusing. Reading that post was like reading my own mind, explaining the reasons of the confusion.

martes, 26 de abril de 2022

Parsing args with python (alt version)

Parsing cli arguments is a solved problem. Every language has a library to get the flags from your command line. Maybe not in the stdlib, but for sure there blessed libs for it.

In Python, argparse is the official way. It's very complete and everything, but I've found it's api quite hard to follow, and I've read code that feels like written in a copypaste style, and instead of giving you more intuition on the program as a developer, it hides the knowledge of which flags go where, and which defaults they have, and which options make sense to each subcommand.

I recently rewrote a tool that had exactly that problem. Unused flags that no one removed from the argparse parsing code, hidden defaults...

When I rewrote that code, I started with this yosefk post in mind (and some reminiscence of picolisp's cli handling). I'll just do the simplest thing. Even against the standard official way (so kids, don't do it at home, or yes, do it only at home. Or not).

Here's the first version

What's already something super good is that there's 0 overhead for getting your parameters.  Of course, the parameters are not processed at all, so you'll have to cover for defaults or wrong number of args. But the language already is going to help on some of those. It will just complain if you try to call testing without an argument.

Another nice thing is that you can predict what's going to happen without checking any docs or anything. For someone that doesn't create cli apps every day, this is a nice pro IMHO.

Second version:

What can we say about this? This one takes --flag=value, and you can pass them in the order you want because the nice splat operator will take care of it. It's very rewarding to use the language features to work alongside your goal.  **kwargs, does also a great job, providing for optional parameters, that every function will make sure to validate (It should be their job anyway, not the argparser's IMHO).

Of course, in the end, the overengineering takes over:

And we end up feeling envy from --help. In this case we also can use reflection to fill in the parameters and docs from the signatures and docstrings.

That was a nice exercise!

(In the end, I just went with the first solution, because KISS and YAGNI and Suckless.)