Skip to content

Instantly share code, notes, and snippets.

View hustshawn's full-sized avatar
🎯
Focusing

Shawn Zhang hustshawn

🎯
Focusing
  • AWS
  • Hong Kong
View GitHub Profile
@hustshawn
hustshawn / rss-engineer-blogs
Created September 16, 2021 14:59 — forked from oiler/rss-engineer-blogs
RSS for Engineering Blogs
{
"https://blog.twitter.com/developer": "https://blog.twitter.com/api/blog.rss?name=developer",
"https://code.facebook.com/posts/": "https://code.facebook.com/posts/rss",
"http://blog.chromium.org/": "http://blog.chromium.org/feeds/posts/default",
"http://www.theguardian.com/info/developer-blog": "http://www.theguardian.com/info/developer-blog/rss",
"http://open.blogs.nytimes.com/": "http://open.blogs.nytimes.com/feed/",
"http://blog.apps.npr.org/": "http://blog.apps.npr.org/atom.xml",
"http://www.webperformancetoday.com/": "http://www.webperformancetoday.com/feed/",
"http://www.filamentgroup.com/lab/": "http://www.filamentgroup.com/lab/atom.xml",
"http://githubengineering.com/": "http://githubengineering.com/atom.xml",
@hustshawn
hustshawn / gpg-ssh-setup.md
Last active September 5, 2022 07:44 — forked from mcattarinussi/gpg-ssh-setup.md
A setup guide to use a personal gpg key for ssh authentication

GPG - SSH setup

Generating the master key

Here we create the master key. We want only Certify capability: we use the master key only to create the subkeys, Sign - Encrypt - Authenticate capabilities will be assigned to the subkeys.

Run the following command to start the master key generation process. Select the set your own capabilities creation process (type 8)

  ▶ gpg --full-generate-key --expert

gpg (GnuPG) 2.2.9; Copyright (C) 2018 Free Software Foundation, Inc.

@hustshawn
hustshawn / docker.conf
Created June 9, 2021 04:31 — forked from paulredmond/docker.conf
Example www pool for PHP-FPM with dynamic Environment variables
; if you're using the starter bundle file `docker/php/php-fpm.d/docker.conf`
[global]
daemonize = no
pid = run/php-fpm.pid
[www]
listen = /usr/local/var/run/php-fpm.sock
listen.owner = www-data
listen.group = www-data
listen.mode = 0660
@hustshawn
hustshawn / multiple_ssh_setting.md
Created May 17, 2021 14:08 — forked from jexchan/multiple_ssh_setting.md
Multiple SSH keys for different github accounts

Multiple SSH Keys settings for different github account

create different public key

create different ssh key according the article Mac Set-Up Git

$ ssh-keygen -t rsa -C "your_email@youremail.com"
@hustshawn
hustshawn / k8s-svc-annotations.md
Created August 7, 2019 04:08 — forked from mgoodness/k8s-svc-annotations.md
AWS ELB-related annotations for Kubernetes Services (as of v1.12.0)
  • service.beta.kubernetes.io/aws-load-balancer-access-log-emit-interval (in minutes)
  • service.beta.kubernetes.io/aws-load-balancer-access-log-enabled (true|false)
  • service.beta.kubernetes.io/aws-load-balancer-access-log-s3-bucket-name
  • service.beta.kubernetes.io/aws-load-balancer-access-log-s3-bucket-prefix
  • service.beta.kubernetes.io/aws-load-balancer-additional-resource-tags (comma-separated list of key=value)
  • service.beta.kubernetes.io/aws-load-balancer-backend-protocol (http|https|ssl|tcp)
  • service.beta.kubernetes.io/aws-load-balancer-connection-draining-enabled (true|false)
@hustshawn
hustshawn / detect_locale.py
Last active November 8, 2021 03:43
Determine user lcoale from HTTP header 'accept-language' with Python. Ref: https://siongui.github.io/2012/10/12/detect-user-language-locale-gae-python/
def detectLocale(acceptLanguage):
defaultLocale = 'en_US'
supportedLocales = ['de', 'en_US', 'zh_TW']
locale_q_pairs = parseAcceptLanguage(acceptLanguage)
for pair in locale_q_pairs:
for locale in supportedLocales:
# pair[0] is locale, pair[1] is q value
if pair[0].replace('-', '_').lower().startswith(locale.lower()):
return locale
@hustshawn
hustshawn / aws_ses.bash
Created June 18, 2019 04:02 — forked from umrashrf/aws_ses.bash
Amazon AWS CLI - SES SEND EMAIL
sudo pip install awscli
aws configure
aws ses send-email \
--from "john@gmail.com" \
--destination "ToAddresses=mike@gmail.com" \
--message "Subject={Data=from ses,Charset=utf8},Body={Text={Data=ses says hi,Charset=utf8},Html={Data=,Charset=utf8}}"
@hustshawn
hustshawn / create-kube-user.sh
Last active December 4, 2020 12:19 — forked from henning/create-kube-user.sh
create k8s user, certificate, permissions and client config
#!/bin/bash
CLUSTERNAME=cluster-name
CLUSTER_API=cluster-api
NAMESPACE=namespace
USERNAME=username
ORGANIZATION=organization
KEY_FILE=$USERNAME.key
CSR_FILE=$USERNAME.csr
CRT_FILE=$USERNAME.crt
@hustshawn
hustshawn / kubernetes_add_service_account_kubeconfig.sh
Created May 17, 2019 02:42 — forked from innovia/kubernetes_add_service_account_kubeconfig.sh
Create a service account and generate a kubeconfig file for it - this will also set the default namespace for the user
#!/bin/bash
set -e
set -o pipefail
# Add user to k8s using service account, no RBAC (must create RBAC after this script)
if [[ -z "$1" ]] || [[ -z "$2" ]]; then
echo "usage: $0 <service_account_name> <namespace>"
exit 1
fi
@hustshawn
hustshawn / deployment.yml
Created April 25, 2019 08:55 — forked from troyharvey/deployment.yml
Using Kubernetes envFrom for environment variables
# Use envFrom to load Secrets and ConfigMaps into environment variables
apiVersion: apps/v1beta2
kind: Deployment
metadata:
name: mans-not-hot
labels:
app: mans-not-hot
spec:
replicas: 1