Skip to content

Instantly share code, notes, and snippets.

@rorycl
rorycl / tplCache.go
Created March 31, 2025 17:40
Cache golang parsed templates to avoid reparsing unless in development mode
package main
// Assumes a directory next to this file called "templates"
// containing "home.html", "forest.html"
import (
"embed"
"fmt"
"html/template"
"io"
@rorycl
rorycl / exif.go
Last active March 6, 2025 17:54
Example of using bep/imagemeta (https://github.com/bep/imagemeta)
package main
import (
"fmt"
"maps"
"os"
"regexp"
"slices"
"strings"
"time"
@rorycl
rorycl / buildDateLayouts.go
Created January 9, 2025 16:55
RFC 5322, section 3.3 date parsing comparison
// 09 January 2025
package main
import (
"cmp"
"fmt"
"slices"
"sort"
"time"
)
@rorycl
rorycl / list.go
Last active April 8, 2024 13:56
bubbletea/list first item padding issue
package main
import (
"fmt"
"os"
"github.com/charmbracelet/bubbles/list"
tea "github.com/charmbracelet/bubbletea"
"github.com/charmbracelet/lipgloss"
)
@rorycl
rorycl / tx.go
Created October 25, 2023 19:04
go database/sql tx example
package main
import (
"context"
"database/sql"
"fmt"
_ "github.com/lib/pq"
)
@rorycl
rorycl / agentcerts.go
Created March 7, 2023 11:15
list ssh agent certificates
/*
Check the certificates loaded into the specified ssh agent for imminent expiry
example output:
0 key ssh-ed25519 : is not a certificate
1 key ssh-ed25519-cert-v01@openssh.com
comment: acmeinc_briony_from:2023-03-07T08:18_to:2023-03-07T11:18UTC
validity: 2023-03-07 08:37:23 GMT to 2023-03-07 11:37:23 GMT
expiring in 60m? true
@rorycl
rorycl / jwttest.go
Created June 5, 2021 21:59
Validate Header issue with ed25519 keys : github.com/gbrlsnchs/jwt
package main
import (
"crypto/ed25519"
"crypto/x509"
"fmt"
"time"
"encoding/pem"
@rorycl
rorycl / ed25519genandsave.go
Created June 5, 2021 16:14
Generate ed25519 keys in PEM format using Go
// RCL 05 June 2021
/*
verify with `openssl pkey -in <privatekey>` or `openssl pkey -in <privatekey> -pubout`
the latter should match the publickey
*/
package main
import (