Skip to content

Instantly share code, notes, and snippets.

View JohnMertz's full-sized avatar

John Mertz JohnMertz

View GitHub Profile
@JohnMertz
JohnMertz / amihome.pl
Created May 28, 2020 19:19
Is a device currently up on LAN (determine if my phone is at home).
#!/usr/bin/perl
use strict;
use warnings;
use Net::Ping;
my $file = "/tmp/amihome";
my $host = "192.168.2.127";
@JohnMertz
JohnMertz / traffic.pl
Created April 10, 2020 11:44
Ottawa traffic news and alerts
#!/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 April 10, 2020 11:38
Battery status script
#!/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 / miband.pl
Created April 10, 2020 11:15
Script for aggregating MiBand step count from GadgetBridge export
#!/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 April 10, 2020 11:10
Simple weekly streak counter script
#!/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 April 10, 2020 11:02
Script to fetch Holds, Checkouts and Fines for an account with the Ottawa Public Library.
#!/usr/bin/perl
use strict;
use warnings;
use WWW::Mechanize;
use JSON::XS;
use HTML::TreeBuilder;
my $pretty = 0;
@JohnMertz
JohnMertz / cardspace.c
Last active April 10, 2020 10:51
Calculate how to display a hand of cards for 80 column console
#include <stdio.h>
void main() {
int x,y,z,spaceleft,spaceright,width;
printf("|");
for (x=0;x<80;x++) {
printf(" ");
}
printf("|left card right\n");
for (x=1;x<=13;x++) {
width = 67 / x;
@JohnMertz
JohnMertz / wordfind.pl
Created December 29, 2019 01:04
Wordscape - Anagram word search assistant
#!/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 / clone-lxc.pl
Created July 20, 2019 07:33
Extract and Configure LXC from Archived Backup
#!/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 / mocp-start-cec.pl
Last active June 18, 2019 22:07
Start Music On Console Player and Force Active Input via HDMI-CEC
#!/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';