Skip to content

Instantly share code, notes, and snippets.

@mikepatrick
mikepatrick / python_sigv4.py
Created May 18, 2020 00:51
Python sigv4 code
# from datetime import datetime
import hmac, hashlib
import requests
import datetime
def sign(key, msg):
return hmac.new(key, msg.encode('utf-8'), hashlib.sha256).digest()
def get_signature_key(key, dateStamp, regionName, serviceName):
kDate = sign(('AWS4' + key).encode('utf-8'), dateStamp)
@mikepatrick
mikepatrick / color-settings.json
Created March 21, 2020 00:13
VSCode dark blue colors
{
"workbench.colorCustomizations": {
"activityBar.background": "#001",
"activityBar.border": "#00f",
"activityBar.dropBackground": "#023",
"activityBar.foreground": "#777",
"activityBar.inactiveForeground": "#066",
"activityBarBadge.background": "#006",
"activityBarBadge.foreground": "#ff0",
"badge.background": "#006",
@mikepatrick
mikepatrick / jenkinsfile-refactor.js
Created March 3, 2020 21:19
Move some Jenkinsfile logic out into JS script.
const AWS = require('aws-sdk');
const s3 = new AWS.S3();
async function doStuff() {
const temps = await getETags('splitter-transaction-temp-schema');
const currents = await getETags('splitter-transaction-schema-develop');
let publish = true;
@mikepatrick
mikepatrick / nodeServiceProvider.ts
Created February 5, 2019 16:59
Singleton to vend aws-sdk services and http clients.
import { DynamoDB, SNS } from 'aws-sdk';
import * as https from 'https';
const AWSXRay = require('aws-xray-sdk');
interface ProviderConfig {
forceLocal?: boolean;
forceLive?: boolean;
dynamoEndpoint?: string;
snsEndpoint?: string;
region?: string;
{
"type": "hc",
"colors": {
"contrastBorder": "#0000ff",
"contrastActiveBorder": "#00ff00",
"selection.background": "#008000",
"widget.shadow": "#aa00aa",
"input.background": "#001111",
"input.foreground": "#00aaaa",
"input.border": "#0000ff",
"workbench.colorCustomizations": {"editorWarning.foreground": "#ff0",
"editorError.foreground": "#ff0000",
"contrastActiveBorder": "#0f0",
"contrastBorder": "#00f",
"tab.border": "#050",
"editor.lineHighlightBorder": "#11a",
"activityBar.border": "#aaa",
"panel.border": "#00f",
"terminalCursor.foreground": "#0f0",
"sideBar.border": "#030",
@mikepatrick
mikepatrick / sample-token-endpoint-call.txt
Created January 25, 2018 03:23
Sample call to oauth2/token for AWS Cognito.
POST /oauth2/token HTTP/1.1
Host: my-cognito-domain.auth.us-east-1.amazoncognito.com
Content-Type: application/x-www-form-urlencoded
Cache-Control: no-cache
Postman-Token: bdcd43dc-...
grant_type=authorization_code&code=ad377bda-218a-44c6-b61e-338f24eef205&client_id=1xxxxxxxxxxxxxx0&redirect_uri=https%3A%2F%2Flocalhost%3A3000%2F
{
"id":"https://schema.management.azure.com/schemas/2017-09-01-preview/Microsoft.DataFactory.json#",
"$schema":"http://json-schema.org/draft-04/schema#",
"title":"Microsoft.DataFactory",
"description":"Microsoft DataFactory Resource Types",
"resourceDefinitions":{
"factories":{
"type":"object",
"properties":{
"name":{
@mikepatrick
mikepatrick / azure-schema
Created December 27, 2017 21:45
json schema to typescript demo
{
"id":"https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"$schema":"http://json-schema.org/draft-04/schema#",
"title":"Template",
"description":"An Azure deployment template",
"type":"object",
"properties":{
"$schema":{
"type":"string",
"description":"JSON schema reference"
@mikepatrick
mikepatrick / cognito-user-pool-get-token.ts
Last active December 14, 2017 23:41
Get auth token for user authenticated via Cognito User Pool
getAuthTokenFromCognitoUserPool = (): Promise<Cognito.CognitoIdToken> => {
var self = this;
return new Promise(function fetchCurrentAuthToken(resolve: Function, reject: Function) {
var cognitoUser = self.props.appState.state.pool.getCurrentUser();
self.props.appState.setState({cognitoUser: cognitoUser});
if (cognitoUser) {
cognitoUser.getSession(function sessionCallback(err: {}, session: Cognito.CognitoUserSession) {
if (err) {
reject(err);