Skip to content

Instantly share code, notes, and snippets.

View StevenACoffman's full-sized avatar

Steve Coffman StevenACoffman

View GitHub Profile
@StevenACoffman
StevenACoffman / push-to-someone-elses-pr.md
Created September 17, 2025 16:35 — forked from wtbarnes/push-to-someone-elses-pr.md
Brief instructions for how to modify and push to someone else's PR on github

How to Push to Someone Else's Pull Request

Let's say contributor has submitted a pull request to your (author) project (repo). They have made changes on their branch feature and have proposed to merge this into origin/master, where

origin -> https://github.com/author/repo.git

Now say you would like to make commits to their PR and push those changes. First, add their fork as a remote called

@StevenACoffman
StevenACoffman / diy_sts.md
Created September 7, 2025 17:52 — forked from salrashid123/diy_sts.md
GCP Authentication with custom STS Server

Simple DIY STS server Google Cloud Application Default Credential

or...how to use ADC and run your own STS token broker

An STS server will exchange one token for another. This protocol is used by GCP Workload Federation.

THis example runs your own STS server with GCP where the STS server accepts a source token, validates it and the returns a gcp access_token

For more information about STS servers, see

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@StevenACoffman
StevenACoffman / proto-to-map.go
Created August 29, 2025 01:12 — forked from IshanDaga/proto-to-map.go
Create a go map from any proto message without proto->json->map
package main
import (
"google.golang.org/protobuf/proto"
"google.golang.org/protobuf/reflect/protodesc"
"google.golang.org/protobuf/reflect/protoreflect"
"google.golang.org/protobuf/types/descriptorpb"
"google.golang.org/protobuf/types/dynamicpb"
)
@StevenACoffman
StevenACoffman / importing-protobuf-guidelines.md
Created June 2, 2025 14:14
Importing proto files from an external Go library
// ProtoDiff generates an indented summary of the diff between two protos'
// YAML representations. See ProtoToYAML for documentation on rewrites.
func ProtoDiff(a, b protoutil.Message, args DiffArgs, rewrites func(interface{})) string {
	toYAML := func(m protoutil.Message) string {
		if m == nil {
			return ""
		}
 str, err := ProtoToYAML(m, false /* emitDefaults */, rewrites)

Clean Architecture (2022 H2)

Good architecture:

  • good architecture = allow changes w/ flexibility + delay decision

Business rules:

  • Entities: pure; small sets of critical business rules. Should be most independent & reusable. Can be an object with methods or data structures & functions
  • Use case: not as pure; is an object. contains data elements & operations.
  • Entities are lower level than (don’t depend on) use cases since use cases are closer to inputs/outputs.
  • Entities & use cases are 2 layers
@StevenACoffman
StevenACoffman / CommandPatternInGo.md
Created March 20, 2025 17:28
CommandPatternInGo.md

If you have several tools that are very closely related, you can make them easier to use, discover, and distribute by combining them into a single tool (and a single executable binary artifact).

If you’ve got a tool that’s sufficiently complex, you can reduce its complexity by making a set of subcommands. This is also useful for sharing stuff—global flags, help text, configuration, storage mechanisms.The above guidance doesn’t help you to decide when something is unrelated and should be separated, BTW.

It is worth comparing this advice to the Command Pattern from the “Gang of Four” “Design Patterns” book, where you encapsulate an an action or a request as an object that can be parameterized. Usually, in the Command Design Pattern the invoker doesn’t know anything about the implementation details of the command or it’s receiver, it just knows the command interface and its only responsibility is to invoke the command and optionally do some bookkeeping of what commands are possible and/or valid. There are

@StevenACoffman
StevenACoffman / workload_federation_dwd.go
Created January 30, 2025 01:24 — forked from salrashid123/workload_federation_dwd.go
Access GCP and workspace APIs using GCP Workload Identity Federation usign Domain Delegation
package main
import (
"fmt"
"log"
"context"
"cloud.google.com/go/storage"