Skip to content

Instantly share code, notes, and snippets.

View 17twenty's full-sized avatar

Nick Glynn 17twenty

View GitHub Profile
@17twenty
17twenty / index.html
Created February 11, 2024 02:22
Can You Lend Me - Tailwind design + HTMX + Vanilla JS to do what we want...
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Can You Lend Me?</title>
<script src="https://cdn.tailwindcss.com"></script>
<script>
// formatNumber(n)
// formats a number 1234567 to 1,234,567
@17twenty
17twenty / gagaface.go
Created November 13, 2023 01:15
Poker Hands in Go
package main
import (
"cmp"
"log"
"math/rand"
"os"
"strconv"
"golang.org/x/exp/slices"
@17twenty
17twenty / demo.tmpl.html
Last active February 16, 2025 11:49
Golang Flash demo using cookies - recreate the Flask Flash library using Golang and HTMX and make life easier.
<html>
<head>
<script src="https://unpkg.com/htmx.org@1.8.0"></script>
<script src="https://cdn.tailwindcss.com"></script>
<title>Template Fragment Example</title>
</head>
<body>
<div hx-get="/notifications" hx-trigger="load" hx-swap="outerHTML"><!-- I GET REPLACED --></div>
package main
import (
"html/template"
"log"
"net/http"
"strconv"
)
/***********************
@17twenty
17twenty / statementFriendly.go
Created September 29, 2022 02:49
Clean and simplify a user entered name to make a Stripe 22 character friendly merchant name
package main
import (
"fmt"
"regexp"
"strings"
)
var re *regexp.Regexp
@17twenty
17twenty / migrate-readme.md
Last active June 15, 2022 03:16
How to use Migrate (incl sqlc.yaml too!)

Golang Migrations Made Easy

Prerequisite / Getting Started

$ go install -tags 'postgres' github.com/golang-migrate/migrate/v4/cmd/migrate@latest
$ migrate -h
Usage: migrate OPTIONS COMMAND [arg...]
       migrate [ -version | -help ]
@17twenty
17twenty / shortid.go
Created October 27, 2021 21:57
Use base62, UUID and the birthday paradox to create shorter unique IDs.
package main
import (
"encoding/hex"
"fmt"
"log"
"math"
"strconv"
"strings"
"time"
@17twenty
17twenty / basic.css
Created July 31, 2021 04:54
Make your navbar change color on scroll
.nav {
transition-duration: 1s;
}
@17twenty
17twenty / generate.go
Created August 14, 2020 02:21
Generate an embeddable zip file that can be included in your Golang project that auto extracts at runtime.
package main
import (
"fmt"
"io/ioutil"
"os"
"strings"
)
func main() {
package {{.Package}}
import (
"database/sql/driver"
"encoding/json"
"fmt"
"strings"
)
// {{.Type}}Enum is the status code of an {{.Type}} (must be int64)