Skip to content

Instantly share code, notes, and snippets.

@gboone
gboone / display.py
Last active February 3, 2023 16:35
Script to display some basic info from a pihole on an adafruit 1.14" tft display. Buttons control pihole and display a qr code for the wifi network
#! /usr/bin/python3
# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
# SPDX-License-Identifier: MIT
# -*- coding: utf-8 -*-
# to test, edit /etc/rc.local then reboot
import time
import subprocess
import digitalio
@gboone
gboone / chkcrt.sh
Last active June 3, 2020 17:59
crtchk.sh
#! /bin/zsh
# Very much low-fi, low-tech shortcut to check a domain name passed via stdin and return details about the certificate.
# If `ca` is passed, the "CA Issuers" string is grepped from the output.
domain=${1%/}
echo $domain
if [[ $2 == "ca" ]]; then
echo | openssl s_client -showcerts -servername $domain -connect $domain:443 2>/dev/null | openssl x509 -inform pem -noout -text | grep "CA Issuers";
else
echo | openssl s_client -showcerts -servername $domain -connect $domain:443 2>/dev/null | openssl x509 -inform pem -noout -text;
fi
@gboone
gboone / intermediates.sh
Last active June 25, 2018 19:07
How to find intermediate images in a list of files
^.*(\d*x\d*).(jpg|jpeg|png)
@gboone
gboone / wp_metadata_filter.rb
Created September 2, 2017 17:30
A jekyll filter to sort out and return only the wp:post_meta keys and values
module Jekyll
module WPmetadata
def wpmeta(input)
standard_post = [
"output",
"content",
"relative_path",
"path",
"url",
"collection",
@gboone
gboone / feed-wordpress.xml
Last active February 21, 2019 16:34
A simple jekyll template to generate WordPress eXtended RSS (WRX) feeds suitable for importing into a WordPress site
---
---
<?xml version="1.0" encoding="UTF-8" ?>
<!-- This is a WordPress eXtended RSS file generated by WordPress as an export of your site. -->
<!-- It contains information about your site's posts, pages, comments, categories, and other content. -->
<!-- You may use this file to transfer that content from one site to another. -->
<!-- This file is not intended to serve as a complete backup of your site. -->
<!-- To import this information into a WordPress site follow these steps: -->
<!-- 1. Log in to that site as an administrator. -->
@gboone
gboone / commit-msg
Last active May 11, 2017 22:57
Copy Federalist preview URL on commit
#!/bin/sh
#
# A commit-msg hook to copy the federalist preview url to your clipboard after you commit.
# Note: The URL will not work until the preview site has actually generated, that doesn't happen until you `push`
#
NAME=$(git branch | grep '*' | sed 's/* //')
echo "Your federalist preview will be at https://federalist.18f.gov/preview/18F/18f.gsa.gov/$NAME/"
echo "https://federalist.fr.cloud.gov/preview/18F/18f.gsa.gov/$NAME/" | pbcopy
echo "This url has been copied to your clipboard."
@gboone
gboone / ooo.md
Last active January 11, 2017 17:41
Thanksgiving OOO

Hey there, I'm out of office for the Thanksgiving holiday. While you wait for me to get back to you, check out these ten awesome initiatives from my colleagues across the federal government:

  1. The General Services Administration's Fine Arts program has a trove of public art. Search the database and find some art near you!
  2. Speaking of art, the Bureau of Reclamation commissioned dozens of works of art in the 1960s. Check out the works they commissioned on their website.
  3. The National Ice Core Lab in Lakewood, CO contains samples of ice from deep in the earth's surface. It's pretty much the closest thing we have to time travel.
  4. Help your relatives stay safe if their identity is stolen on the Federal Trade Commission's [IdentityTheft.gov](https://identitytheft.gov
# Strips the body out of a document. Quick and dirty, assumes ARGV is a real directory with markdown or YAML files in it.
# I hard coded the directory and am not really a rubyist so there's a chance I screwed up this ARGV thing.
#!/usr/bin/env ruby
require 'yaml'
files = Dir.glob("#{ARGV[0]}/*")
for file in files
yaml = YAML.load(File.read(file))
File.open(file, 'w') { |f|
f.write(yaml.to_yaml + "---")
}
@gboone
gboone / til.rb
Created January 20, 2016 23:07
Today I Learned about ruby logic
# this:
if expected['value']
variable = expected['value']
else
variable = "default"
end
# is the same as this:
unless variable = expected['value']
variable = "default"
@gboone
gboone / midpoint
Created November 28, 2015 23:47
How to find a geographic midpoint in js
function setLatLng(dataset) {
var lat = dataset.lat
var lng = dataset.lng
return new L.LatLng(lat, lng)
}
function latLngRadians(dataset) {
return _.map(dataset, function(item) {
var latRad = item.lat*(Math.PI/180)
var lngRad = item.lng*(Math.PI/180)