July 10, 2023

Anonymous Hyperlinks

Today, I looked something up in our documentation, and noticed an unformatted link. `launchpad-mojo-specs <https://code.launchpad.net/launchpad-mojo-specs>` This is reStructuredText - a file format for structured data. While many people have switched to MarkDown, which is unarguably easier to read and write, I still like reStructuredText as it is very powerful. The above link does not get rendered as a hyperlink, as it misses a trailing underscore. I was about to add it, and directly commit, but luckily I tried to render it first....

February 12, 2023

Multiline Commit Messages With `git commit -m

When you execute git commit on the command line, your specified editor opens and you can create an expressive title and a longer description. That is probably nothing new. You are probably also aware of the shortcut git commit -m <message>, which skips the step with the editor. But there is only room for the title, right? Nope, this is not true. one way It turns out you can use -m multiple times....

October 24, 2022

How to Update Cargo

Today I saw a Tweet by Marius Gedminas, who wrote about lfs, a replacement for df. It is one of the many tools, implemented in Rust, which offer some more features compared to their bash alternatives. What about no When I tried to install it, I just saw the following error message: ❯ cargo install lfs Updating crates.io index Downloaded lfs v2.6.0 error: failed to parse manifest at `/home/jugmac00/.cargo/registry/src/github.com-1ecc6299db9ec823/lfs-2.6.0/Cargo.toml` Caused by: feature `strip` is required The package requires the Cargo feature called `strip`, but that feature is not stabilized in this version of Cargo (1....

September 30, 2022

How to Apply Git Log and Git Grep Only for a Specific File Type

Today I wanted to check how the UPDATE statement was used in already deleted SQL patch files. Usually I do a git log -p and then use the interactive search in less via /, but in this case there were too many hits from Python files, so I wanted to restrict my search to SQL files only. Turns out you can pass in the file type via … git log -p -- '*sql' And then use the interactive search....

July 5, 2022

How f-strings Handle Double Curly Braces

Today I was about setting up a test case for parsing a YAML file which is templated with Jinja variables. Something like this… f""" pipeline: - test jobs: test: package-repositories: - type: apt url: "https://{{auth}}@example.org" """ My test case failed… My Pydantic model, which uses yaml.safe_load under the hood to load the above configuration, returned the URL, even before the value got replaced, as https://{auth}@example.org. One pair of the double curly braces was stripped away!...

May 18, 2022

Choosing Singular or Plural for Argument Names in Argparse

Naming is hard, right? Today I was extending an argparse based CLI application. I wanted to add an optional argument so that I can pass in environment variables. For this argparse has a special “action”, called append. From the argparse documentation: >>> parser = argparse.ArgumentParser() >>> parser.add_argument('--foo', action='append') >>> parser.parse_args('--foo 1 --foo 2'.split()) Namespace(foo=['1', '2']) Awesome! Now I can access all the provided values as foo. Wait a moment Wait! This does not match....

May 10, 2022

How to Delete Documentation Hosted on pythonhosted.org

Today, I needed to lookup something in the documentation of lazr.config, which - you guessed it - is a configuration system, using an ini-like configuration file format. The number one search result on Google is still https://pythonhosted.org/lazr.config/. For projects on available on PyPI both wheels and packages are hosted on pythonhosted.org, and as it looks, at least before “my time” and before there was Read the Docs, also documentation was hosted on pythonhosted....

May 7, 2022

How to Render a Single ReStructuredText Document

Today I came across ubuntu-archive-tools which is a great set of scripts to help administer the Ubuntu archive. The project consists of Python scripts only, is not packaged, and the repository comes with no setup documentation. After I have figured out which dependencies the project needs, I wanted to add a minimal documentation, so the next user has an easier start. So, I created a README.rst, added some information… and huh, how would I render the file locally to make sure I have not messed up the syntax?...

April 24, 2022

How to Combine PDF Files on the Command Line

Without further ado… pdfunite in-file-1.pdf in-file-2.pdf outfile.pdf Simple as that. How to get pdfunite? I had it already installed as a dependency when I installed calibre, but you can also install it via… sudo apt install poppler-utils poppler-utils is a collection of PDF utils.

April 22, 2022

How to Cargo Install a Package With Additional Features

Meanwhile you may have heard that there are a couple of new CLI apps out there written in Rust - blazing fast and with additional features. While I rarely use them, as I do not want to get used to tools, which are not available on all Linux machines I work on, I do use ripgrep regularly, as it really makes a difference, especially in speed. Yesterday, I wanted to use ripgrep with PCRE2 (Perl Compatible Regular Expressions), but when I tried it, I got this error message:...