In the middle of the desert you can say anything you want
Miller (mlr
) is a tool for doing stuff to csvs like jq is for jsqn: Quick examples — Miller 5.10.2 documentation
cocoapi/pycocoDemo.ipynb at master · cocodataset/cocoapi has a nice example of a use case that’s not printlns:
dataDir='..'
dataType='val2017'
annFile='{}/annotations/instances_{}.json'.format(dataDir,dataType)
Nothing was working, neither tqdm nor atpbar, till I used “emulate terminal” in the running config. As soon as I did all bars started working!
Nested loops - for tqdm, nothing needed except just calling it twice. The inner loop, tqdm(iterator, leave=False)
removes the 100% completed inner bar and restarts from 0, so only two bars are seen at the same time.
atpbar (alphatwirl/atpbar: Progress bars for threading and multiprocessing tasks on terminal and Jupyter Notebook) is basically like tqdm. Can’t find an option similar to leave=True
(though didn’t look), and output looks juuust a bit nicer than vanilla tqdm.
Since speedtest-cli is dead, this is an option that works:
curl -o /dev/null http://speedtest-blr1.digitalocean.com/100mb.test
vim -u NONE
. vim -u filenaem
reads only that filename as .vimrc
, NONE
is a key to not use anything.
Finally decided to undertand this part: Vim documentation: pattern
\m
is magic, \M
is nomagic. \m
/magic is the default.\v
is verymagic, \V
is very nomagicHandy table from the documentation:
Examples:
after: \v \m \M \V matches
'magic' 'nomagic'
$ $ $ \$ matches end-of-line
. . \. \. matches any character
* * \* \* any number of the previous atom
() \(\) \(\) \(\) grouping into an atom
| \| \| \| separating alternatives
\a \a \a \a alphabetic character
\\ \\ \\ \\ literal backslash
\. \. . . literal dot
\{ { { { literal '{'
a a a a literal 'a'
Practically:
\v
/verymagic - almost everything has a special meaning (numbers, letters and _
are the only ones parsed as-is)\V
/verynomagic - almost nothing has a special meaning, everything interpreted as-is EXCEPT \
A Vim Guide for Adept Users has these nice tips that I’ll stick to:
My advice in this madness: remember that very magic will allow you to use every regex metacharacter without escaping them, and that very nomagic oblige you to escape these metacharacters to use them.
and
I propose this simple rule:
- When you need a regex, use “very magic” by adding \v before your pattern.
- When you don’t need a regex, use “very nomagic” by adding \V before your pattern.
It also has this nice list:
\s or [:blank:] - whitespace characters.
[A-Z] or \u or [:upper:] - Uppercase.
[a-z] or \l or [:lower:] - Lowercase.
[0-9] or \d or [:digit:] - Digits.
\_ - Character class with end of line included.
pkill aw-
kills all processes whose name starts with aw-
!
rsync.net is a nice no-nonsense offering. They have special prices for borg backups: Cloud Storage for Offsite Backups - borg support
Blog post about setting it up: Remote Backups with Borg | The Cucurbit Developer
rsync.net itself has nice documetation about a lot of stuff: rsync.net Cloud Storage for Offsite Backups
:fill
works not just for moving stuff, but also tracking!
If I tracked A from 11:00 to 11:23 and now it’s 11:30, I can do timew track 2min B :fill
- it will create B
from the end of the previous one until now, so 11:24 - 11:30.
<C-R>
gets vi-mode into search mode, after returning to Normal mode n
/N
work just as expected to do a case-insensitive search of similar things in history
How to Change Your Default Google Account on Mac or PC says that the first one I log into will be the default one.
Webmin is cool and allows to move iptables rules!
A top-level folder can be excluded, but any of the folders inside it can be marked as something else and that will override the parent! Very sensible decision actually, when I think about it
+
register when closingFrom SO:1
autocmd VimLeave * call system("xclip -selection clipboard -i", getreg('+'))
Here vim’s system()
command is interesting:
If you pass a second argument like this, Vim will write it to a temporary file and pipe it into the command on standard input.2
In any case, I should really write some alias to be able to use xclip
and friends by passing parameters to them, not piping stuff - makes any kind of scripting with them much harder.
And to finish, Learn Vimscript the Hard Way seems to be still an excellent introduction to vim itself, even without the scripting part.
ag
/grep output only capturing groupsThis3 describes how to get ag
to output not the match, but only a specific capturing group inside it:
ag -o 'https://\K.*?(?=")'
It uses PCRE features to remove stuff from before and from after the match:
\K
resets the match start(?=")
sets the end to "
- here, "
is what should be after the match, but will not be included in it.Related is Learn PCRE in Y Minutes. PC in PCRE stands for “Perl Compatible”.
PCRE can be enabled in grep
by doing grep -P
, and it’s the default in ag
.
Parametrization · iterative/dvc Wiki is an experimental feature.
Allows to call parameters directly, such as:
stages:
build:
foreach: ${models}
do:
cmd: >-
python script.py
--out ${item.filename}
--thresh ${item.thresh}
outs:
- ${item.filename}
as opposed to getting your program to read parameters.yaml
IPSet set structures: wiki.ipfire.org - IPset
To create an ipv6 ipset that supports domain ranges, we need the hash:net
one:
ipset create my6 hash:net family inet6
Nice subnet calculators:
iptables
doesn’t do ipv6, but ip6tables
does, seems to be installed by default along with vanilla iptables. Commands seem to be identical.
iptables-save > some_output_file
to save them to a file (this alone doesn’t make it persist reboots)iptables-persistent
does what is says on the label,1 for rules being saved in:
/etc/iptables/rules.v4
/etc/iptables/rules.v6
ipset save > output_file
ipset save -f output_file
ipset restore -f output_file
ipset restore < output_file
The output files it generates seem to be the exact commands without the leading ipset
?
Looked into yunohost’s recommendations, there’s a best practice.2 Created a shell script that does ipset restore -f file
and then runs the iptables commands, put it into /etc/yunohost/hooks.d/post_iptable_rules/99-specific_rules
. Survived a reboot, mission accomplished.
> mktemp /tmp/somescript.XXXX
/tmp/somescript.6Zxi
mktemp
creates random files with a set format, replacing the XXX
with random characters, and returns the filename (+ can also create directories). Cool!
theskumar/python-dotenv: Get and set values in your .env file in local and production servers.
Duc: Dude, where are my bytes! - both GUI and cli interface. Love it!
#!/bin/bash
run_command(){
echo "The thing that will be run in parallel"
}
for i in {1..20}
do
run_command $i &
done