Skip to content

Instantly share code, notes, and snippets.

View JohnMertz's full-sized avatar

John Mertz JohnMertz

View GitHub Profile
@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 / suit.c
Created October 9, 2015 18:37
How many cards do you have to deal before an entire suit has been dealt?
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
void main(){
long long int total = 0;
long long int i = 0;
for (i = 0; i<1000000; i++){
@JohnMertz
JohnMertz / lxc-debian-wheezy
Last active October 4, 2018 20:05 — forked from tpokorra/lxc-debian-wheezy
lxc template for Debian Wheezy to install on Debian Stretch
#!/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 / OCTranspo.pl
Created February 15, 2019 03:30
OCTranspo Alert Scraper
#!/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 / 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';
@JohnMertz
JohnMertz / Duolingo.pl
Created June 18, 2019 21:59
Duolingo API Script
#!/usr/bin/perl
use strict;
use warnings;
use WWW::Mechanize;
use JSON::Any;
use HTTP::CookieJar::LWP;
my $user = 'username';
@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 / rem2json.pl
Last active July 8, 2022 01:07
Convert `remind -p` output to JSON
#!/usr/bin/perl
use strict;
use warnings;
use constant MONTH => sub{{
'January' => 1,
'February' => 2,
'March' => 3,
'April' => 4,
@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 / tangerine.pl
Last active June 17, 2024 17:35
Tangerine Investment Fund Scraper/Export Tool
#!/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: