Using RQ Tasks with Netbox scripts for Asynchronous Execution and Retry Logic
The scripting functionality in Netbox is an easy way to add simple functionality and integrations without having to resort to real django apps. However, by default these scripts run synchronously and will not retry on error. You can, though, use the python-rq integration that comes with netbox out of the box.
It requires you to define the task separately in a separate module (else the rq worker will fail to properly resolve/load it).…
Read more ⟶
Go Changed Forloop Semantics Inconsistencies
Binding a local variable in the scope of a go routine in a for-loop used to have unexpected semantic behaviour: you wouldn’t get the value of the variable at the moment of the iteration, but the actual last value (but not always! It depends on when the go routine actually runs)
package main import ( "fmt" "time" ) func main() { for i := 0; i < 2; i++ { go func() { fmt.…
Read more ⟶
Improve your shell skills with Clai
I created a very simple command line utility in go that helps you create non-trivial command line / shell commands. It’s actually just a thin wrapper around the openai API’s, but it can be pretty usefull and saves you from switching to a chatgpt session or stackoverflow.
E.g.
$ clai "group a tab separated file by first column, sum them by third column" awk -F'\t' '{sum[$1] += $3} END {for(group in sum) print group, sum[group]}' file.…
Read more ⟶