Skip to content

Instantly share code, notes, and snippets.

Avatar

Stefan stefanschmidt

  • Berlin, Germany
View GitHub Profile
@stefanschmidt
stefanschmidt / delete-addon-prefs.py
Created Apr 23, 2022
Delete Firefox Addon preferences
View delete-addon-prefs.py
import sys
import glob
import os
import configparser
import json
import sqlite3
# Functions for finding Firefox default profile folder adapted from
# https://github.com/1dot75cm/browsercookie
@stefanschmidt
stefanschmidt / setup.py
Created Apr 22, 2022
Clean Python build directory
View setup.py
import os
import glob
import shutil
from io import open
from setuptools import Command, setup
# Slightly modified and extended version of this approach:
# https://github.com/pypa/setuptools/issues/1347#issuecomment-387802255
@stefanschmidt
stefanschmidt / download-file-selenium-firefox.py
Created Apr 14, 2022
Download file in headless Firefox with Selenium and geckodriver on macOS
View download-file-selenium-firefox.py
# install requirements
# brew install python@3.10 # Python 3.7+ required
# brew install geckodriver # To access Firefox
# pip install --upgrade selenium
from selenium import webdriver
from selenium.webdriver.firefox.options import Options
options = Options()
options.headless = True
@stefanschmidt
stefanschmidt / install-opencv-python-mojave.sh
Last active Mar 31, 2022
Install latest built distribution of OpenCV python bindings on macOS Mojave with Homebrew and pip
View install-opencv-python-mojave.sh
brew install python@3.9
pip3.9 install opencv-python==4.5.1.48
@stefanschmidt
stefanschmidt / chkrootkit-mojave-timed.log
Created Mar 29, 2022
chkrootkit 0.55 reports false positive for timed on macOS Mojave 10.14.6 (18G103)
View chkrootkit-mojave-timed.log
$ sw_vers | grep -E 'ProductVersion|BuildVersion'
ProductVersion: 10.14.6
BuildVersion: 18G103
$ brew install chkrootkit
==> Downloading https://ghcr.io/v2/homebrew/core/chkrootkit/manifests/0.55
Already downloaded: /Users/stefan/Library/Caches/Homebrew/downloads/09b127ebda92fbe220c997e4b03716223b647c1893d08c2f8f35ccac65b71a0a--chkrootkit-0.55.bottle_manifest.json
==> Downloading https://ghcr.io/v2/homebrew/core/chkrootkit/blobs/sha256:dcb47fe
Already downloaded: /Users/stefan/Library/Caches/Homebrew/downloads/a1e9dccaef720633989239dbd3fcb79d4fc7252965ed73e7eb4a2ffe2795a0b4--chkrootkit--0.55.mojave.bottle.tar.gz
==> Pouring chkrootkit--0.55.mojave.bottle.tar.gz
🍺 /usr/local/Cellar/chkrootkit/0.55: 15 files, 170.8KB
@stefanschmidt
stefanschmidt / tesseract-ocr-macos.sh
Created Mar 26, 2022
OCR an image file with german language with tesseract on macOS
View tesseract-ocr-macos.sh
brew install tesseract
brew install tesseract-lang
tesseract -l deu input.png output.txt
@stefanschmidt
stefanschmidt / fileinfo.py
Created Mar 13, 2022
Simple command line interface for fileinfo.com
View fileinfo.py
#!/usr/bin/env python
import sys
import requests as req
from bs4 import BeautifulSoup
if not(len(sys.argv) == 2):
sys.exit("Usage: fileinfo.py extension")
ext = str(sys.argv[1])
@stefanschmidt
stefanschmidt / batch-re-crawl-pinboard-bookmarks.js
Last active Mar 9, 2022
Batch re-crawl all Pinboard bookmarks that show an error 500 instead of a link to an archived copy
View batch-re-crawl-pinboard-bookmarks.js
/*
1. Open https://pinboard.in/u:account/code:500 in browser
2. Maximize the number of displayed bookmarks per page (160)
3. Open the JavaScript Console in browser
4. Paste the below snippet to re-crawl all links with error 500
5. Refresh browser and repeat as needed
*/
const list = document.querySelectorAll('a[title="Click to re-crawl this link"]');
const regexp = /mark_for_recrawl\(this, (\d+), '([0-9a-f]+)'\);return false;/g;
@stefanschmidt
stefanschmidt / charles-proxy-rewrite-reponse.xml
Last active Mar 5, 2022
Charles Proxy rewrite rule to remove object-src 'none'; from HTTPS response headers for PDF files from afaa.com to enable display in Safari avoiding "Blocked Plugin-In" error
View charles-proxy-rewrite-reponse.xml
<?xml version='1.0' encoding='UTF-8' ?>
<?charles serialisation-version='2.0' ?>
<rewriteSet-array>
<rewriteSet>
<active>true</active>
<name>AFAA</name>
<hosts>
<locationPatterns>
<locationMatch>
<location>