Skip to content

Instantly share code, notes, and snippets.

View cgoldberg's full-sized avatar
☠️
¯\_(ツ)_/¯

Corey Goldberg cgoldberg

☠️
¯\_(ツ)_/¯
View GitHub Profile
@cgoldberg
cgoldberg / webdriver-packed-extension.py
Last active July 8, 2021 17:48
Python - Selenium WebDriver - Installing a packed Chrome Extension
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
packed_extension_path = '/path/to/packed/extension.crx'
options = Options()
options.add_extension(packed_extension_path)
driver = webdriver.Chrome(options=options)
@cgoldberg
cgoldberg / img_exif_date_fixer.py
Last active June 7, 2021 07:10
Python - Fix Photo Exif Metadata
#!/usr/bin/env python
#
# gexiv2 image Exif date fixer.
# Corey Goldberg, 2014
"""Recursively scan a directory tree, fixing dates
on all jpg/png image files.
Each file's Exif metadata and atime/mtime are all
@cgoldberg
cgoldberg / webdriver-unpacked-extension.py
Last active November 3, 2020 15:23
Python - Selenium WebDriver - Installing an unpacked Chrome Extension
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
unpacked_extension_path = '/path/to/unpacked/extension/'
options = Options()
options.add_argument('--load-extension={}'.format(unpacked_extension_path))
driver = webdriver.Chrome(options=options)
@cgoldberg
cgoldberg / lookup_pypi_packages.py
Last active September 15, 2020 21:53
lookup PyPI packages by author or maintainer
#!/usr/bin/env python
# Corey Goldberg, 2013
import argparse
import pkgtools.pypi
"""
Command line script to lookup packages on Python Package Index (PyPI).
@cgoldberg
cgoldberg / download-selenium-server.sh
Last active March 7, 2020 15:14
Download latest Selenium Standalone Server (shell script)
#!/usr/bin/env bash
# Corey Goldberg 2018
#
# download latest release of Selenium Standalone Server
#
# requires:
# * `curl`
# * `xpath` utility from the `XML::XPath` Perl module. On Debian,
# this is provided by the `libxml-xpath-perl` package.
@cgoldberg
cgoldberg / img_metadata_strip_fix.py
Last active July 18, 2019 09:03
Python - image metadata remover and date fixer.
#!/usr/bin/env python
#
# image metadata remover and date fixer.
# Corey Goldberg, 2014
"""Recursively scan a directory tree for image files, and fix metadata.
* removes all metadata (Exif, IPTC, XMP, GPS Info, comment, thumbnail)
* sets metadata and file timestamps to oldest datetime found.
@cgoldberg
cgoldberg / playlists.sh
Last active May 27, 2019 12:39
scan music library and create M3U playlists
## 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
@cgoldberg
cgoldberg / install-webdrivers.sh
Last active May 11, 2019 12:00
Selenium - download and install WebDriver binaries for Firefox (geckodriver) and Chrome (chromedriver)
#!/usr/bin/env bash
#
# Installer for WebDrivers
# ------------------------
# - Binary webdrivers are required to drive Firefox and Chrome browsers from Selenium.
# - This script will fetch the 64-bit binaries (geckodriver/chromedriver) for MacOS or Linux.
set -e
@cgoldberg
cgoldberg / helloworld_pyqt5.py
Last active January 27, 2019 20:43
Hello World, in Python3 and Qt5
#!/usr/bin/env python3
"""
helloworld.py
Python3 and Qt5
"""
from PyQt5 import QtWidgets
@cgoldberg
cgoldberg / next.sh
Last active December 20, 2018 17:17
bash - skip to next track on Squeezebox player via SlimServer/LogitechMediaServer
#!/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 \