Skip to content

Instantly share code, notes, and snippets.

Ryan Punt rpunt

View GitHub Profile
@rpunt
rpunt / profiles.json
Created Mar 29, 2020
Microsoft Terminal configuration
View profiles.json
// To view the default settings, hold "alt" while clicking on the "Settings" button.
// For documentation on these settings, see: https://aka.ms/terminal-documentation
{
"$schema": "https://aka.ms/terminal-profiles-schema",
"globals": {
"alwaysShowTabs": true,
"initialCols": 120,
"initialRows": 30,
@rpunt
rpunt / hamilton.sh
Last active Feb 26, 2020
Did Hamilton win the race?
View hamilton.sh
if [ "$(curl -s https://www.formula1.com/en/results.html/$(date +%Y)/races.html | nokogiri -e 'puts $_.at_xpath("//table[@class=\"resultsarchive-table\"]/tbody/tr[last()]/td[4]/span[2]").text' 2>/dev/null)" == "Hamilton" ]; then
echo "YES. I'm guessing Ferrari botched team orders, and Williams probably came last."
else
echo "NO. ANYTHING IS POSSIBLE. REVEL IN THE UNPREDICTABLITY OF LIFE."
fi
@rpunt
rpunt / mktemp.ps1
Created Feb 15, 2020
I've wanted mktemp in powershell forever, so... fine.
View mktemp.ps1
function mktemp {
param (
[Parameter(mandatory=$false)]$Extension
)
$randomfile = [System.IO.Path]::GetRandomFileName()
if ($Extension) {
$randomfile = [System.IO.Path]::ChangeExtension($randomfile, $Extension)
}
return Microsoft.PowerShell.Management\Join-Path ([System.IO.Path]::GetTempPath()) "$randomfile"
}
@rpunt
rpunt / check-windows-cert-expiry.ps1
Created Aug 7, 2019
Return days until cert expiration
View check-windows-cert-expiry.ps1
# exit codes reflect this script's use as a Sensu check
# replace "YOUR ISSUER HERE" with the CA of your choice
param (
[Parameter(Mandatory=$True)][int]$critical = $(throw "-critical - is required."),
[Parameter(Mandatory=$True)][int]$Warning = $(throw "-warning - is required."),
[Parameter(Mandatory=$False)][string]$computer = $env:COMPUTERNAME.Tolower()
)
$cert=$(get-childitem cert:LocalMachine\My -recurse | where-object { $_.Issuer -match "YOUR ISSUER HERE" } | select Subject,@{Name="DaysRemaining";Expression={($_.NotAfter).subtract([DateTime]::Now).days}})
View unifi_jail_file_transfer_from_host.sh
# get jail paths
root@freenas:~ > jls
JID IP Address Hostname Path
3 unifi /mnt/default/iocage/jails/unifi/root
root@freenas: > mv ~/keystore /mnt/default/iocage/jails/unifi/root/usr/local/share/java/unifi/data/
View unifi_dns_record.sh
# Create a DNS record in a Unifi USG
# ssh to USG
configure
# create an A record
set system static-host-mapping host-name HOSTNAME inet IPADDRESS
# create a CNAME
set system static-host-mapping host-name HOSTNAME alias CNAME
@rpunt
rpunt / ntpconfig.ps1
Created Jan 21, 2019
Configure NTP on windows server
View ntpconfig.ps1
# from an elevated prompt
Stop-service w32time
w32tm /config /syncfromflags:manual /manualpeerlist:"server1.domain.tld,server2.domain.tld"
w32tm /config /reliable:yes
start-service w32time
# get sync status
W32tm /query /status
View gitconfig
[alias]
lg = log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit
since = !git log $(git merge-base --fork-point master)..HEAD
files-changed="!f() { git log --name-only $1..HEAD --oneline --format=%n ${2:-.} | grep -v '^$' | sort | uniq; }; f"
@rpunt
rpunt / unifi_keystore_gen.sh
Last active Feb 16, 2019
Generate a keystore for Unifi controllers
View unifi_keystore_gen.sh
#!/bin/bash
# Assumptions:
# ./unifi.pem is the signed cert you wish to use
# ./unifi.key is the private key
# ./chain.pem is the CA chain for your issuer, ordered intermediates to root (descending)
# /var/lib/unifi/keystore is the appropriate path for your Keystore; may vary by distro (tested on Debian 8)
openssl pkcs12 -export \
-in unifi.pem \
View keybase.md

Keybase proof

I hereby claim:

  • I am rpunt on github.
  • I am rpunt (https://keybase.io/rpunt) on keybase.
  • I have a public key whose fingerprint is BF55 A76A E67F F3A1 2E09 E08F ED47 262D 3FF6 076A

To claim this, I am signing this object:

You can’t perform that action at this time.