[go: up one dir, main page]

Today I Learned

tags


2021/10/12

about the shell until keyword, which is equivalent to while !.


2022/04/04

to run terraform output $output_name to print a named output


2022/04/11

You can use journalctl -u ${service_name}.service --since ${time:-today} to view the logs of a systemd service: https://www.digitalocean.com/community/tutorials/how-to-use-journalctl-to-view-and-manipulate-systemd-logs


2022/04/20

tar -ztvf file.tar.gz will list the files in tar.gz


2022/04/29

how to check the last apt update time:

last_update="$(stat --format=%Y /var/cache/apt/pkgcache.bin)"

https://askubuntu.com/a/410259/505362


2022/05/09


2022/05/10

That you can call time(1) to time how long a shell command takes, like so:

; time terraform fmt -write=true -recursive .
# terraform fmt -write=true -recursive . 0.10s user 0.23s system 24% cpu 1.377 total

2022/05/16

that gzip(1), by default, includes file mtimes. The flag to prevent gzip from zipping non-deterministically is gzip --no-name or gzip -n.


2022/05/31

That sql has assertions:

CREATE ASSERTION <Constraint name>
CHECK (search condition)
[ <constraint attributes> ]

see https://crate.io/docs/sql-99/en/latest/chapters/20.html#create-assertion-statement.

h/t https://www.scattered-thoughts.net/log/0024/ for bringing that to my attention.

Also, from the weekend: in postgres, at least, you can call TABLE :table_name; directly to SELECT * FROM :table_name;

Also: how to look up a domain name from an ip:

reverse_ip_lookup() {
  ip_address="$1"
  dig -x $ip_address +noall +answer
}

Also: how to audit AWS VPC flow logs from CloudWatch Log Insights: use the example queries in the right sidebar.

Also: python can execute .zip files directly, like so:

:; echo 'print("Hello, World!")' > __main__.py
:; zip hello-world.zip __main__.py
:; python3 ./hello-world.zip
## Hello, World!

h/t https://pradeepchhetri.xyz/til/pythonzip/ for pointing that out.


2022/06/01

That pg_dumpall exists. That you need to use pg_dumpall to dump tablespaces, roles, and subscriptions. That pg_dumpall will dump the postgres role by default, causing resultant dump to fail to restore. Fortunately, I’m able to grep -ve '^CREATE ROLE postgres


2022/07/29

that in bash and zsh, you can put a newline in a variable like so:

newline=$'\n'
echo ">>>${newline}<<<"

learned from: https://stackoverflow.com/a/4456399/6571327


2022/08/11

That you can call docker compose kill to kill all docker-compose containers That there’s a timeout shell command in gnu coreutils: https://man7.org/linux/man-pages/man1/timeout.1.html


2022/08/24

that you can lsblk to list the block devices that the OS knows about without sudo.

that you can sudo growpart to increase a partition size without restarting the machine.


2022/10/11

That terraform plan -detailed-exitcode exists: 0 means no diff, 1 means error, 2 means a diff exists.

Also, that you can print the source code of a bash function like so:

print_fn_src() { declare -f "$1"; }

2022/10/18

That BSD arch command found on Macs also supports a -${arch} flag for running universal binaries.


2023/01/28

That you need ato git add a flake.nix for the flake’s contents to start to work with nix develop

This is needed because Nix flakes respects gitignores. If you don’t add things to the git staging area, git doesn’t know about the files at all, and Nix flakes can’t know if it should ignore them. – https://xeiaso.net/blog/nix-flakes-go-programs


that “truecolor” support in shells is detected with the $COLORTERM env var


2023/05/30

That there’s a Linux command to do sql-like JOINs of lines in files, possibly based on a field in each line: join(1)


2023/10/31

That POSIX shell has configuration option, set -a or set -o allexport that exports all assigned variables. This simplifies using .env files in .envrc files:

# evaluate a .env file, if it exists
if [ -f .env ]; then
  set -a # assigning a variable exports the variable
  # shellcheck disable=SC1091
  source .env
  set +a
fi

That JS has a String.raw template literal tag function that unescapes escape sequences in a backtick-string:

String.raw`\t\r\n` // => "\\t\\r\\n"

2024/10/16

which -a python # shows all matches on $PATH type python # checks if a builtin/alias/fn/exe

https://wizardzines.com/comics/path-tips/