In the middle of the desert you can say anything you want
When adapting an example qtile config1 that used volume keys (XF86AudioRaiseVolume
etc.) discovered that I can lock the function keys by pressing <Fn-Esc>
. Then a LED turns on, and all the F-keys become function keys.
(Or the opposite, I guess, with default BIOS settings).
Wanted to show the currently active taskwarrior task (220209-1901 taskwarrior getting currently active task) in my statusbar.
Github had helpful discussion1 that led me to this qtile widget code:
widget.GenPollText(
update_interval=1,
func=lambda: subprocess.check_output("path/to/my/get_tasks.sh").decode( "utf-8").strip(),
),
that runs this shell script:
#!/bin/bash
task rc.verbose=nothing rc.color=off a || true
The || true
bit makes sure the return code is 0. Taskwarrior returns 1
if no tasks are shown, in this case - if no task is in progress.
j
Adding a semi-random number of X
after each character of a password is better than giving no output a la linux sudo
(bad UX) or writing a single *
(unsafe).
Not allowing pasting in the password prompt, then creating weird complex first-time passwords with O
s and 0
s is worse than both.
Pycharm was slow. Googled for stuff, removed extensions, gave it more memory etc.
Solution from Everything - JetBrains YouTrack:
rm .cache/JetBrains/PyCharmCE2021.3/icons-v3.db
Deleting icon cache made all menus etc. fast.
Fascinating.
FUNSD is a “dataset for Text Detection, Optical Character Recognition, Spatial Layout Analysis and Form Understanding” and contains annotated forms. Initially I saw it when looking at HF layout datasets1.
ralphbean/taskw: python taskwarrior api is a Python lib to talk to Taskwarrior, by default through the import/export functionality.
Looks really neat and is a better way to parse the tasks for my statusbar than my planned “read and parse the shell output of the cli command”
Create a new project, point it at the folder with the sources, and instead of trying to use an existing poetry environment, just create a new one. It will use the same virtualenv as usual when running poetry shell
inside that directory. Nice!1
The project uses ./src/package_name
layout (220105-1142 Order of directories inside a python project), which created issues in the editor (tests and files run fine though). Fixed by adding ./src
as Source Root, then it parses all imports as packgae name
Official Black instructions for Pycharm worked for me: Editor integration — Black 21.12b0 documentation
This was tricky! I found a really nice post2 that showed how to spawn vim from ideavim. I tried following its example but
nmap <leader>f :action Tool_External_Tools_black<CR>
didn’t work.
The post mentioned running :actionlist
inside the editor to get the list of all available actions (I used to rely on a github gist for that!). Well, would you believe, External Tools
has a space inside it.
So the correct line is:
nmap <leader>f :action Tool_External Tools_black<CR>
Wow. …Wow.
In any case works now!
Reddit suggested using poetry env info
, which gives info about the environment, and add that interpreter to pycharm directly ↩︎
Customising IdeaVim - Chathura Colombage; His example .ideavimrc from that post is really really interesting, TODO steal ideas! ↩︎
NLP Course @ lena-voita.github.io
(Ty AA for the link!)
This is a really nice course covering the basics of NLP, putting it here for now, until I finally finish setting https://serhii.net/links/ up.
Covers:
After enabling “strict” newlines for markdown/hugo conformity I had to decide whether newline would be two trailing space or a single backspace (Line breaks in markdown)
Backspaces didn’t work out, so whitespaces it is - how to make them visible when editing?
Obsidian forum1 provided this wonderful snippet:
.cm-trailing-space-new-line, .cm-trailing-space-a, .cm-trailing-space-b, .cm-tab{
font-size: 0;
}
.cm-trailing-space-a::before, .cm-trailing-space-b::before, .cm-trailing-space-new-line::before, .cm-tab::before{
content:'·';
color:var(--text-faint);
font-size: initial;
}
.cm-trailing-space-new-line::before {
content:'↵';
}
.cm-tab::before {
content:'⟶'
}
Works!
(And shows tabs as bonus, perfect.)
I seem to keep googling this. … and this is not final and magic and I should actually understand this on a deeper level.
Not today.
So.
Reading lines in a file:
while IFS="" read -r p || [ -n "$p" ]
do
printf '%s\n' "$p"
done < peptides.txt
For outputs of a command:
while read -r p; do
echo $p;
done < <(echo "one\ntwo")
Otherwise: Easy option that I can memorize, both for lines in command and in file that will will skip the last line if it doesn’t have a trailing newline:
for word in $(cat peptides.txt); do echo $word; done
Same idea but with avoiding this bug:
cat peptides.txt | while read line || [[ -n $line ]];
do
# do something with $line here
done
Same as first cat
option above, same drawbacks, but no use of cat
:
while read p; do
echo "$p"
done <peptides.txt
``
Same as above but without the drawbacks:
while IFS="" read -r p || [ -n "$p" ]
do
printf '%s\n' "$p"
done < peptides.txt
This would make command read from stdin, 10
is arbitrary:
while read -u 10 p; do
...
done 10<peptides.txt
(All this from the same SO answer1).
In general, if you’re using “cat” with only one argument, you’re doing something wrong (or suboptimal).