In the middle of the desert you can say anything you want
Installed noisetorch, it complained about CAP_SYS_RESOURCE like the last time and I fixed it by installing polkit like the last time, didn’t work though.
Issue seems to be that by default Mint has the home partition mounted with nosetuid1, confirmed by doing mount
.
Fix was to put the binary in /opt
, the prompt is the same but after entering the password it works and I see the expected interface.
Use-case - using limited mobile internet.
vnstat
is nice. sudo apt install vnstat
, service has to be started/enabled through systemctl as usual.
Logs traffic with 5-minute granularity, so for the first 5 minutes after install will say that there’s not enough information :)
vnstat -5
returns the last hours in 5-minute interval, -h
/-d
/-m
is hourly/daily/monthly.
-i
selects the interface (otherwise all existing non-zero ones will be shown).
Saw this in the python pandoc cookbook1
holder[index:index+1] = split_home(elt)
Wow.
Never thought I could assign multiple elements to a slice!
pdbpp is a drop-in replacement for pdb
, and I like it more than ipdb
for some reason.
Installing it makes it the default one imported when importing pdb
(incl. by pytest, python’s breakpoint()
etc!)
Really nice tutorial: pdb++, a drop-in replacement for pdb (the Python debugger) | PythonRepo
Vanilla-pdb cheatcheet: Python Debugger Cheat Sheet - Kapeli
Features not present in pdb that I love:
ll
outputs the text of the current functionsticky
updates the function listing with each new line, giving a nice interactive visual feeling to the debugging processpytest -s
works to make it play nice with the stdouts generated by pdbpp.
In the context of reading a settings.ini
from python’s decouple
1 config lib, this works as empty string
YAML_CONVERTER_PREFIX=
has to be cast to string though:
D_YAML_CONVERTER_PREFIX = config("YAML_CONVERTER_PREFIX", cast=str)
These don’t, these are strings containing two characters, ""
and ''
respectively.
YAML_CONVERTER_PREFIX=""
YAML_CONVERTER_PREFIX=''
Wooho!
files = list(input_dir.glob("*.md"))[: cs.limit]
if output_path.is_file() and ((l := len(files)) != 1):
raise ValueError(f"Can't write {l} files to single file {output_dir}")
Had to use additional parentheses around the actual assignment. Without that, black fails in an interesting way:
error: cannot format smw_to_hugo/yaml_converter.py: cannot use --safe with this file; failed to parse source file.
Just discovered this! In vim, if I skip the pattern, it’ll take the one last searched for:
/mypattern
:s//newpattern/g
Had weird issues with kitty terminal output being wrong, lines in vim/nvim being in wrong places, usually because it thought the terminal was a different size than it really was (blamed it on nvim initally, but the problem happened in other complex CLI programs too, notably tig
).
$TERMINFO
wasn’t set, and the terminfo file was nowhere to be found. The package kitty-terminfo
was installed though.
In any case, downloaded the terminfo file from the repo and set the env variable manually in zshrc, now it works:
export TERMINFO="$HOME/.config/kitty/xterm-kitty"
After for the nth time writing awkward code like
if limit is None:
limit = len(mylist)
decided to see if there’s a better way. Looked into the walrus operator etc,but decided to test what I get with None
.
Well, mylist[:None]
works! No errors, I’d guess I get a copy of it same as mylist[:]
.
Will save me hundreds of lines in the future!
Docu about slice
1 is terse, says it uses range(start,end,step)
under the hood with start
and step
defaulting to None. But range
doesn’t accept None for all arguments! TODO for later I guess.
Stumbled upon python-decouple · PyPI, which seems like a “better” dotenv (supports casting, defaults etc)
For example, this is a settings.ini
in poetry project root:
[settings]
ECHO=True
I can overwrite these parameters like ECHO=False poetry run python myscript.py
Neat!