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 | |
# pull all local git branches in current repo | |
# - stashes uncommitted changes | |
# - switches to default branch and does pull/rebase | |
# - switches to every other local branch and does pull/rebase | |
# - switches back to original branch | |
# - only works if in a git repo (otherwise does nothing) | |
set -e |
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. | |
# Returns a list of module names. | |
# This will work for a package installed in `site-packages` or read from source. | |
# | |
# Requires Python 3.9+ | |
import importlib.util | |
import os |
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 ;; |
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 script downloads the latest stable version of the `selenium-manager` binary | |
# for Linux (x86-64) from `https://github.com/SeleniumHQ/selenium_manager_artifacts/releases` | |
# | |
# When you run this script, it will download the binary to the current working directory. | |
set -e |
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 script downloads the latest stable version of the `selenium-manager` binary | |
# for Linux (x86-64) from `https://github.com/SeleniumHQ/selenium_manager_artifacts/releases` | |
# | |
# Before running this script, you should have the selenium repo cloned locally: | |
# $ git clone --filter=blob:none [email protected]:SeleniumHQ/selenium.git | |
# | |
# Make sure to set the `SELENIUM_HOME` variable below to match the repo's base directory. | |
# |
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
import logging | |
# add one of these logging configurations to your selenium script to enable logging. | |
# 6 logger levels are supported: CRITICAL, ERROR, WARNING, INFO, DEBUG, NOTSET. | |
# (default is WARNING) | |
# enable DEBUG logging to console for all modules globally (selenium, urllib3, etc) | |
logging.basicConfig(level=logging.DEBUG) | |
# enable DEBUG logging to console for selenium module |
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
import socket | |
HOST = '127.0.0.1' | |
PORT = 65432 | |
COMMAND = 'whoami' | |
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s: | |
print('connecting to: {HOST}:{PORT}') | |
s.connect((HOST, PORT)) | |
print(f'sending command: {command}') |
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
## scan music library and create M3U playlists | |
# example shell commands: | |
# 500 random MP3's | |
find /path/to/music -type f -iname "*.mp3" | shuf | head -n 500 > 500_playlist.m3u | |
# All MP3's and FLAC's, sorted | |
find /path/to/music -type f \( -iname '*.mp3' -o -iname '*.flac' \) | sort > full_playlist.m3u |
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 | |
# skip to next track on Squeezebox player via SlimServer/LogitechMediaServer | |
SQUEEZEBOX_SERVER='localhost:9000' # server host:port | |
SQUEEZEBOX_PLAYER='00:05:11:23:82:6e' # player MAC address | |
next () { | |
curl -sS -o /dev/null -X POST \ |
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
# rename files in current directory with digits stripped from filenames | |
# first do a dry-run (only print the commands that will be applied) | |
for f in *; do echo mv "$f" $(printf '%s' "$f" | tr -d '0123456789'); done | |
# run it for real (modifications done in-place) | |
for f in *; do mv "$f" $(printf '%s' "$f" | tr -d '0123456789'); done |
NewerOlder