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 / dialpad.pl
Created Apr 10, 2020
Translate letters to dialpad numbers and numbers to possible words
View dialpad.pl
#!/usr/bin/perl
# TODO: at the moment, words are only broken up by 0 and 1. Should search for smaller sequential words. For example:
# 6908378 finds: mytest
# but 1698378 does not
use strict;
use warnings;
# Default Debian ispell dictionary
@JohnMertz
JohnMertz / traffic.pl
Created Apr 10, 2020
Ottawa traffic news and alerts
View traffic.pl
#!/usr/bin/perl
use warnings;
use strict;
use Data::Dump qw | dump |;
use LWP::UserAgent;
use JSON::XS;
my $ua = LWP::UserAgent->new();
@JohnMertz
JohnMertz / battery.pl
Created Apr 10, 2020
Battery status script
View battery.pl
#!/usr/bin/perl
# Not proud of this one. It had multi-battery supported shunted on when I got a new laptop and Waybay output taped on too. Could use to be cleanud up a lot, but it does the job.
my $output;
my $bar = 0;
if ($ARGV[0] eq '-h' || $ARGV[0] eq '--help') {
print'
pow.pl - Power Status Script
@JohnMertz
JohnMertz / net.pl
Created Apr 10, 2020
Script to get network interfaces as nested hashes
View net.pl
#!/usr/bin/perl
use strict;
use warnings;
my $addr = `ip addr`;
my %links;
my $current;
foreach (split '\n', $addr) {
@JohnMertz
JohnMertz / blc.pl
Created Apr 10, 2020
Intel backlight control script
View blc.pl
#!/usr/bin/perl -w
# Files containing current and max brightness values
my $cur_file = "/sys/class/backlight/intel_backlight/brightness";
my $max_file = "/sys/class/backlight/intel_backlight/max_brightness";
# About (See help() for more):
# Script to read and write to the backlight brightness file. Allows for easy control of the backlight without a proper backlight daemon (eg. when logged in to a console).
# Requires ownership/permissions for the brightness file. This can be automatically acquired with the following SystemD Unit:
@JohnMertz
JohnMertz / miband.pl
Created Apr 10, 2020
Script for aggregating MiBand step count from GadgetBridge export
View miband.pl
#!/usr/bin/perl
use warnings;
use strict;
use Time::Local;
use JSON::XS;
use DBI;
my $file = "/path/to/export_file";
@JohnMertz
JohnMertz / gist:39306b25eada1e658338ef5f434ee629
Created Apr 10, 2020
Simple weekly streak counter script
View gist:39306b25eada1e658338ef5f434ee629
#!/usr/bin/perl
# Manually trigger with `$0 -a` to log an exercise event for the day.
# Automatically run each morning with `$0 -c` to cycle out old data
# Simply outputs Bool for event today, count for the last 7 days and the goal
# Meant for a simple indicator widget so I know if a streak is at risk
use JSON::XS;
use Date::Calc;
@JohnMertz
JohnMertz / opl.pl
Created Apr 10, 2020
Script to fetch Holds, Checkouts and Fines for an account with the Ottawa Public Library.
View opl.pl
#!/usr/bin/perl
use strict;
use warnings;
use WWW::Mechanize;
use JSON::XS;
use HTML::TreeBuilder;
my $pretty = 0;
@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";
You can’t perform that action at this time.