In the middle of the desert you can say anything you want
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
What do I need?
Options:
Random:
JacobEvelyn/friends: Spend time with the people you care about. Introvert-tested. Extrovert-approved. is really nice!
> friends add activity three days ago: Some activity three days ago <<<
Activity added: "2021-05-30: Some activity three days ago"
# also works:
> friends list activities --since="two month ago"
As with taskwarrior, things can get arbitrarily shortened as long as they remain unique!
friends a ac "some activity"
(you can add both an activity and an alias)
Found this: How to use collections on addons.mozilla.org | Firefox Help
TL;DR create an extension collection on Firefox’s website, then from Fennec or Firefox Nightly they can be installed! Wooooohooo!
Also TIL about Fennec - seems like a Firefox fork without features that are ‘considered harmful’
task log
adds a task and sets its status to completed! 1
As a bonus, tasks that don’t have a specific tag are task -notthistag list
To add all the swapfiles generated by vim (.swp
, .swo
, etc) to gitignore:2
.*.sw*
Here’s also interesting Github’s own .gitignore
for vim files: gitignore/Vim.gitignore at master · github/gitignore
graph-tool: Efficent network analysis with python looks like a really good and modern graph theory library for python
You Don’t Need to Rebuild Your Development Docker Image on Every Code Change · vsupalov.com
Got solved by using jemalloc instead of malloc. … No idea why and how that works.
keshavbhatt/red: Red - Privacy focused Youtube player and download manager for Linux, uses youtube-dl as backend. afaik it’s snap-only.
Unstable and crashes a lot though :(
Can be done through dev tools! Clear all site data, just cookies, or anything else. [^qbprivgithub ]
Will be using the old and awesome Git - Book and a small test local repo.
git status -s
is short git status
Setting it in Dockerfiles is discouraged (even by the official Docker FAQ 1) because it’s mainly cosmetic & may create unwanted side effects.
For me, tzdata wanted input and waited for it:
[17:01:56][Step 1/3] debconf: falling back to frontend: Readline
[17:01:56][Step 1/3] Configuring tzdata
[17:01:56][Step 1/3] ------------------
[17:01:56][Step 1/3]
[17:01:56][Step 1/3] Please select the geographic area in which you live. Subsequent configuration
[17:01:56][Step 1/3] questions will narrow this down by presenting a list of cities, representing
[17:01:56][Step 1/3] the time zones in which they are located.
[17:01:56][Step 1/3]
[17:01:56][Step 1/3] 1. Africa 4. Australia 7. Atlantic 10. Pacific 13. Etc
[17:01:56][Step 1/3] 2. America 5. Arctic 8. Europe 11. SystemV
[17:01:56][Step 1/3] 3. Antarctica 6. Asia 9. Indian 12. US
Fixed this by adding this command specifically before the one requiring it:
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y
TODO: Vaex: Pandas but 1000x faster - KDnuggets
Looks interesting. Why is it faster?
subprocess.run()
is the newer version of ..call()
. Can run a string like this:
subprocess.run("echo one two three", shell=True)
Generate password, paste it into a textfield, and xclip the output:
#!/usr/bin/python3
import os
import string
import secrets
from subprocess import run
alphabet = string.ascii_letters + string.digits
password = ''.join(secrets.choice(alphabet) for i in range(8))
run(f"echo {password} | xclip -selection c", shell=True)
with open(os.environ['QUTE_FIFO'], 'w') as f:
f.write(":insert-text {}".format(password))
Generate a throwaway email with email based on domain (so if I were to run it on google.com, it’d generate google@wildcard.mydomain.net
:
#!/usr/bin/python3
import os
import tldextract
import argparse
import sys
argument_parser = argparse.ArgumentParser()
argument_parser.add_argument('--subdomain', '-s', default='t',
help='subdomain ("t" would do "@t.email_host.net")')
argument_parser.add_argument('--email_host', '-d', default='email_host.net',
help='main domain where you\'ll get the emails')
argument_parser.add_argument('--username', '-u', default=None,
help='the name used for email username (name@...)')
def main(args):
my_domain = args.email_host
subdomain = args.subdomain
if args.username is not None:
username = args.username
else:
url = os.environ['QUTE_URL']
extract_result = tldextract.extract(url)
username = extract_result.domain
address = f"{username}@{subdomain}.{my_domain}"
with open(os.environ['QUTE_FIFO'], 'w') as f:
f.write(":insert-text {}".format(address))
if __name__ == '__main__':
arguments = argument_parser.parse_args()
sys.exit(main(arguments))
Use-case for both - quick easy registration in pointless places.
My older approach was to use this:
run_watch VPN {
pidfile = "/etc/openvpn/mv.pid"
}
And start openvpn in a way that it writes that specific pid file.
i3: i3status(1)’s documentation points at this:
path_exists VPN {
# path exists when a VPN tunnel launched by nmcli/nm-applet is active
path = "/proc/sys/net/ipv4/conf/tun0"
}
On my computer it was tap0
instead of tun0
. But it works!
My ~/.dotfiles
is a symlink to another place. stow
follows it, and uses as target the parent directory of the directory the symlink points to, not ~/
!
Explicitly setting a target directory is stow -t ~/ thing-to-stow
(interestingly, stow -t ../
also uses the parent directory relative to the symlink target of the current one).
First I did the logical thing:
alias st='stow -t ~/'
Then, after reading the manual1, created a ~/.stowrc
:
--target=~/
Works now :)
Wallabag supports tagging rules based on parameters, such as domain names or reading time. Nice!
Added ww
as binding to the bookmarklet.
I finally moved Fiamma (my link wiki) to a the new server! Which reminded me about the bindings I wrote to automatically format the input for the links I add there.
For example, on Ron Burk: Commas Depend on Linebreaks - Fiamma, I edited the pre-filled things to look like this:
http://ronburk.blogspot.de/2009/09/commas-depend-on-linebreaks.html
Ron Burk: Commas Depend on Linebreaks
6
5
language, linguistics, internet, style, etiquette, mildly interesting
Language
Style
Then a vim snippet from hell transformed it to
{{B|
http://ronburk.blogspot.de/2009/09/commas-depend-on-linebreaks.html
|Ron Burk: Commas Depend on Linebreaks
|6
|5
}}
{{#set:
k=language, linguistics, internet, style, etiquette, mildly interesting
|+sep=, }}
[[Category: Language]]
[[Category: Style]]
Though they were in latin-1
encoding, the .vimrc got converted to utf8, and it all got lost.
Now I have a solution. ~/.config/qutebrowser/.qb-vimrc
is:
source ~/.vimrc
" let @H = 'gg<80>ýc<80>ýbi<80>ýc<80>ýb{{B|^[^[^[j0i|^[^[^[ji|j<80>kb^[^[^[ji|^[^[^[o}};q' " For the 5 lines
" let @L = 'ji{{$<80>kb%<80>kb#set:\^Mk=<80>kD^[o|+sep=,}}^[' " For the tags
" let @C = 'i[[C;tj<80>kb<80>kb<80>kbategory: ^[^[^[A]];q' " For each individual category
" let @F = 'jjVG:norm! @C\^M' "Apply that to all lines till the end
" let @d = '@H@L@F'
" let @q = '^[A^[bbbbbbi|<80>ü^B<80>kb^[:%s/=/{{=}}/ge^M'
" Summed up:
let @C = 'i[[C;tj<80>kb<80>kb<80>kbategory: ^[^[^[A]];q' " For each individual category
"let @H = '^[A^[bbbbbbi|<80>ü^B<80>kb^[:%s/=/{{=}}/ge^Mgg<80>ýc<80>ýbi<80>ýc<80>ýb{{B|^[^[^[j0i|^[^[^[ji|j<80>kb^[^[^[ji|^[^[^[o}};qji{{$<80>kb%<80>kb#set:^Mk=<80>kD^[o|+sep=,}}^[jjVG:norm! @C^M:x^M'
let @H = '^[A^[bbbbbbi|<80>ü^B<80>kb^[:%s/=/{{=}}/ge^Mgg<80>ýc<80>ýbi<80>ýc<80>ýb{{B|^[^[^[j0i|^[^[^[ji|j<80>kb^[^[^[ji|^[^[^[o}};qji{{$<80>kb%<80>kb#set:^Mk=<80>kD^[o|+sep=,}}^[jjVG:norm! @C^M' " Without closing at the end
" let @d = '@H@L@F'
" Start in insert mode
startinsert
And in qutebrowser config, I set the editor to:
c.editor.command = ['kitty', 'vim', '-u', str(config.configdir / '.qb-vimrc'), '+{line}', '{file}']
This way, standard-vim uses the standard fancy utf8 config file, but qutebrowser uses a separate one that overwrites the needed lines with the latin-1 macros. vim +10 filename
means open it and put the cursor on line 10, idea comes from Reddit[^ideared
(Macros are really hard to read. How can I use something like python next time for this?)
Also - them being defined in the ~/.vimrc
seems to have broken the newer ones, had to comment them out. Does vim not like redefined macros?
Updated my yank-for-markdown yank.py
userscript to remove the anchor text ("…#!~:text=Text on the page to scroll to"), so I can paste it without it messing up the markdown formatting:
#!/usr/bin/python3
import os
title = os.environ['QUTE_TITLE']
title = title.replace("|", "\\|")
url = os.environ['QUTE_URL']
url = url.split("#:~:")[0]
command = "yank inline \"[{}]({})\"".format(title, url)
with open(os.environ['QUTE_FIFO'], 'w') as f:
f.write(command)
Rewrote the whole mechanism, now there’s one template that gets pre-filled by URI. First the qb userscript gets the data, writes them to a file; then opens this file in vim. When closed, it calls the new template passing the entire content of the file as first parameter.
Better because much simpler and less steps needed.
[23:07:35]
i mean, i have important work to do. dealing with an IRC network is not really something i want to be doing this decade outside of fucking around for fun with IRCX [23:07:51] i have code running on two planets 2
I think I have this time - removing state
got it to start without reinstalling/changing anything.
screen
in places that don’t support screenFigured out myself and kinda proud of this one. If server1 doesn’t have screen, you can ssh to it from inside screen
of a server2 that does have screen! As long as the SSH connection is there it’ll work.
When doing jsons.dumps(thing)
where thing
has np.float32
s inside it, you get the error:
TypeError: Object of type 'float32' is not JSON serializable
This is fixed by:
json.dumps(str(thing))
(though will return it as string, may or may not be what we want)np.float32
s to standard python float
before adding them to the objectmosquito
is an ubuntu implementation of the mqtt protocol, which is “subscribe to a broker for messages of type X and you’ll get them” - seems to be a standard like REST.(from V.H’s presentation about “Как подключить вайфай к чайнику для чайников”)
German tutorial about preprocessing German with NLTK: Preprocessing
Added a zsh binding that in vi command mode launches edit-command-line
to edit the current line in vim proper:
bindkey -M vicmd v edit-command-line
Doesn’t conflict with zsh-vim-mode-plugin. It’s nice how they all build upon the existing zsh infrastructure and I can keep adding my own bindings using the same mechanisms.