Skip to content

Instantly share code, notes, and snippets.

View Tugzrida's full-sized avatar

Cameron Steel Tugzrida

View GitHub Profile

Keybase proof

I hereby claim:

  • I am tugzrida on github.
  • I am tugzrida (https://keybase.io/tugzrida) on keybase.
  • I have a public key whose fingerprint is 4D61 B752 B355 94DC CB7E 61C3 CE91 5A0B C269 4D91

To claim this, I am signing this object:

@Tugzrida
Tugzrida / dns_cacher
Created January 13, 2019 00:11
Crude DNS cacher to reduce number of upstream lookups
#!/bin/bash
# Requires install of dnsutils package. Can be added to a crontab with root permissions
# for however often you want to refresh the cached IP.
host="pfclient-upload.planefinder.net"
ipaddr=$(dig +short "$host" | awk '{ print ; exit }')
grep -v "$host" /etc/hosts | tee /etc/hosts
echo "$ipaddr $host" | tee -a /etc/hosts
@Tugzrida
Tugzrida / fritzsid.py
Last active September 21, 2019 06:48
Python routine to get a session ID from a FRITZ!Box
#!/usr/bin/env python
# Simple python2/3 routine to get a SID from a FRITZ!Box as it took me forever to figure this out
# If you don't have https set up, set the urls to http and remove the two verify options
# If you do have https set up, point the two verify options to the CA cert
# (unless your FB cert is publicly signed, then remove the verify options)
from requests import get
@Tugzrida
Tugzrida / microview_boards.txt
Created September 22, 2019 10:53
boards.txt definition for SparkFun Microview in new Arduino IDE
uview.upload.tool=avrdude
uview.bootloader.tool=avrdude
uview.name=MicroView
uview.upload.protocol=arduino
uview.upload.maximum_size=32256
uview.upload.speed=115200
uview.bootloader.low_fuses=0xff
uview.bootloader.high_fuses=0xde
uview.bootloader.extended_fuses=0x05
uview.bootloader.file=optiboot/optiboot_atmega328.hex
@Tugzrida
Tugzrida / certspotter_acknowledge
Created November 18, 2019 01:39
Automatically acknowledge Certbot renewals on Cert Spotter
#!/usr/bin/env python
# v0.1 Created by Tugzrida(https://gist.github.com/Tugzrida)
# Dependencies: python, requests
# Add your Cert Spotter API key below, then save this script to
# /etc/letsencrypt/renewal-hooks/deploy/certspotter_acknowledge with execute permissions.
# Any certificates renewed by this instance of Certbot will then be automatically
# marked as acknowledged on Cert Spotter to reduce notifications for legitimate
@Tugzrida
Tugzrida / MicroPython_RTC_DST.py
Created November 23, 2019 00:15
Implementation of NTP and Australian DST in MicroPython
import time, socket
from struct import unpack
from machine import RTC
standardTimeOffset = 60 * 60 * 10 # The base TZ UTC offset in sec, AEST(UTC+10)
summerTimeDifference = 60 * 60 * 1 # The difference between the base TZ and DST TZ in sec, AEDT(UTC+11), 1 hour ahead
rtc = RTC()
lastSync = 0
@Tugzrida
Tugzrida / lametric_icon.php
Created February 19, 2020 09:12
LaMetric Time icon overlayer in PHP
<?php
// This file defines the function lametricFormatNumber which accepts a filepath to an 8x8px PNG and string.
// The general idea is that an 8-digit number can be displayed on the LaMetric without scrolling by overlaying
// the left-most digit over the icon. By providing your desired icon PNG file(GIFs for animated icons not yet
// supported) and number to lametricFormatNumber, you will recieve as output your icon and number, with the first
// digit overlaid on the icon if the number has 8 or more digits. The alphabet A-Z is also included, however does not
// work as well, as the letters I, M, N, Q and W deviate from the 3-pixel width of all the other characters and digits.
// Theoretically, a 9-digit number could also be displayed as there is enough room on top of the icon, however then there
// won't be much room left for the actual icon, so it's not really worth it. At the end of this file is an example json
// output in LaMetric time format using the function.
@Tugzrida
Tugzrida / uCollapse.css
Last active April 20, 2020 11:41
A tiny independent JS library for easily making collapsible sections.
/* uCollapse v0.2 Created by Tugzrida(https://gist.github.com/Tugzrida) */
.ucollapsible {
overflow: hidden;
transition: height 0.3s ease-in-out;
}
.ucollapsible.ucollapsed {
height: 0px;
}
@Tugzrida
Tugzrida / hashchecker
Last active December 11, 2020 06:44
Simple bash hash verification utility
#!/bin/bash
# hashchecker Created by Tugzrida(https://gist.github.com/Tugzrida)
# A simple utility that accepts a file path and expected md5, sha1 or
# sha256 hash, then verifies the file matches the expected hash.
# Hash length assumptions:
# md5 - 32 chars
# sha1 - 40 chars
# sha256 - 64 chars
@Tugzrida
Tugzrida / mta-sts
Last active December 11, 2020 06:54
MTA-STS vhost for Nginx
# A simple Nginx vhost to direct all requests to mta-sts.example.com to the mta-sts file.
# Just substitute your domain and certificate paths(MTA-STS *must* be available over HTTPS)
# Then do mkdir -p /var/www/mta-sts/.well-known and add your policy to
# /var/www/mta-sts/.well-known/mta-sts.txt
server {
listen 80;
listen [::]:80;
server_name mta-sts.example.com;