Skip to content

Instantly share code, notes, and snippets.

View henkin's full-sized avatar

Paul Henkin henkin

View GitHub Profile
@henkin
henkin / deleteAwsThing.js
Created October 10, 2016 15:14
Delete an AWS IoT thing and all its attached certificates.
'use strict';
var AWS = require('aws-sdk');
AWS.config.region = 'us-east-1';
var iot = new AWS.Iot();
function deleteThing(name, policyName) {
console.log('Deleting thing "' + name + '"');
let params = {thingName: name};
@henkin
henkin / register.js
Created October 11, 2016 18:06
AWS register IoT thing using promises
'use strict';
// https://aws.amazon.com/blogs/compute/implementing-a-serverless-aws-iot-backend-with-aws-lambda-and-amazon-dynamodb/
console.log('Loading register function');
var AWS = require('aws-sdk');
AWS.config.region = 'us-east-1';
var iot = new AWS.Iot();
let policyName = 'Policy';
let thingTypeName = 'Type';
@henkin
henkin / nestedErrors.js
Created October 14, 2016 21:19
Handling errors in libraries
function mainApp() {
libraryCode(input)
.then((data) => console.log("main output", formatForUserView(data)))
.catch((err) => {
console.error("error from library!", err);
display("user-friendly error message");
});
}
@henkin
henkin / fix_tiller.sh
Created September 5, 2019 17:19
Fix helm Tiller service account gcp
kubectl create serviceaccount --namespace kube-system tiller
kubectl create clusterrolebinding tiller-cluster-rule --clusterrole=cluster-admin --serviceaccount=kube-system:tiller
kubectl patch deploy --namespace kube-system tiller-deploy -p '{"spec":{"template":{"spec":{"serviceAccount":"tiller"}}}}'
@henkin
henkin / wait-k8s-ip.sh
Created November 22, 2019 23:00
wait for k8s ip #k8s #gcp
#!/usr/bin/env bash
# Waits for kubernetes ingress to get an IP
# Usage:
# wait-k8s-ip.sh <ingressName> <namespace>
# eg: wait-k8s-ip.sh ingress-name my-app-dev
# Will timeout after 5minutes (5 * 60 tries * 1 sec wait = 300 secs)
external_ip=""
times=0
@henkin
henkin / wait-dns-ip.sh
Created November 22, 2019 23:01
Wait for DNS to resolve, return IP #gcp #dns
#!/bin/bash
# Usage:
# wait-dns-ip.sh <hostname>
# eg: wait-dns-ip.sh host.foo.com
#
# Will timeout after 5minutes (5 * 60 tries * 1 sec wait = 300 secs)
DNS_IP=""
COUNTER=0
while [ -z $DNS_IP ] && [ $COUNTER -lt 300 ]; do
DNS_IP=$(nslookup $1.humanaedge.io | awk '/^Address: / { print $2 }')
@henkin
henkin / zglobtest.sh
Last active December 21, 2019 06:51
ZSH zshell glob test condition select
print -l zsh_demo/*/*(e:'[[ ! -e $REPLY/malta ]]':)
# https://reasoniamhere.com/2014/01/11/outrageously-useful-tips-to-master-your-z-shell/
@henkin
henkin / git-to-https.sh
Last active March 19, 2020 21:00
Set Git remote origin to Https
#!/usr/bin/env bash
# chmod +x this script, put it in the parent directory, then call it with something like:
# for d in */; do; cd "$d" && bash ../git-to-https.sh && cd ..; done
# eg. if you have /src/repo1, /src/repo2, then put the script into /src, and run the loop from /src
# you have to run it within a separate Bash instance because it uses 'exit' :) hence `bash ../git-to-https.sh`
OUR_GIT_SERVER="gitlab.humanaedge.com"
DIRNAME=`basename $PWD`
@henkin
henkin / Makefile
Last active September 28, 2020 11:00
Makefile GitlabCI target gitalb make
CURRENT_DIR=$(shell pwd)
CI_COMMIT_SHORT_SHA=$(shell git rev-parse --short HEAD)
BRANCH='branch'
JOB='init-k8snet'
gci:
# 1) local gitlab-runner only pulls things that have been committed - temporarily commit
(git add . && git commit -am "gitlab CI testing - temp commit") || true
gitlab-runner exec docker ${JOB} \
# --env PRV_GKE_SA_KEY='/secrets/gcloud-key.json' \
@henkin
henkin / collapse.md
Created August 13, 2020 13:06
markdown html details summary collapse

Sample Instituional Claim

Institutional Claim Request
   {
    "contractId": "103405",
    "claimType": "HO",