This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# | |
# monkeypatch a method on a class and call the original method from the new one | |
from functools import partialmethod | |
class MyClass: | |
# this is the original method |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# | |
# Selenium WebDriver function to wait for an element and click it | |
import time | |
from selenium import webdriver | |
from selenium.common.exceptions import ( | |
ElementClickInterceptedException, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# | |
# Functions for generating Unicode data | |
import random | |
import unicodedata | |
def get_all_chars(): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env -S pipx run | |
# /// script | |
# requires-python = ">=3.13" | |
# dependencies = [ | |
# "selenium==4.34.2", | |
# ] | |
# /// | |
# This script has dependencies defined using inline script metadata (PEP 723) | |
# Running it will create a temporary virtual environment, install depenendencies, then run the code (requires pipx) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# this is a total hack for `getopts` so it handles a single short or long option | |
# - valid options are: -a, -h, --all, --help | |
# - no args for options are allowed | |
die () { | |
tput setaf 1; echo -en "\u2717 "; tput sgr0 | |
tput bold; echo "$*" 1>&2; tput sgr0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Problem: | |
# When you call the black formatter, it prints all output to standand | |
# error (even when no formatting is required). However, tox colors all | |
# output to standard error in bold red. This results in black's | |
# "All done! ... files left unchanged" message being colored red in | |
# console output (which is very annoying). | |
# | |
# Workaround: | |
# This is a `tox.ini` configuration file that invokes black through a | |
# Python subprocess and redirects output to standard output when |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# example fixture for taking screenshots on test failures | |
# | |
# requires: | |
# - pytest | |
# - selenium | |
import time | |
import pytest | |
from selenium import webdriver |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
REM - launch Git-Bash with symlinks enabled | |
REM - (they are disabled for non-Admin accounts by default) | |
set MSYS=winsymlinks:native | |
%USERPROFILE%\Scoop\apps\git\current\git-bash.exe |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# | |
# Find all modules in a package without importing the package. | |
# This will work for a package installed in `site-packages` or read from source. | |
# | |
# Requires Python 3.9+ | |
import importlib.util | |
import os | |
import site |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extract () { | |
if [ -f $1 ] ; then | |
case $1 in | |
*.tar.bz2) tar xjf $1 ;; | |
*.tar.gz) tar xzf $1 ;; | |
*.bz2) bunzip2 $1 ;; | |
*.rar) rar x $1 ;; | |
*.gz) gunzip $1 ;; | |
*.tar) tar xf $1 ;; | |
*.tbz2) tar xjf $1 ;; |
NewerOlder