Skip to content

Instantly share code, notes, and snippets.

Avatar

Brian Porter beporter

View GitHub Profile
@beporter
beporter / add_to_cart.user.js
Last active May 16, 2021
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.
View add_to_cart.user.js
// ==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 / .bash_profile
Last active Jan 9, 2020
Set iTerm2 tab color based on current working directory name ($PWD).
View .bash_profile
# 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 Aug 30, 2019
Python script to fetch Guild Wars 2 trading post sell orders and send a push notification when they drop below a threshold.
View README.md

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 / gw2_home_instance_cats.user.js
Last active Sep 4, 2018
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.
View gw2_home_instance_cats.user.js
// ==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 / steps.php
Created May 10, 2017
PHP command line script that consumes a CSV dump from the [Pedometer++ iOS app](http://pedometerplusplus.com/) and reports total and average number of steps over the date range contained in the file.
View steps.php
#!/usr/bin/env php
<?php
/**
* Consumes a CSV file as exported by the
* [Pedometer++ iOS app](http://pedometerplusplus.com/) and reports your total
* steps and average steps per day for the range of dates contained in the file.
*
* beporter@users.sourceforge.net
* v1.0.0
* 2017-05-10
@beporter
beporter / github_header_colors.user.js
Last active Apr 11, 2021
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.
View github_header_colors.user.js
// ==UserScript==
// @name GitHub Repo Header Colors
// @namespace https://gist.github.com/beporter/704eea76b3943c50f7a61e287f60eca8
// @version 1.1.3
// @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
// @run-at document-body
@beporter
beporter / asins.php
Last active Jul 7, 2017
(Crudely) collect Amazon ASINs from URLs
View asins.php
<?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
*/
@beporter
beporter / md5-compare.sh
Last active Aug 20, 2019
Compare a known md5 hash against that of a downloaded file.
View md5-compare.sh
#!/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 / belongstomany-patch.sh
Created Nov 2, 2015
A quick diff and script to resolve cakephp/cakephp#7626 until that PR can be merged. Save these files in your project root dir, make the .sh executable, and run it. Assumes CakePHP v3.1.3 is in use.
View belongstomany-patch.sh
#!/usr/bin/env bash
#---------------------------------------------------------------------
usage ()
{
cat <<EOT
${0##*/}
Apply the belongstomany.patch file to your cakephp source in vendor/
@beporter
beporter / thumbs.php
Last active Sep 29, 2015
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.
View thumbs.php
<?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;