Skip to content

Instantly share code, notes, and snippets.

View yannickperrenet's full-sized avatar
👊
Teamwork

Yannick Perrenet yannickperrenet

👊
Teamwork
View GitHub Profile
@yannickperrenet
yannickperrenet / analyze.py
Created May 28, 2024 17:50
Analyze all DNS queries on systems with systemd
"""Analyze all DNS queries on systems with systemd.
Does our ad-blocker block all the requests that we want it to? Do I have
to add more entries to my `/etc/hosts` file? Find out.
```sh
sudo resolvectl monitor --json=short >> dns-queries-json
```
Output:
@yannickperrenet
yannickperrenet / main.py
Created May 2, 2024 12:41
Run a CMD whenever particular words are typed in any window
"""Run `CMD` whenever any of the `FORBIDDEN_WORDS` is typed.
Reading keyboard input regardless of window focus requires sudo:
```sh
python3 -m venv venv
venv/bin/pip install keyboard==0.13.5
sudo venv/bin/python main.py
```
@yannickperrenet
yannickperrenet / qftoggle.lua
Last active May 19, 2023 14:33
Toggle the Quickfix window in Neovim
local function qf_toggle()
local qfbufnr = vim.fn.getqflist({ qfbufnr = 0 }).qfbufnr
-- Whether the qf buffer is open in a window
local has_win
if qfbufnr == 0 then -- Quickfix buffer doesn't exist
has_win = false
else -- Quickfix buffer has been open before
if #vim.fn.win_findbuf(qfbufnr) > 0 then
has_win = true
else
@yannickperrenet
yannickperrenet / convert_vimwiki_to_markdown.sh
Last active March 6, 2022 19:43
Convert vimwiki files to markdown files
# Check extensions and see whether you want to add any.
# Extensions can be added like `--to=gfm+extension_name`
pandoc --list-extensions=gfm
# Note: make sure you are on the latest version of pandoc.
# Older versions might not convert fenced code blocks
# correctly.
# Known issues:
# - "Wikilinks" (the linking to another document) will break.
fd -e wiki --exec pandoc \