Skip to content

Instantly share code, notes, and snippets.

View wobondar's full-sized avatar
🌴
Working remotely

Andrew wobondar

🌴
Working remotely
View GitHub Profile
@wobondar
wobondar / golang-to-node-authenticated-encryption.js
Created November 2, 2022 20:35 — forked from kendru/golang-to-node-authenticated-encryption.js
Decrypting AES-256-GCM encoded in Go from Node
// Usage: go run main.go | node decode.js
/*
// main.go:
package main
import (
"crypto/aes"
"crypto/cipher"
@wobondar
wobondar / aws_codebuild_credentials.sh
Created August 22, 2018 15:43
AWS CodeBuild container credentials
#!/usr/bin/env bash
curl -qL 169.254.170.2/$AWS_CONTAINER_CREDENTIALS_RELATIVE_URI > credentials.json
mkdir -p ~/.aws
echo "[default]" > ~/.aws/credentials
echo "aws_access_key_id = $(cat credentials.json | jq '.AccessKeyId' | sed s'/"//g')" >> ~/.aws/credentials
echo "aws_secret_access_key = $(cat credentials.json | jq '.SecretAccessKey' | sed s'/"//g')" >> ~/.aws/credentials
echo "aws_session_token = $(cat credentials.json | jq '.Token' | sed s'/"//g')" >> ~/.aws/credentials
rm credentials.json
@wobondar
wobondar / aws_api_gateway_export.sh
Created August 20, 2018 15:21
AWS export all API gateways with stages
aws apigateway get-rest-apis > apis.json
rm -rf apis
mkdir apis
jq -r '.items[] | .id' apis.json | while read i; do
aws apigateway get-stages --rest-api-id $i > stages.json
jq -r '.item[] | .stageName' stages.json | while read z; do
aws apigateway get-export --rest-api-id $i --stage-name $z --export-type 'swagger' "apis/$z-$i.json"
done
done
@wobondar
wobondar / Tuple.java
Created May 26, 2018 07:26
Tuple generic for two objects
public class Tuple<L,R> {
private final L left;
private final R right;
public Tuple(L left, R right) {
this.left = left;
this.right = right;
}
@wobondar
wobondar / aws_api_gateway_deployment.tf
Created May 16, 2018 00:05
AWS API Gateway Terraform trigger for re-deployment whenever it has any changes
resource "aws_api_gateway_deployment" "api_gw_deployment" {
stage_description = "${md5(file("apigateway.tf"))}"
rest_api_id = "${aws_api_gateway_rest_api.api_gw.id}"
stage_name = "production"
}
@wobondar
wobondar / Key.java
Created April 13, 2018 22:32
Private cache key
private static class Key {
private final Object key;
private final long timelife;
public Key(Object key, long timeout) {
this.key = key;
this.timelife = System.currentTimeMillis() + TimeUnit.SECONDS.toMillis(timeout);
}