Instantly share code, notes, and snippets.

View file-rename-strip-digits.sh
# 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
View webdriver-unpacked-extension.py
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)
View webdriver-packed-extension.py
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)
View update_webdrivers.sh
#!/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
View download-selenium-server.sh
#!/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.
View check_root.bash
# 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
View keybase.md

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:

View sniff.txt
\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
View install-webdrivers.sh
#!/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
View geckodriver-install.sh
#!/bin/bash
# download and install latest geckodriver for linux or mac.
# required for selenium to drive a firefox browser.
install_dir="/usr/local/bin"
json=$(curl -s https://api.github.com/repos/mozilla/geckodriver/releases/latest)
if [[ $(uname) == "Darwin" ]]; then
url=$(echo "$json" | jq -r '.assets[].browser_download_url | select(contains("macos"))')
elif [[ $(uname) == "Linux" ]]; then
url=$(echo "$json" | jq -r '.assets[].browser_download_url | select(contains("linux64"))')