Skip to content

Instantly share code, notes, and snippets.

View jhunt's full-sized avatar
🎧
codin'

James Hunt jhunt

🎧
codin'
View GitHub Profile
@jhunt
jhunt / flags.cl
Created December 14, 2021 21:02
Using Lisp Macros to Fact-Check Code at Compile Time
;;
;; This code was extracted from a larger project
;; and used in a Twitter thread on using macros
;; to fact-check programmers at compile-time.
;;
;; https://twitter.com/iamjameshunt/status/1470845641027129345
;;
(defun -flags-for (num)
(format nil "~{~A~}"
@jhunt
jhunt / json-encode.cl
Created September 8, 2021 13:49
JSON encoding in Lisp!
(defun alist? (lst)
(cond ((null lst) t)
((listp lst) (and (consp (car lst))
(alist? (cdr lst))))
(t nil)))
(defun json-encode-obj (v)
(format nil "~{~a~^,~}"
(mapcar (lambda (pair)
(format nil "\"~(~a~)\":~a"
@jhunt
jhunt / combined.sql
Created July 31, 2020 15:24
mariadb northwind
SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='TRADITIONAL,ALLOW_INVALID_DATES';
DROP SCHEMA IF EXISTS `northwind` ;
CREATE SCHEMA IF NOT EXISTS `northwind` DEFAULT CHARACTER SET latin1 ;
USE `northwind` ;
-- -----------------------------------------------------
-- Table `northwind`.`customers`
@jhunt
jhunt / cert-issuer.yml
Last active June 16, 2020 18:06
Gluon Kubernetes Controller Deployment YAML
apiVersion: cert-manager.io/v1alpha2
kind: ClusterIssuer
metadata:
name: internal-ca
namespace: cert-manager
spec:
selfSigned: {}
@jhunt
jhunt / kubernetes.yml
Last active August 3, 2020 20:14
A Gluon Deployment for Kubernetes
---
apiVersion: v1
kind: ConfigMap
metadata:
name: buffalo-lab-boshes
data:
vcenter_ip: your.vsphere.example.com
vcenter_dc: dc1
vcenter_cluster: cluster1
@jhunt
jhunt / just-a-pod.yml
Created February 12, 2020 14:52
Running Pods (natively) ain't such a great idea, after all.
apiVersion: v1
kind: Pod
metadata:
name: its-a-pod
spec:
containers:
- image: filefrog/k8s-hacks:falldown
name: its-a-pod
@jhunt
jhunt / Watching-Upstream-Releases.md
Last active March 17, 2022 00:05
Watching Upstream HTTP Download Sites for New Versions

Watching Upstream Releases

For a while now I've had an idea for a VERY lightweight CI/CD solution based on Kubernetes CronJobs, and a bespoke set of heuristic "version checkers" that can parse a single source -- HTTP downloads listing, a GitHub repository's release feed, etc. -- and determine if you need to go download a new thing.

This is a quick hacky sketch of what those checkers might look like, because it's late, I can't sleep, and I'm otherwise unoccupied.

@jhunt
jhunt / gist:3d3200fca04b6d6614766a920fbc8453
Created August 15, 2019 13:52
Patch for provider ID args based on BOSH vm name / ID
diff --git a/jobs/kubelet/templates/bin/kubelet b/jobs/kubelet/templates/bin/kubelet
index c5b0e52..a52cb13 100644
--- a/jobs/kubelet/templates/bin/kubelet
+++ b/jobs/kubelet/templates/bin/kubelet
@@ -34,6 +34,7 @@ end
# set kube-* binaries in our path
export PATH=$PATH:/var/vcap/packages/k8s/bin
+export PATH=$PATH:/var/vcap/packages/jq/bin
# Internship Projects
#sw
These are write-ups for potential internship projects. These projects are fully self-contained (though they most assuredly exist within the confines of a larger project like SHIELD or Cloud Foundry), and can be executed within 3 months by a team of 3-4 moderately talented junior-year computer science students.
## SHIELD etcd Data Protection Plugin
The Kubernetes container orchestration system relies on a single persistent data store for its metadata and configuration needs: etcd. This distributed key-value store is vital to the proper operation of Kubernetes and, assuming identical replacement hardware / component configuration, the data in etcd is all that an operator needs to resurrect a dead cluster.
Design and build a SHIELD Data Protection Plugin for backing up the data in etcd, and restoring data to etcd from those archives. This plugin must work within the existing contract SHIELD has for "target" plugins. To enable this effort, you will need to be able to deploy and va
@jhunt
jhunt / hunternetes.sh
Created November 22, 2018 20:16
hunternetes - A Kubernetes bootstrap script for Linode
#!/bin/bash
set -eu
useradd jhunt -Nm -c 'James Hunt' -d /home/jhunt -g staff -G staff -s /bin/bash
cat >/etc/sudoers.d/staff <<EOF
%staff ALL=(ALL:ALL) NOPASSWD:ALL
EOF
install -d -o jhunt -g staff -m 0700 ~jhunt/.ssh