mpv and youtube-dl

mpv and youtube-dl can talk directly to each other.

Specificaly:

$ mpv --ytdl-format=bestaudio ytdl://ytsearch:'think about things'

will immediately start mpv off playing the audio results of the youtube-dl search.

U2F and OpenSSH

As of OpenSSH 8.2, OpenSSH now supports U2F for authentication.

This is a totally separate authentication mechanism entirely from say, ED25519 host keys with a second factor; here, the U2F (e.g. Yubikey) is / has the key on it.

To use it though, both sides (server and client) have …

Symlinking Python (3) Interpreters

PEP 405 introduced a pyvenv.cfg file, useful for creating lightweight virtual environments without the hacks done by virtualenv historically. Doing so is much, much faster as well, since now creation of a virtual environment is essentially just creating 2 files (one file and a symlink).

It also though changed …

namei

namei(1) (provided by util-linux on macOS) is a nifty utility for fully resolving symbolic links.

Given a chain of links, it will show e.g.:

⊙  namei =python                                     julian@Air ●
f: /Users/julian/.local/bin/python
d /
d Users
d julian
l .local -> /Users/julian/.dotfiles/.local
d /
d Users …

Firefox

Copying to the Clipboard from the Console

The Firefox Dev Tools console defines a copy() function which will copy text to the clipboard.

For some reason, using navigator.clipboard.writeText("asdf"), which seems to be the normal way to do this fires a rejected promise. Probably something to do with …

BPF

JIT

A restricted subset of C is compiled via clang to eBPF bytecode, and the Linux kernel contains a JIT (and of course a VM) to execute it.

bcc

bcc is a higher level toolkit for interacting with eBPF (including via Python). For example:

from bcc import BPF

BPF(
    text …

less

less -S

-S will disable soft line breaks within less, allowing horizontal scrolling.

Tailing Files

Use less +F instead of tail -f. It works the same, but supports interrupting the stream with SIGINT to e.g. search around, and then can resume tailing by hitting F again.

Doing so will …

zsh

&|

Piping using foo &| bar will pipe both stdout and stderr to bar.

MULTIOS

With MULTIOS enabled, multiple outputs to the same file descriptor can be provided, similar to using tee.

In other words:

$ date >foo >bar

will output date to both foo and bar. (Piping it will also work since …

coreutils

mkdir -p will create a directory with its parents. But cp takes a parents option as well.

cp --parents foo/bar/baz/quux.txt some/directory will create some/directory/foo/bar/baz/quux.txt without any of the other directory structure from the original location.

dstat

dstat can replace a bunch of other statistical performance counting things (I/O, CPU, Disk, Network, Syscalls, etc.).

socat

Use socat instead of netcat. It takes something more like endpoint syntax (and does many more kinds of ports and configurable connectivity that come with them).

Tons of examples here.

Git

git you magnificent beast…

Finding the History of a Function or Object

log -L :foo will show you the history of the function/object called foo. This is a smarter version of normal log -L which just knows about lines.

But because I’m lazy to even type this out …

pv

pv is a useful utility to insert in shell pipelines for watching how much data passes through the pipe.

This page has a few simple examples, and there are more I’m sure with some googling around.