Skip to content

Instantly share code, notes, and snippets.

@geraldstanje
geraldstanje / deployment.yaml
Created January 7, 2023 18:44
databricks file
custom:
mm_tags: &mm-tags
"Application Type": "Back End"
Product: Optimization
"Sub Department": "Data Science"
Department: Engineering
"Service Name": cmv
"Repo Name": cmv-st
"Purpose": prod
"Category": Production
@geraldstanje
geraldstanje / main.go
Last active July 4, 2022 10:48
use gocmp for json
package main
import (
"encoding/json"
"fmt"
"github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts"
)
@geraldstanje
geraldstanje / kms_encrypt_decrypt.sh
Created March 9, 2018 02:41
kms encrypt decrypt
#!/usr/bin/env bash
if [ -z ${KMS_KEY_ID} ]; then
echo "KMS_KEY_ID unset! Exiting";
exit 1
fi
aws kms encrypt --key-id $KMS_KEY_ID --plaintext "hello" --output text --query CiphertextBlob > output.kms.yml
encrypted=$(<output.kms.yml)
echo "Encrypted: $encrypted"
@geraldstanje
geraldstanje / json_to_map.go
Created September 20, 2019 15:53 — forked from cuixin/json_to_map.go
json to map[string]interface{} example in golang
package main
import (
"encoding/json"
"fmt"
)
func dumpMap(space string, m map[string]interface{}) {
for k, v := range m {
if mv, ok := v.(map[string]interface{}); ok {
@geraldstanje
geraldstanje / ngrep_hack.md
Created May 29, 2018 18:07 — forked from jfarcand/ngrep_hack.md
Fixing broken ngrep with OS X Mavericks

Migrating to OS X Mavericks breaks the ngrep utility. Doing:

sudo ngrep -d lo0 -q -W byline port 8080

stopped working where the process exits immediately. I didn't dig into the ngrep code, but was able to find a simple workaround by doing

sudo ngrep -q -W byline -d lo0 '' 'port 8080'

You can call that a lazy hack, but it work!

MM-MAC-3270:byoa-price-engine geri$ go run -race main.go
2018-05-25T14:05:47.525 Notice ▶ NOTI 001 Loading App Config ...
2018-05-25T14:05:47.912 Infof ▶ INFO 002 Stats - Statsd client connected to aws-stats-x1.Abc.com:57475 with prefix core.byoa-price-engine-test.MM-.MM-MAC-3270. and interval 1 second(s)
2018-05-25T14:05:47.912 Notice ▶ NOTI 003 Price Engine version - %v 0.0.0
2018-05-25T14:05:47.912 Notice ▶ NOTI 004 Price Engine build time - %v 2018-05-25 14:05:47 -0400 EDT
2018-05-25T14:05:47.912 Notice ▶ NOTI 005 Price Engine build timestamp - %v UTC 1527271547
2018-05-25T14:05:47.913 Info ▶ INFO 006 Initializing CMV LoadBalancer ...
2018-05-25T14:05:47.913 Info ▶ INFO 007 Starting Camaping Setting Store ...
2018-05-25T14:05:47.913 Info ▶ INFO 008 In Refresh Settting
2018-05-25T14:05:47.921 Info ▶ INFO 00a Starting WebPage server @ 7070
MM-MAC-3270:byoa-price-engine gstanje$ go run -race main.go
2018-05-25T14:05:47.525 Notice ▶ NOTI 001 Loading App Config ...
2018-05-25T14:05:47.912 Infof ▶ INFO 002 Stats - Statsd client connected to aws-stats-x1.mediamath.com:57475 with prefix core.byoa-price-engine-test.MM-.MM-MAC-3270. and interval 1 second(s)
2018-05-25T14:05:47.912 Notice ▶ NOTI 003 Price Engine version - %v 0.0.0
2018-05-25T14:05:47.912 Notice ▶ NOTI 004 Price Engine build time - %v 2018-05-25 14:05:47 -0400 EDT
2018-05-25T14:05:47.912 Notice ▶ NOTI 005 Price Engine build timestamp - %v UTC 1527271547
2018-05-25T14:05:47.913 Info ▶ INFO 006 Initializing CMV LoadBalancer ...
2018-05-25T14:05:47.913 Info ▶ INFO 007 Starting Camaping Setting Store ...
2018-05-25T14:05:47.913 Info ▶ INFO 008 In Refresh Settting
2018-05-25T14:05:47.921 Info ▶ INFO 00a Starting WebPage server @ 7070
@geraldstanje
geraldstanje / kms-vault
Created March 8, 2018 03:12 — forked from hassy/kms-vault
Encrypt/decrypt files using AWS KMS
#!/usr/bin/env bash
# License: MIT - https://opensource.org/licenses/MIT
#
# Usage:
#
# Encrypt a file:
# kms-vault encrypt My-Key-Alias some-file-i-want-encrypted.txt > topsecret.asc
#
@geraldstanje
geraldstanje / Makefile
Created March 7, 2018 16:42 — forked from ryu1kn/Makefile
Encrypt/decrypt with AWS KMS
# How to encrypt/decrypt your text/blob secret with AWS KMS with AWS cli
KEY_ID=alias/my-key
SECRET_BLOB_PATH=fileb://my-secret-blob
SECRET_TEXT="my secret text"
ENCRYPTED_SECRET_AS_BLOB=encrypted_secret_blob
DECRYPTED_SECRET_AS_BLOB=decrypted_secret_blob # Result of decrypt-blob target
encrypt-text: