Skip to content

Instantly share code, notes, and snippets.

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

Corey Goldberg cgoldberg

☠️
¯\_(ツ)_/¯
View GitHub Profile
@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 / 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 \
@cgoldberg
cgoldberg / file-rename-strip-digits.sh
Created October 8, 2018 21:54
shell one-liner - rename files in current directory with digits stripped from filenames
# 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
@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 / 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 / update_webdrivers.sh
Created July 16, 2018 18:52
Install geckodriver/chromedriver for Linux (64 bit)
#!/usr/bin/env bash
#
# Install WebDrivers for Linux
# ----------------------------
# * Binary webdrivers are required to drive Firefox and Chrome browsers from Selenium.
# * This script will fetch the 64-bit binaries (geckodriver/chromedriver) for Linux.
set -e
@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 / check_root.bash
Last active November 25, 2018 07:56
got root?
# add this to the beginning of a bash script to ensure it can only be run with root access.
if [[ $EUID -ne 0 ]]; then
echo "permission denied."
echo "$(basename $0) must be run as root."
exit 1
fi
@cgoldberg
cgoldberg / keybase.md
Created December 8, 2017 20:11
Keybase proof

Keybase proof

I hereby claim:

  • I am cgoldberg on github.
  • I am cgoldberg (https://keybase.io/cgoldberg) on keybase.
  • I have a public key ASDk5SpG1Ab5cbPjZP2kcdVjLxyEN2_QbT-RMz1E_r5tuAo

To claim this, I am signing this object:

@cgoldberg
cgoldberg / sniff.txt
Created October 24, 2017 20:09 — forked from manifestinteractive/sniff.txt
A friendly formatter for curl requests to help with debugging.
\n
============= HOST: ==========\n
\n
local_ip: %{local_ip}\n
local_port: %{local_port}\n
remote_ip: %{remote_ip}\n
remote_port: %{remote_port}\n
\n
======= CONNECTION: ==========\n
\n