Skip to content

Instantly share code, notes, and snippets.

View beporter's full-sized avatar

Brian Porter beporter

View GitHub Profile
@beporter
beporter / github_header_colors.user.js
Last active October 17, 2023 18:23
A Greasemonkey/Tampermonkey script that allows you to customize the header color of each GitHub repository you frequent. If you already have Tampermonkey installed, click the "Raw" button to install this user script.
// ==UserScript==
// @name GitHub Repo Header Colors
// @namespace https://gist.github.com/beporter/704eea76b3943c50f7a61e287f60eca8
// @version 1.1.5
// @description Change the header background color of selected GitHub repositories.
// @author https://github.com/beporter
// @match http*://github.com/*
// @grant GM_getValue
// @grant GM_setValue
// @grant GM_addStyle
@beporter
beporter / add_to_cart.user.js
Last active August 18, 2023 21:43
Greasemonkey script to repeatedly refresh a given page, look for specific "Add to Cart" buttons, click them if present, and make a lot of noise on success.
// ==UserScript==
// @name Add Saved Items to Cart
// @namespace https://gist.github.com/beporter/ce76204bcba35d9edb66b395bb5e9305
// @version 0.5
// @description Repeatedly refresh a given "saved items" page (Amazon, Walmart, BestBuy), look for specific "Add to Cart" buttons, click them if present, and make a lot of noise on success.
// @author https://github.com/beporter
// @match https://www.amazon.com/gp/registry/wishlist/*
// @match https://www.amazon.com/hz/wishlist/ls/*
// @match https://www.bestbuy.com/cart
// @match https://www.bestbuy.com/site/customer/lists/manage/saveditems
@beporter
beporter / thumbs.php
Last active April 19, 2022 09:23
A quick PHP script to generate a folder of thumbnails from a source folder of JPG image files. PHP must be able to write files to the local directory.
<?php
// Make sure we see processing errors during development/testing.
error_reporting(E_ALL);
ini_set('display_errors', true);
// Set up operating parameters.
$filePattern = 'gallery/*.[jJ][pP][gG]';
$thumbPattern = 'thumbs/%s';
$targetWidth = 200;
@beporter
beporter / vmnetshop.sh
Last active March 31, 2020 04:46
Shut down VM network bridges on a Mac
#!/usr/bin/env bash
#
# If you're like me and have to switch between VMware Fusion and
# VirtualBox virtual machines on your Mac frequently, then you've
# probably run into one of the associated errors in this gist
# (https://gist.github.com/beporter/2841de37edbcc48a8755), particularly
# if you're using vagrant. This script shuts down or removes the bridge
# interfaces from BOTH providers so that they can start up cleanly again
# without conflicting with each other and without having to reboot your
# Mac.
@beporter
beporter / composer-create-project-test.sh
Last active January 9, 2020 20:28
Make the process of testing a `composer create-project` command easier by operating against your local working copy.
#!/usr/bin/env bash
# Allows you to test the create-project process using your local
# checked-out copy of the skeleton as the source. You MUST commit the
# changes you want to test to a git branch! You MUST name that branch
# as the first argument and the destination path to set up the fresh
# copy into as the second.
#
# Usage:
# - Place this script in your package's root directory and make it executable.
# - Set the PACKAGE_NAME variable below to match your composer.json's `name`.
@beporter
beporter / .bash_profile
Last active January 9, 2020 19:56
Set iTerm2 tab color based on current working directory name ($PWD).
# The follow snippets will automatically change your iTerm2 tab color when you enter a configured directory.
#
# Installation:
#
# Add the function definitions in this file to your `~/.bash_profile` or `~/.profile`.
#
# Configuring your command prompt to include $(_iterm_tab_color).
# For example:
# PS1="\[$(iterm2_prompt_mark; _iterm_tab_color)\]${PS1}"
#
@beporter
beporter / README.md
Last active August 30, 2019 20:03
Python script to fetch Guild Wars 2 trading post sell orders and send a push notification when they drop below a threshold.

Guild Wars 2 Trading Post alerting script

This script allows you to track the sell price for GW2 items and send an IFTTT notification to your phone when the price drops below your configured threshold. I built this so I can wait till items drop to an acceptable range and be notified to log in and purchase them. The script incorporates rate limiting so as not to overload the GW2 API, as well as a mechanism to avoid repeated alerts if an item stays below your threshold for a length of time.

Details and set up steps outlined below.

Requirements

  • Python 2.7
@beporter
beporter / md5-compare.sh
Last active August 20, 2019 13:34
Compare a known md5 hash against that of a downloaded file.
#!/user/bin/env bash
# $1 = file to digest
# $2 = expected hash
# Exits zero if the hashes match, outputs the difference if they do not and exits non-zero.
diff \
<(md5 ${1?"Provide a valid file path as the first argument."} | cut -f 4 -d ' ' -) \
<(echo ${2?"Provide the expected md5 hash as the second argument."})
@beporter
beporter / gw2_home_instance_cats.user.js
Last active September 4, 2018 15:57
A Greasemonkey/Tampermonkey script that will auto-inject your Guild Wars 2 API key (that must have `progression` permissions) into the "Home instance scavenger hunt" wiki page so you'll always see your progress on page load. Be sure to enter your `apiKey` into the script below.
// ==UserScript==
// @name GW2 Home Instance Cats: API Key Injector
// @namespace https://wiki.guildwars2.com/wiki/Hungry_cat_scavenger_hunt
// @version 0.5
// @description Automatically injects your GW2 API key into the form in the "Hungry cat scavenger hunt" wiki page and submits it.
// @author http://github.com/beporter
// @match https://wiki.guildwars2.com/wiki/Hungry_cat_scavenger_hunt
// @updateURL https://gist.github.com/beporter/561f2e95abd4327750e59467c12bf766/raw/gw2_home_instance_cats.user.js
// @grant none
// @run-at document-end
@beporter
beporter / asins.php
Last active July 7, 2017 19:59
(Crudely) collect Amazon ASINs from URLs
<?php
/**
* Quick script to extract ASINs from Amazon URLs.
*
* @see http://stackoverflow.com/a/12827734/70876
*
* beporter at users dot sourceforge dot net
* 2016-05-18
*/