Skip to content

Instantly share code, notes, and snippets.

View tmclnk's full-sized avatar

Tom McLaughlin tmclnk

View GitHub Profile
@tmclnk
tmclnk / README.md
Last active October 21, 2025 19:23
AWS Profile Switcher for

AWS Profile Switcher

Creates aliases for aws cli profile management. Reads through your ~/.aws/config and presents a list of profiles.

  • aws-switch - switch profiles (with tab completion!)
  • aws-list - list all profiles in ~/.aws/config
  • aws-profile - show the current profile (whatever's in AWS_PROFILE)
  • aws-clear - clear out AWS_PROFILE env var

Make sure you're grabbing the file with the right extension for your shell!

@tmclnk
tmclnk / id-token.js
Created January 11, 2024 17:06
id-token-example
{
"nickname": "myuser",
"name": "[email protected]",
"picture": "https://s.gravatar.com/avatar/843b31161c0df615e49c17b1eea2d89c?s=480&r=pg&d=https%3A%2F%2Fcdn.auth0.com%2Favatars%2Fmy.png",
"updated_at": "2023-06-04T01:27:09.546Z",
"iss": "https://dev-ce0onvx2.us.auth0.com/",
"aud": "mc7CK206Mk0loShIk8av4eoRKkEOgmkO",
"iat": 1685843022,
"exp": 1685879022,
"sub": "auth0|647a4956dcf5d74a05a16996",
javascript:location.href='https://archive.vn/?run=1&url=%27+encodeURIComponent(document.location.href)
@tmclnk
tmclnk / main.go
Last active December 7, 2024 10:34
Golang Machine to Machine OAuth
package main
import (
"context"
"fmt"
"golang.org/x/oauth2"
"golang.org/x/oauth2/clientcredentials"
"io/ioutil"
"os"
)
@tmclnk
tmclnk / gist:9b66709fd21d4b06e143c0fed9d2edc0
Last active June 22, 2022 13:35
Inventory/ItemsInChunksList Response => Inventory/ItemPriceAndAvailabilityList Request
# Inventory/ItemsInChunksList Response => Inventory/ItemPriceAndAvailabilityList Request
jq '{request : {dsItemPriceAndAvailRequest: {dtPriceAndAvailRequest: [{CustomerID:"1234",ShiptoSequence:"0", SaleType:"WHSE"}], dtItemToProcessRequest: [.response.ItemsInChunksListResponse.dsItemsInChunksListResponse.dtItemsInChunksListResponse[] | {ItemCode: .ItemCode, OrderQty: "1", "UOM":""}]}}}'
@tmclnk
tmclnk / calc.sh
Last active June 21, 2022 14:15
Postman Collection JSON
# Averages
jq ' .results [] | { name: .name , avg : .times | (add/length) }'
# Calculate average time of a particular request (by name)
jq ' .results [] | select(.name | contains("20")).times | add / length'
jq ' .results [] | select(.name | contains("40")).times | add / length'
jq ' .results [] | select(.name | contains("60")).times | add / length'
jq ' .results [] | select(.name | contains("80")).times | add / length'
jq ' .results [] | select(.name | contains("100")).times | add / length'
@tmclnk
tmclnk / gh_hash.sh
Created April 18, 2022 19:16
dump latest hash
#!/usr/bin/env bash
github_pat=$(bw get password "github pat")
owner=dmsi-io
branch=develop
declare -A repos
repos[accounts-receivable-api]=develop
repos[users-api]=develop
repos[session-api]=develop
@tmclnk
tmclnk / empty_test.go
Created April 13, 2022 01:12
Golang Zero-Value JSON Serialization
package main
import (
"encoding/json"
"github.com/stretchr/testify/assert"
"testing"
)
type MyType struct {
FieldA string `json:"field_a"`
// AgilityPayload canonical payload shape for agility "REST" methods.
// Use this if you don't want to make structs for your backend call,
// but still want to access deeply nested fields which you wouldn't
// be able to dereference when using map[string]interface{}.
type AgilityPayload map[string]map[string]map[string][]map[string]interface{}
// ToMap to let you dump a map of names to meaningless objects
// into an even less useful map of names to meaningless objects.
// _this_ is what you'd pass to the RequestBody.
func (c *AgilityPayload) ToMap() map[string]interface{} {
@tmclnk
tmclnk / header.png
Last active April 7, 2022 14:39
Postman - set authorization header
header.png