Skip to content

Instantly share code, notes, and snippets.

@ThePsyjo
ThePsyjo / .zshrc
Created July 21, 2023 10:46
Atuin delete session history on exit
# run `nh` any time in the session to delete it's history on session exit.
alias nh="export ATUIN_DELETE_HISTORY=1"
__delete_history_on_exit() {
if [[ $ATUIN_DELETE_HISTORY ]]
then
# echo $ATUIN_SESSION >> /tmp/debug
# stick to tomlq to get the db from config or hardcode db path here
db=$(tomlq -c .db_path < ~/.config/atuin/config.toml)
[[ "${db}" == "null" || -z "${db}" ]] && db="~/.local/share/atuin/history.db"
@ThePsyjo
ThePsyjo / remove_click_selects_all_105.patch
Created September 23, 2022 08:13
this prevents LMB click on URL bar (if it wasn't already focused) from getting the equivalent of Ctrl+A aka Select All ie. it acts as if browser.urlbar.clickSelectsAll=false AND browser.urlbar.doubleClickSelectsAll=false so only triple click will Select All. See: https://bugzilla.mozilla.org/show_bug.cgi?id=1621570 or https://bugzilla.mozilla.or…
diff -r 078326f48100 browser/components/urlbar/UrlbarInput.jsm
--- a/browser/components/urlbar/UrlbarInput.sys.mjs Tue Apr 14 06:41:42 2020 +0000
+++ b/browser/components/urlbar/UrlbarInput.sys.mjs Tue Apr 14 16:01:40 2020 +0200
@@ -3101,6 +3101,8 @@
if (event.target.id == SEARCH_BUTTON_ID) {
this._preventClickSelectsAll = true;
this.search(lazy.UrlbarTokenizer.RESTRICT.SEARCH);
+ } else if (event.target == this.inputField) {
+ this._preventClickSelectsAll = true;
@ThePsyjo
ThePsyjo / kafka_delete_consumed.py
Last active July 17, 2024 21:49
Script to reset the start position of partitions in kafka topics close to the consumer-group's offset
"""Reset the low watermark of partitions close to the point where given consumer-group has been."""
import argparse
import sys
from collections import OrderedDict
from json import dumps, loads
from pprint import pformat
from subprocess import PIPE, Popen
from tempfile import NamedTemporaryFile
from typing import Generator, Iterable, Union
@ThePsyjo
ThePsyjo / fix_policies.sh
Last active February 17, 2022 15:04
fix_policies.sh
# ~/.es has to contain {"username": "...", "password": "...", "endpoint": "https://..."}
es_config(){ jq -r ".$1" < ~/.es; }
es_api ()
{
url=$1;
shift;
curl -ku $(es_config username):$(es_config password) -s "$(es_config endpoint):9200/${url}" "$@"
}