Skip to content

Instantly share code, notes, and snippets.

View chaoyangnz's full-sized avatar
🏠
Working from home

Chao Y chaoyangnz

🏠
Working from home
View GitHub Profile

MicroService Proxy Gateway Solutions

Kong, Traefik, Caddy, Linkerd, Fabio, Vulcand, and Netflix Zuul seem to be the most common in microservice proxy/gateway solutions. Kubernetes Ingress is often a simple Ngnix, which is difficult to separate the popularity from other things.

Github Star Trend:

Github Star History for Kong vs traefik vs fabio vs caddy vs Zuul

This is just a picture of this link from Feb

@chaoyangnz
chaoyangnz / bump.sh
Created October 24, 2018 07:25 — forked from dberstein/bump.sh
Shell semver component bump (1 line function)
# SemVer bump small shell/python function: bumps component $1 ("major", "minor" or "patch") from version in $2 (or STDIN).
# Version components to the right of the bump rollback to 0, ie. 1.2.3:1.2.4 or 1.2.3:1.3.0 or 1.2.3:2.0.0.
function bump() {
echo ${2:-$(</dev/stdin)} | python -c 'from sys import argv,stdin,stdout;n={"major":0,"minor":1,"patch":2}.get(argv[-1]);v=list(map(int,stdin.read().strip().split(".")));v[n]=v[n]+1;v[n+1:]=[0]*len(v[n+1:]);stdout.write(".".join(map(str,v))+"\n")' $1
}
## Examples
# # Version as parameter
# $ bump minor 1.0.1
# 1.1.0
function solution(A) {
if(A.length < 3) return -1;
let depth = -1;
for(let p = 0; p < A.length; ++p) {
const q = findQ(A, p);
if(!q || q == A.length -1 || A[p] - A[q] <= depth) continue;
const r = findR(A, q);
if(r) {
const d = Math.min(A[p] - A[q], A[r] - A[q])
console.log('$$', p, q, r)
#!/bin/sh
domain=$1
if [ "$domain" == "clean" ]; then
defaults delete com.apple.SafariTechnologyPreview ResourceLoadStatisticsManualPrevalentResource
else
defaults write com.apple.SafariTechnologyPreview ResourceLoadStatisticsManualPrevalentResource $domain
defaults read com.apple.SafariTechnologyPreview ResourceLoadStatisticsManualPrevalentResource
fi

when you run npm run dev, sometimes you will come accross this error:

Open node_modules/typescript/lib/typescript.js, and go to line 8873:

if (!sourceFile) {
    return ts.createTextSpan(0, 0);
}

Put these two functions into your ~/.bashrc or ~/.zshrc

decrypt_secret() {
	if [ "$#" -ne 2 ]; then
	  echo "Usage: decrypt_secret <secret.yaml> <passphrase>"
	  return 1
	fi
	openssl enc -aes-256-cbc -d -base64 -in "$1.aes256" -out "$1" -k "$2"
}

Put these two functions into your ~/.bashrc or ~/.zshrc

decrypt_secret() {
	if [ "$#" -ne 2 ]; then
	  echo "Usage: decrypt_secret <secret.yaml> <passphrase>"
	  return 1
	fi
	openssl enc -aes-256-cbc -d -base64 -in "$1.aes256" -out "$1" -k "$2"
}
  • Kubectl exec Pod
gcloud container clusters get-credentials dunlap-gke-private --region australia-southeast1 --project stuff-98118045375 && \
kubectl exec stuff-content-service-67b9779bcf-fqb6c --namespace devint -c stuff-content-service -it -- sh
  • In Pod, dump the heap
apt-get update
apt-get install wget
wget -L -O /usr/local/bin/jattach \
{"messageType":"DATA_MESSAGE","owner":"513548267075","logGroup":"/ffx/production/ecs","logStream":"stuff-content-service-cq-sync/stuff-content-service-cq-sync/83e9719a-196c-4351-bb6f-50c5f7ffc22b","subscriptionFilters":["kiwiops-ecs-production-lambda-CloudWatchLogsECSFilter-G5BX8F9164MJ"],"logEvents":[{"id":"35437510453221364307759336754505867747353865762156904448","timestamp":1589072927283,"message":"INFO 2020/05/10 01:08:47,282 [Camel (camel-1) thread #1 - GooglePubsubConsumer[stuff.content.cs.asset.published.subscription]] (n.c.s.s.c.s.c.CsAssetPublishedRoute.log:159) - Received publish event with message id = ID-c3d11bbfc887-1588826815662-0-133346, message body = {
 "asset" : {
 "assetType" : "image",
 "id" : 300009089,
 "assetSubType" : "photograph",
 "source" : "Stuff",
 "lastPublishedAt" : "2020-05-10T01:08:46.973700Z",
 "openToComment" : false,
 "excludeFromSeo" : false,
 "lastUpdated" : "2020-05-10T01:08:46.983161Z",
 "lastPublished" : "2020-05-10T01:08:47.063024Z",