Skip to content

Instantly share code, notes, and snippets.

View tmclnk's full-sized avatar

Tom McLaughlin tmclnk

View GitHub Profile
@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 8, 2022 22:29
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
@tmclnk
tmclnk / curl.sh
Created February 16, 2022 19:30
GraphQL Introspection Query
curl --location --request POST 'http://localhost:8080/session-api' \
--header 'Content-Type: application/json' \
--data-raw '{"query":"query IntrospectionQuery {\n __schema {\n queryType {\n name\n }\n mutationType {\n name\n }\n subscriptionType {\n name\n }\n types {\n ...FullType\n }\n directives {\n name\n description\n locations\n args {\n ...InputValue\n }\n }\n }\n}\n\nfragment FullType on __Type {\n kind\n name\n description\n fields(includeDeprecated: true) {\n name\n description\n args {\n ...InputValue\n }\n type {\n ...TypeRef\n }\n isDeprecated\n deprecationReason\n }\n inputFields {\n ...InputValue\n }\n interfaces {\n ...TypeRef\n }\n enumValues(includeDeprecated: true) {\n name\n description\n isDeprecated\n deprecationReason\n }\n possibleTypes {\n ...TypeRef\n }\n}\n\nfragment InputValue on __InputValue {\n name\n description\n type {\n