Skip to content

Instantly share code, notes, and snippets.

View StevenACoffman's full-sized avatar

Steve Coffman StevenACoffman

View GitHub Profile
@preslavrachev
preslavrachev / do.go
Last active August 4, 2022 13:15
Do is an experiment in mimicking the Result type (known from languages like Rust and Haskell). The idea is to minimize the amount of error checking and let the developer focus on the happy path, without undermining the power of Go's errors. The code below requires Go 1.18+, as it makes use of generic type parameters.
package do
type Void struct{}
type Result[T any] interface {
Unwrap() (T, error)
}
type defaultResult[T any] struct {
val T
@knadh
knadh / numbers-to-words.go
Created June 12, 2022 08:22
Simple algorithm for converting numbers to English words (Golang)
package main
import (
"fmt"
)
var (
ones = []string{
"zero", "one", "two", "three", "four",
"five", "six", "seven", "eight", "nine",
#!/usr/bin/env bash
###
### Shell script to use Google service account and optionally
### domain-wide delegation (DwD).
###
### This script will ultimately output an access token that can be used to
### call Google APIs as the service account or the Workspace user in DwD.
###
### Example to show a Workspace user's IMAP settings:
###
@StevenACoffman
StevenACoffman / pull-request-types.md
Created October 3, 2021 15:49
pull-requests-types.md

After reading Rouan Wilsenach’s article on Ship / Show / Ask, I realized that when creating a pull request, I’m thinking about:

  • How can I confidently get my code out of the door?
  • Will my changes pass the automated CI checks?
  • Will my changes pass a self-review? I.e. would I approve my own PR?
  • Will my colleagues be able to give me good feedback?

So this gives us 7 types of pull-request:

No Pull Request / Ship
@StevenACoffman
StevenACoffman / stackoverflow-source.md
Created October 3, 2021 00:09
Get Source code from Stack overflow
@rafi
rafi / k3d-keycloak.md
Last active May 25, 2025 19:16
Keycloak and oauth2-proxy using k3d & ngrok:

K3d and Keycloak

Prerequisites

Ensure docker, k3d and ngrok are installed.

brew update
brew install --cask docker ngrok
brew install k3d
function rest(dag) {
layering = d3.layeringSimplex()
decrossing = d3.decrossOpt()
coords = d3.coordQuad()
@salrashid123
salrashid123 / signer.go
Created August 4, 2020 23:05
basic GCP IAMCredentials `crypto.Signer()`
package kms
import (
"crypto"
"encoding/base64"
"io"
"sync"
"context"
"fmt"
@StevenACoffman
StevenACoffman / time.md
Last active July 8, 2022 18:29
Time format

From Go: Format a time or date

Consider just running dateparse:

go get -u github.com/araddon/dateparse/dateparse
dateparse --timezone="UTC" "2019-11-20T22:32:59.882Z"
dateparse --timezone="America/Detroit" "2017-07-19 03:21:00"

Go: Format a time or date