From 4a0b7ea1822015d05681254061eb0e4608599773 Mon Sep 17 00:00:00 2001 From: neingeist Date: Fri, 2 Jul 2021 17:06:16 +0200 Subject: [PATCH 1/8] =?UTF-8?q?=E2=9A=99=EF=B8=8F=20find-junk:=20add=20~/.?= =?UTF-8?q?local/share/apt-dater/history?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- find-junk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/find-junk b/find-junk index 4416799..7910e7e 100755 --- a/find-junk +++ b/find-junk @@ -15,7 +15,7 @@ def junk_dirs(): """Return directories which potentially contain junk""" for d in ['~/tmp', '~/.local/share/Trash', '~/rpmbuild', '~/RPM', - '~/.cache/tracker']: + '~/.cache/tracker', '~/.local/share/apt-dater/history']: d = os.path.expanduser(d) if os.path.exists(d): yield d From 036fd39041da1212bd34941b3f7e4ab1fdb932ce Mon Sep 17 00:00:00 2001 From: neingeist Date: Fri, 26 Nov 2021 09:21:15 +0100 Subject: [PATCH 2/8] =?UTF-8?q?=F0=9F=90=9B=20saubermann:=20do=20not=20che?= =?UTF-8?q?ck=20/etc/sv/ssh=20for=20dangling=20symlinks?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- saubermann | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/saubermann b/saubermann index 2313570..cfddc01 100755 --- a/saubermann +++ b/saubermann @@ -1,5 +1,6 @@ #!/bin/sh # check for common problems + junk +# https://github.com/neingeist/dirty-helpers is_debian() { @@ -12,7 +13,7 @@ is_fedora() { echo "== Dangling symlinks in /etc" -find /etc -type l -and -xtype l | egrep -v 'blkid.tab|/var/log/dropbear' +find /etc -type l -and -xtype l | egrep -v 'blkid.tab|/var/log/dropbear|/etc/sv/ssh' echo "== Trashes" for t in /home/*/.local/share/Trash; do From aca0f41d6576b709ccdf80b2c0ec7563df283070 Mon Sep 17 00:00:00 2001 From: neingeist Date: Sat, 28 May 2022 14:01:42 +0200 Subject: [PATCH 3/8] =?UTF-8?q?=E2=9C=A8=20wiewardertatort?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- wiewardertatort | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100755 wiewardertatort diff --git a/wiewardertatort b/wiewardertatort new file mode 100755 index 0000000..c464518 --- /dev/null +++ b/wiewardertatort @@ -0,0 +1,29 @@ +#!/usr/bin/env python3 + +import requests +import re +import click +from bs4 import BeautifulSoup + + +@click.command() +@click.argument('search_title') +def search(search_title): + q = requests.utils.quote(search_title) + url = f"https://www.wiewardertatort.de/search?q={q}" + + soup = BeautifulSoup(requests.get(url).text, features="lxml") + + for post_outer in soup.select("div.post-outer"): + title = post_outer.select_one("h3.post-title").a.text + print(title) + + if m := re.search(r"Bewertung: (\d+)/", post_outer.text): + bewertung = int(m.group(1)) + print(bewertung) + + +if __name__ == '__main__': + search() + +# vim:ft=python:tw=120: From a58706e9aa9da18a1d5c572a0d02edd982a0050e Mon Sep 17 00:00:00 2001 From: neingeist Date: Sat, 28 May 2022 14:02:01 +0200 Subject: [PATCH 4/8] =?UTF-8?q?=E2=9C=A8=20rmdir-empty?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- rmdir-empty | 3 +++ 1 file changed, 3 insertions(+) create mode 100755 rmdir-empty diff --git a/rmdir-empty b/rmdir-empty new file mode 100755 index 0000000..a2db42d --- /dev/null +++ b/rmdir-empty @@ -0,0 +1,3 @@ +#!/bin/sh +# recursively delete empty directories +find . -depth -type d -empty -exec rmdir -v {} \; From c540423ba3e3c63b9751756a19b5fd3debd1f260 Mon Sep 17 00:00:00 2001 From: neingeist Date: Tue, 18 Oct 2022 16:45:39 +0200 Subject: [PATCH 5/8] =?UTF-8?q?=F0=9F=90=9B=20rmdir-empty:=20ignore=20cwd?= =?UTF-8?q?=20to=20avoid=20error=20message?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- rmdir-empty | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/rmdir-empty b/rmdir-empty index a2db42d..9a9ad64 100755 --- a/rmdir-empty +++ b/rmdir-empty @@ -1,3 +1,5 @@ #!/bin/sh # recursively delete empty directories -find . -depth -type d -empty -exec rmdir -v {} \; +find . -depth \ + -path "." -prune -or \ + -type d -empty -exec rmdir -v {} \; From 109fc110c14e12405347701a960c883984ddbb71 Mon Sep 17 00:00:00 2001 From: neingeist Date: Fri, 6 Jan 2023 13:19:29 +0100 Subject: [PATCH 6/8] =?UTF-8?q?=F0=9F=90=9B=20ssh=5Fknown=5Fdupes:=20use?= =?UTF-8?q?=20python3=20interpreter?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ssh_known_dupes | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ssh_known_dupes b/ssh_known_dupes index 7602c24..6ad959f 100755 --- a/ssh_known_dupes +++ b/ssh_known_dupes @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 # Find duplicate keys in ~/.ssh/known_hosts # # Of course, we should have been more careful in the first place :) From a295c5c0c69477fc5cb61b3465bd04e9b570137b Mon Sep 17 00:00:00 2001 From: neingeist Date: Mon, 9 Jan 2023 23:28:42 +0100 Subject: [PATCH 7/8] =?UTF-8?q?=F0=9F=90=9B=20git-status-all:=20get=20work?= =?UTF-8?q?ing=20tree=20directory=20via=20pathlib?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- git-status-all | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/git-status-all b/git-status-all index f863d22..fc17fd2 100755 --- a/git-status-all +++ b/git-status-all @@ -4,13 +4,14 @@ from __future__ import division, print_function from colorama import Fore +from pathlib import Path import contextlib import os import subprocess -def git_directories(startdir): +def git_directories(startdir) -> Path: for dirpath, dirnames, _ in os.walk(startdir): if '.sync' in dirpath: continue @@ -18,11 +19,11 @@ def git_directories(startdir): # FIXME continue if set(['info', 'objects', 'refs']).issubset(set(dirnames)): - yield dirpath + yield Path(dirpath) @contextlib.contextmanager -def working_directory(directory): +def working_directory(directory: Path): saved_cwd = os.getcwd() os.chdir(directory) yield @@ -30,7 +31,12 @@ def working_directory(directory): for git_directory in git_directories('.'): - work_tree_directory = git_directory[:-4] + # technically,we could have a different GIT_DIR than ".git", but this script + # assumes ".git". + if git_directory.parts[-1] != ".git": + continue + work_tree_directory = git_directory.parent + with working_directory(work_tree_directory): try: out = subprocess.check_output(['git', 'status', '-s'], stderr=subprocess.STDOUT) From 7bc79861e11041c21df25039ab34222f1c058841 Mon Sep 17 00:00:00 2001 From: neingeist Date: Mon, 20 Feb 2023 15:45:47 +0100 Subject: [PATCH 8/8] =?UTF-8?q?=E2=9C=A8=20rmdir-empty:=20take=20directory?= =?UTF-8?q?=20arguments?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- rmdir-empty | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/rmdir-empty b/rmdir-empty index 9a9ad64..774fff5 100755 --- a/rmdir-empty +++ b/rmdir-empty @@ -1,5 +1,15 @@ #!/bin/sh # recursively delete empty directories -find . -depth \ - -path "." -prune -or \ - -type d -empty -exec rmdir -v {} \; + +rmdir_empty() { + # make default . explicit + if [ -z "$1" ]; then + set -- . + fi + + find "$@" -depth \ + -path "." -prune -or \ + -type d -empty -exec rmdir -v {} \; +} + +rmdir_empty "$@"