Elmar Athmer
  • About
  • Blog

Blog

May 15, 2020

Must have Cargo subcommands

Cargo already comes with many commands, but just as rust itself, it’s designed to provide a stable core to be extended by faster evolving additional commands, published as separate crates. All commands presented here can easily be installed via $ cargo install $CRATE into your $CARGO_HOME/bin directory. Since Cargo 1.41 cargo install can also update installed crates. Must have subcommands This is a list of crates I don’t want to miss in my daily life anymore, with exemplary use cases.
November 15, 2019

(parametrized) raw SQL Queries with diesel (Postgres)

Sometimes the diesel abstraction is not enough if you want to execute more complex queries. This is totally possible, but the documentation is a bit brief on that topic, and the “SqlQuery bind” example shows MySQL syntax (which threw me off, since my postgres-query-writing-know-how is a bit rusty ATM). I wanted to execute the following query: insert into store_traffic_uploads (store_id, batch_id) select id as store_id, $1 from stores where id not in (select store_id from store_traffic_uploads) limit $2 ; The corresponding Rust Code then looks like this:
November 14, 2019

Leveraging docker caching building rust binaries

With the compile time required for rust projects and the sheer size of the target/ directory, building rust projects in docker requires to pay attention to some details. Small images with multi-stage builds Using docker multi-stage builds it’s easy to build small images (even smaller with rust:alpine and alpine:latest): FROMrust:latest as builderWORKDIR/usr/srcCOPY . .RUN cargo install --locked --path . --root /usr/localFROMdebian:latestCOPY --from=builder /usr/local/bin/* /usr/local/bin/For the sake of completenesse, an appropriate .
July 21, 2019

Securely cache ansible-vault and "become" password

If you need to run ansible multiple times, it’s cumbersome to enter both the become (formely known as sudo) and the ansible-vault-password with each invocation. tl;dr use a script for vault_password_file in your ansible.cfg that executes a password-manager (e.g. pass) to echo the vault-password to stdout. Then put your become-password into ansible-vaults. The goal The goal is to somehow “cache” both the vault password and the become password, so you can quickly run ansible without re-entering credentials for small playbook changes.
© 2020 Elmar Athmer