Skip to content

Instantly share code, notes, and snippets.

View wolfeidau's full-sized avatar
🐺
Building data science projects

Mark Wolfe wolfeidau

🐺
Building data science projects
View GitHub Profile
@wolfeidau
wolfeidau / embed.go
Created December 20, 2020 21:03
Golang embed with echo and tests
package server
import (
"embed"
"net/http"
"github.com/labstack/echo/v4"
"github.com/labstack/echo/v4/middleware"
)
@wolfeidau
wolfeidau / git.md
Created November 13, 2020 04:24
Git user switching

I found this user management strategy somewhere, and it's been working great for me:

git config --global --unset user.name
git config --global --unset user.email
git config --global --unset user.signingkey

git config --global user.useConfigOnly true

git config --global user..name ""
@wolfeidau
wolfeidau / main.go
Created October 11, 2020 12:21
Example program which creates a secure S3 bucket using the v2 Go SDK for AWS
package main
import (
"context"
"fmt"
"log"
"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/config"
"github.com/aws/aws-sdk-go-v2/service/s3"
@wolfeidau
wolfeidau / .gitconfig
Last active August 11, 2020 03:15
Git aliases I currently use
[alias]
amend = !git add -A && git commit --amend --no-edit
p = !git push origin $(git rev-parse --abbrev-ref HEAD)
c = "!git add -A && git commit -m "
cc = "!git commit --amend -m "
co = !git checkout
f = !git fetch --all && git rebase origin/master
authors = shortlog --summary --email --numbered
l = log --graph --pretty=format:'%Cred%h%Creset -%C(green)%d%Creset %s %C(yellow)(%cr) %C(blue)<%an>%Creset'
[core]
@wolfeidau
wolfeidau / openid.yaml
Last active November 24, 2024 10:26
openid JSON openapi specification
openapi: 3.0.2
info:
title: OTK Server APIs
version: 4.3.1
description: "All API's available in OAuth Toolkit server"
paths:
/auth/oauth/v2/authorize:
get:
tags:
- Authorization Server APIs
@wolfeidau
wolfeidau / saml2idp.md
Last active January 30, 2020 23:39
Some notes / ideas on saml2aws evolution

Background

I have been working on https://github.com/versent/saml2aws for a couple of years, this tool enables developers to use SSO from the command line to get short lived credentials from AWS. As most SSO services don't have an API for authentication, this is done using screen scraping. This has resulted in:

  1. A brittle solution which requires reverse engineering and lots of patience seeing what you can get away with.
  2. This is now how SSO is suppose to work, it is designed for browsers only.
  3. Runs into tons of problems if you have multiple layers of SSO, as services send users off to social or third party authentication of users.

So we need a better way to integrate CLI tools with SSO to enable these tools to acquire and use short term credentials.

package lambda
import (
"context"
"encoding/json"
)
// JSONHandler processes events in and out using Raw JSON
type JSONHandler func(ctx context.Context, evt json.RawMessage) (json.RawMessage, error)
@wolfeidau
wolfeidau / dashboard.json
Created October 15, 2019 05:00
APIGW - 500 Errors as Percentage of Total Requests
{
"metrics": [
[ { "expression": "(m2/m1)*100", "label": "percentage", "id": "e1", "yAxis": "right" } ],
[ "AWS/ApiGateway", "5XXError", "ApiName", "xxx-xxx-xx-xx", { "label": "5xx errors", "id": "m2" } ],
[ "...", { "stat": "SampleCount", "label": "total requests", "id": "m1" } ]
],
"region": "ap-southeast-2",
"title": "APIGW - 500 Errors as Percentage of Total Requests",
"stat": "Sum",
"yAxis": {
@wolfeidau
wolfeidau / dashboard.json
Last active October 14, 2019 06:13
Cloudwatch Dashboard for Appsync which shows 500 Errors as Percentage of Total Requests
{
"metrics": [
[ { "expression": "(m2/m1)*100", "label": "percentage", "id": "e1", "yAxis": "right" } ],
[ "AWS/AppSync", "5XXError", "GraphQLAPIId", "XXXXX", { "label": "5xx errors", "id": "m2" } ],
[ "...", { "stat": "SampleCount", "label": "total requests", "id": "m1" } ]
],
"region": "ap-southeast-2",
"title": "500 Errors as Percentage of Total Requests",
"stat": "Sum",
"yAxis": {
@wolfeidau
wolfeidau / dashboard.json
Created October 14, 2019 05:48
Cloudwatch Dashboard for Appsync 400 Requests as a Percentage of Total Requests
{
"metrics": [
[ { "expression": "(m2/m1)*100", "label": "percentage", "id": "e1", "yAxis": "right" } ],
[ "AWS/AppSync", "4XXError", "GraphQLAPIId", "XXXXXXXX", { "label": "4xx errors", "id": "m2" } ],
[ "...", { "stat": "SampleCount", "label": "total requests", "id": "m1" } ],
[ ".", "5XXError", ".", ".", { "label": "5xx errors", "id": "m3", "visible": false } ]
],
"region": "ap-southeast-2",
"title": "Errors",
"stat": "Sum",