Skip to content

Instantly share code, notes, and snippets.

View beporter's full-sized avatar

Brian Porter beporter

View GitHub Profile
@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 / .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 / 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 / steps.php
Created May 10, 2017 14:29
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.
#!/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 April 15, 2024 15:41
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.6
// @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 / 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
*/
@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 / belongstomany-patch.sh
Created November 2, 2015 15:57
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.
#!/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 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;