Skip to content

Instantly share code, notes, and snippets.

John Mertz JohnMertz

Block or report user

Report or block JohnMertz

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@JohnMertz
JohnMertz / tangerine.pl
Last active Mar 25, 2020
Tangerine Investment Fund Scraper/Export Tool
View tangerine.pl
#!/usr/bin/perl
# This script fetches the performance data for various Tangerine Bank investment funds and exports them to:
# - CSVs called <fund_name>.csv with all historical data in format: "YYYY-MM-DD","12.34"
# - (optional) A single JSON file with trend data: {"Fund Name":{"0":12.34,"1":"12.56"...},"Fund Name":...}
# - (optional) PNG line chart
# All data is publicly available from: https://www.tangerine.ca/en/products/investing/performance
# This is just a handy way to use the data locally for various purposes.
#
# Should be run daily Tuesday-Saturday, such as with cron:
@JohnMertz
JohnMertz / wordfind.pl
Created Dec 29, 2019
Wordscape - Anagram word search assistant
View wordfind.pl
#!/usr/bin/perl
# Program to find all words from a given pool of letters. Written to solve the
# Android puzzle game "Wordscape".
use strict;
use warnings;
# Default Debian ispell dictionary
my $dict = "/etc/dictionaries-common/words";
@JohnMertz
JohnMertz / rem2json.pl
Last active Dec 30, 2019
Convert `remind -p` output to JSON
View rem2json.pl
#!/usr/bin/perl
use strict;
use warnings;
use constant MONTH => sub{{
'January' => 1,
'February' => 2,
'March' => 3,
'April' => 4,
@JohnMertz
JohnMertz / clone-lxc.pl
Created Jul 20, 2019
Extract and Configure LXC from Archived Backup
View clone-lxc.pl
#!/usr/bin/perl
# Note for GitHub:
# This script makes several assumptions based on the backup image I use.
# Mine is a freshly installed Debian image preconfigured just how I want it.
# The script relies on the name 'fresh-lxc' and IP '10.0.3.1' being set.
# It is also written with Debian Buster as the host, some paths may differ.
# Make changes appropriately.
use strict;
@JohnMertz
JohnMertz / Duolingo.pl
Created Jun 18, 2019
Duolingo API Script
View Duolingo.pl
#!/usr/bin/perl
use strict;
use warnings;
use WWW::Mechanize;
use JSON::Any;
use HTTP::CookieJar::LWP;
my $user = 'username';
@JohnMertz
JohnMertz / mocp-start-cec.pl
Last active Jun 18, 2019
Start Music On Console Player and Force Active Input via HDMI-CEC
View mocp-start-cec.pl
#!/usr/bin/perl
use strict;
use warnings;
use JSON::XS;
# Checking for devices every time takes a few seconds, so store these
# settings in a file. Do so in /tmp so that it will be re-checked on reboot
my $tmp = '/tmp/cec-devices';
@JohnMertz
JohnMertz / OCTranspo.pl
Created Feb 15, 2019
OCTranspo Alert Scraper
View OCTranspo.pl
#!/usr/bin/perl
use strict;
use warnings;
use WWW::Mechanize;
use Data::Dump qw/ dump /;
use JSON::Any;
# Define the routes that I actually care about
@JohnMertz
JohnMertz / lxc-debian-wheezy
Last active Oct 4, 2018 — forked from tpokorra/lxc-debian-wheezy
lxc template for Debian Wheezy to install on Debian Stretch
View lxc-debian-wheezy
#!/bin/bash
#
# lxc: linux Container library
# Authors:
# Daniel Lezcano <daniel.lezcano@free.fr>
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
@JohnMertz
JohnMertz / darksky_to_php.sh
Last active Nov 30, 2017
Darksky.net API to PHP Associative Array
View darksky_to_php.sh
#/bin/bash
# Note: This is not secure! If you somehow get malicious code back from Darksky.net, this can run arbitrary code. Use wisely and sanitize your inputs! https://www.xkcd.com/327/
output="yourOutputPathHere.php"
# Replace with your API key and coordinates. Should be fine with other units and may work without excluding minutel and flags.
# I have only teste this format (hourly and daily with SI units). This works for Ottawa, Canada.
# Pipes force into separate lines with quoted fields in PHP associative array format: "attribute_name1"=>"value","attribute_name2"=>...
# Outputs to a .tmp of your defined file name.
curl --compress 'https://api.darksky.net/forecast/<api_key_here>/45.421,-75.69?units=si&exclude=minutely,flags' | tr '{' '\n' | sed 's/},$//' | sed 's/,\ /\ /' | sed -r 's/([^"]),"/\1","/g' | sed -r 's/":([^"])/":"\1/g' | sed -r 's/([^"])\}/\1"\n/' | grep '^"time"' | sed 's/":"/"=>"/g' > $output.tmp
@JohnMertz
JohnMertz / price.sh
Created Aug 12, 2017
Bash Price-Checker Robot
View price.sh
#!/bin/bash
# Price-Checker Robot
# All dependencies should be pre-installed (at least on Debian): bash, curl, echo, grep, sed, tail, date, bsd-mailx, bc, cut
# Alerts user if the price has dropped for defined items.
# Reduced items result in alerts to the defined recipient.
# Errors are sent to the maintainer
# All are logged to $HOME/.price.log
You can’t perform that action at this time.