Skip to content

Instantly share code, notes, and snippets.

View custom_traceback_example.py
import linecache
import re
import sys
from types import TracebackType
from typing import Any, Dict, List, Optional
PACKAGE_PATH_PATTERN = r'.*/lib/python.*/site-packages/.*'
class TracebackLogger:
@bmatthewshea
bmatthewshea / certbot_install_ubuntu20+.md
Last active Jul 27, 2022
Ubuntu 20 - CERTBOT without SNAP/SNAPD
View certbot_install_ubuntu20+.md

CERTBOT - Install using Python PIP

Install Certbot using Python PIP (Package Installer for Python) without using SNAP, APT or SYSTEMD) (Debian/Ubuntu)

This guide will help you install LetsEncrypt / Certbot and a DNS plugin (certbot-dns-route53) using PIP under Debian/Ubuntu.

  • You should already be somewhat familiar with LetsEncrypt, Certbot and any plugin you might need.

  • This guide uses a DNS provider plugin (AWS Route53), but this is really about the install method - not plugins, or validation methods.

@jerieljan
jerieljan / btt-screenshot.sh
Created May 22, 2021
Screenshot OCR with BetterTouchTool on MacOS
View btt-screenshot.sh
#!/usr/bin/env bash
# Usage:
# - Install `tesseract` with `brew install tesseract`
# - In BetterTouchTool, create a trigger of your choice.
# (I recommend a Keyboard Shortcut with Cmd+Shift 6)
# - Add an Execute Shell Script / Task action
# - Paste this script.
# NOTE: You'll need to authorize BTT to the Screen Recording permission in Security and Privacy at System Preferences
@tonetheman
tonetheman / find_radio.py
Created Sep 27, 2020
find a radio button to click on
View find_radio.py
URI = "https://www.16personalities.com/free-personality-test"
from selenium.webdriver import Chrome, ChromeOptions
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
@dnanto
dnanto / geomid.R
Created Jun 25, 2020
Calculate the geographic midpoint given a list of geographic coordinates in R.
View geomid.R
library(tidyverse)
geomid <- function(lat, lon)
{
# http://www.geomidpoint.com/calculation.html
lat <- lat * pi / 180
lon <- lon * pi / 180
x <- mean(sum(cos(lat) * cos(lon)))
y <- mean(sum(cos(lat) * sin(lon)))
z <- mean(sum(sin(lat)))
@kix2mix2
kix2mix2 / kcng.py
Created Jan 27, 2020
K-Nearest Center of Gravity Graph (KNCG)
View kcng.py
def get_kncg(df, K=4):
# df is a pandas dataframe with mandatory columns ['x','y']
graph = get_knntree(df, 1)
for node_a, row in df.iterrows():
if node_a % KK_prints == 0:
print(K)
node_a_coord = list(row[:2])
ncns = []
@TheCloudScout
TheCloudScout / dockerfile
Created Nov 4, 2019
adsha-windowsservercore-ltsc2019-dotnet-4.8
View dockerfile
# escape=`
FROM mcr.microsoft.com/windows/servercore:ltsc2019
# Install .NET 4.8
RUN curl -fSLo dotnet-framework-installer.exe https://download.visualstudio.microsoft.com/download/pr/7afca223-55d2-470a-8edc-6a1739ae3252/abd170b4b0ec15ad0222a809b761a036/ndp48-x86-x64-allos-enu.exe `
&& .\dotnet-framework-installer.exe /q `
&& del .\dotnet-framework-installer.exe `
&& powershell Remove-Item -Force -Recurse ${Env:TEMP}\*
@nestukh
nestukh / installheadlessfirefoxonpi.sh
Last active Aug 15, 2022
Install firefox-esr + geckodriver + selenium + python3 on raspberry pi 3 and above
View installheadlessfirefoxonpi.sh
#!/bin/bash
pypcks="python3-pip python3 python3-all-dev python3-dev libffi-dev libssl-dev librtmp-dev python-dev python3 python3-doc python3-tk python3-setuptools tix xvfb python-bluez python-gobject python-dbus python cython python-doc python-tk python-numpy python-scipy python-qt4 python3-pyqt5 python3-pyqt5.q* python3-qtpy python-pyqt5.q* python-lxml fontconfig python-demjson qt5-default libqt5webkit5-dev build-essential libudev-dev python-lxml libxml2-dev libxslt-dev libpq-dev python-pyside python-distlib python-pip python-setuptools" # python-examples python3-examples python-vte
allgoodpcks="ca-certificates virtualenv autotools-dev cdbs git expect libnss3-tools util-linux xvfb curl bridge-utils chromium-browser chromium-chromedriver firefox-esr"
sudo apt-get install --reinstall -y $pypcks $allgoodpcks
if [[ ! -f /usr/lib/chromium-browser/chromedriver ]]; then
sudo ln -s /usr/bin/chromedriver /usr/lib/chromium-browser/chromedriver
fi
@jftuga
jftuga / bufWrite.go
Created Sep 9, 2019
demonstrates how to either write to STDOUT or to a buffer in golang
View bufWrite.go
// demonstrates how to either write to STDOUT or to a buffer
package main
import (
"bufio"
"fmt"
"os"
)