Skip to content

Instantly share code, notes, and snippets.

View prdoyle's full-sized avatar

Patrick Doyle prdoyle

  • Elastic
  • Toronto, Ontario, Canada
View GitHub Profile
@prdoyle
prdoyle / gist:4fbffab5f78c5d3ec64ee068c6d4e337
Last active August 5, 2024 03:30
HTMX extension for JSON
<script>
(function() {
htmx.defineExtension('ContentTypeJson', {
onEvent: function(name, evt) {
if (name === "htmx:configRequest") {
evt.detail.headers['Content-Type'] = 'application/json';
}
else if (name === "htmx:beforeRequest") {
evt.detail.xhr.send(evt.detail.elt.getAttribute("hx-json"))
}
@prdoyle
prdoyle / release.yml
Created November 4, 2022 11:44
WIP GitHub action for Gradle Sonatype release
# Originally from https://github.com/testcontainers/testcontainers-java/blob/de20484e53eb8d1f580b74ff9df31261b596ab5c/.github/workflows/release.yml#L1
name: Release
on:
release:
types: [published]
permissions:
contents: read
#! /usr/bin/python
from math import prod
def compute_digits( n ):
if n <= 9:
return [ n ]
else:
return compute_digits( n // 10 ) + [ n % 10 ]
def is_robust( value ):
@prdoyle
prdoyle / day15.py
Created December 15, 2020 14:20
Advent of code 2020
#! /usr/bin/python
seed = [0,12,6,13,20,1,17]
end = 30000000
position = 1
most_recent = {}
def process( num ):
global position, most_recent
124109 Boaty McBoatface
39886 Poppy-mai
15774 Henry Worsley
11023 David Attenborough
10679 Its bloody cold here
8710 USAIN BOAT
8365 BOATIMUS PRIME
7687 Katharine Giles
7055 CATALINA DE ARAGON
6452 I Like Big Boats&I Cannot Lie
@prdoyle
prdoyle / lalr-not-nqlalr.txt
Last active August 29, 2015 14:04
A small grammar that is neither SLR nor NQLALR but is LALR
Bermudez and Logothetis show a small grammar that is neither SLR nor NQLALR but is LALR.
S -> agd
S -> aAc
S -> bAd
S -> bgc
A -> B
B -> g
"Simple Computation of LALR(1) Lookahead Sets", p.237 Fig. 5