Skip to content

Instantly share code, notes, and snippets.

Avatar
🎧
codin'

James Hunt jhunt

🎧
codin'
View GitHub Profile
@jhunt
jhunt / flags.cl
Created Dec 14, 2021
Using Lisp Macros to Fact-Check Code at Compile Time
View flags.cl
;;
;; 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 Sep 8, 2021
JSON encoding in Lisp!
View json-encode.cl
(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 Jul 31, 2020
mariadb northwind
View combined.sql
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 Jun 16, 2020
Gluon Kubernetes Controller Deployment YAML
View cert-issuer.yml
apiVersion: cert-manager.io/v1alpha2
kind: ClusterIssuer
metadata:
name: internal-ca
namespace: cert-manager
spec:
selfSigned: {}
@jhunt
jhunt / kubernetes.yml
Last active Aug 3, 2020
A Gluon Deployment for Kubernetes
View kubernetes.yml
---
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 Feb 12, 2020
Running Pods (natively) ain't such a great idea, after all.
View just-a-pod.yml
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 Mar 17, 2022
Watching Upstream HTTP Download Sites for New Versions
View Watching-Upstream-Releases.md

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 Aug 15, 2019
Patch for provider ID args based on BOSH vm name / ID
View gist:3d3200fca04b6d6614766a920fbc8453
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
View gist:f5c5fb5da882628a3c777784eb3f1eb3
# 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 Nov 22, 2018
hunternetes - A Kubernetes bootstrap script for Linode
View hunternetes.sh
#!/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