Skip to content

Instantly share code, notes, and snippets.

View whyvez's full-sized avatar

Yves Richard whyvez

View GitHub Profile
@whyvez
whyvez / README.md
Last active August 2, 2022 02:15
Kustomize GKE Workload Identity Plugin

Kustomize GKE Workload Identity Plugin

  • Creates iam.workloadIdentityUser bindings for each IAMServiceAccount.
  • Creates iam.workloadIdentityUser bindings for each external SA defined in spec.
  • Annotates KSA that matches with each GSA from internal and external referenced GSA.
apiVersion: my.org.com/v1beta1
kind: WorkloadIdentityUser
metadata:
@whyvez
whyvez / csvjson.awk
Last active October 1, 2020 16:25
Simple awk csv to ndjson converter.
BEGIN {
FPAT = "([^,]*)|(\"[^\"]+\")"
}
NR == 1 {
split($0, header, ",")
}
NR > 1 {
@whyvez
whyvez / firebase_pre-request_script.js
Created September 3, 2020 15:03 — forked from moneal/firebase_pre-request_script.js
Postman pre-request script to create a Firebase authentication JWT header.
/**
* This script expects the global variables 'refresh_token' and 'firebase_api_key' to be set. 'firebase_api_key' can be found
* in the Firebase console under project settings then 'Web API Key'.
* 'refresh_token' as to be gathered from watching the network requests to https://securetoken.googleapis.com/v1/token from
* your Firebase app, look for the formdata values
*
* If all the data is found it makes a request to get a new token and sets a 'auth_jwt' environment variable and updates the
* global 'refresh_token'.
*
* Requests that need authentication should have a header with a key of 'Authentication' and value of '{{auth_jwt}}'
@whyvez
whyvez / README.md
Last active July 22, 2020 19:56
OSM Planet PBF to PostgreSQL loader on GCP

osm-loader

Small utility that loads OSM planet data into PosgresSQL.

Utility does the following:

  • Creates GCP instance with 4 SSD (1.5TB)
  • Bootstraps instance with dependencies (src/install.sh)
  • Copies src/load.sh to instance.

Usage:

@whyvez
whyvez / index.js
Last active June 5, 2020 13:42
Gable board calculator.
#!/usr/bin/env node
const gabbleWidth = 22*12;
const boardCoverage = 6.375;
const boardLength = 144;
const nBoards = Math.ceil(gabbleWidth/boardCoverage);
const narray = (n, v) => {
let arr = [...Array(Math.ceil(n+1)).keys()];
arr.shift();
@whyvez
whyvez / delete-all-stacks.sh
Last active August 29, 2018 19:12
Deletes all AWS CloudFormation stacks - USE WITH CAUTION!
#!/bin/bash
aws cloudformation list-stacks | jq -r '.[][].StackName' | while read -r stack_name; do
aws cloudformation delete-stack --stack-name "${stack_name}"
echo "deleted stack ${stack_name}"
done
@whyvez
whyvez / bashstyle.md
Created August 14, 2018 19:46 — forked from outro56/bashstyle.md
Bash scripting best practices (copied from https://github.com/progrium/bashstyle/blob/master/README.md)

progrium/bashstyle

Bash is the JavaScript of systems programming. Although in some cases it's better to use a systems language like C or Go, Bash is an ideal systems language for smaller POSIX-oriented or command line tasks. Here's three quick reasons why:

  • It's everywhere. Like JavaScript for the web, Bash is already there ready for systems programming.
  • It's neutral. Unlike Ruby, Python, JavaScript, or PHP, Bash offends equally across all communities. ;)
  • It's made to be glue. Write complex parts in C or Go (or whatever!), and glue them together with Bash.

This document is how I write Bash and how I'd like collaborators to write Bash with me in my open source projects. It's based on a lot of experience and time collecting best practices. Most of them come from these two articles, but here integrated, slightly modified, and focusing on the most bang for buck items. Plus some ne

@whyvez
whyvez / split.sh
Created May 31, 2018 00:45
maps each layer in input file into separate GeoJSON file
#!/usr/bin/env bash
# desc: maps each layer in input file into separate GeoJSON file
# usage: ./split human_footprint.gdb
# dep: gdal, awk, parallel
input="$1"
ogrinfo "$input" \
| awk '{if (NR > 2) print $2}' \
@whyvez
whyvez / deploy.sh
Last active November 18, 2017 01:27
CircleCi ElasticBeanstalk deploy
#!/usr/bin/env bash
# USAGE:
# DEPLOYMENT_BUCKET=your-deployement-bucket APPLICATION_NAME=your-application-name ENVIRONMENT_NAME=your-environment-name bash ./deploy.sh
commit_sha=$(git rev-parse HEAD)
bundle_name=${commit_sha}.zip
zip -r -x=*node_modules* -x=*.git* $bundle_name * .[^.]*
@whyvez
whyvez / jtf.js
Created October 21, 2017 12:48
Simple example of a JavaScript based Terraform pre-processor using tagged template literal
function resource (literals, func) {
console.log(`resource ${literals[0]} ${func()} ${literals[1]}`);
}
function ip_set_descriptors (literals, func) {
return `ip_set_descriptors ${literals[0]} ${func()} ${literals[1]}`;
}
const ips = ['209.171.43.251', '54.55.73.82'];