Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Shawn Zhang hustshawn

🎯
Focusing
  • Hong Kong
View GitHub Profile
@hustshawn
hustshawn / rss-engineer-blogs
Created Sep 16, 2021 — forked from oiler/rss-engineer-blogs
RSS for Engineering Blogs
View rss-engineer-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
Created Aug 13, 2021 — forked from mcattarinussi/gpg-ssh-setup.md
A setup guide to use a personal gpg key for ssh authentication
View gpg-ssh-setup.md

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 Jun 9, 2021 — forked from paulredmond/docker.conf
Example www pool for PHP-FPM with dynamic Environment variables
View docker.conf
; 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 — forked from jexchan/multiple_ssh_setting.md
Multiple SSH keys for different github accounts
View multiple_ssh_setting.md

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 Aug 7, 2019 — forked from mgoodness/k8s-svc-annotations.md
AWS ELB-related annotations for Kubernetes Services (as of v1.12.0)
View k8s-svc-annotations.md

AWS Service annotations

  • 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 / detact_locale.py
Last active Aug 2, 2019
Determine user lcoale from HTTP header 'accept-language' with Python. Ref: https://siongui.github.io/2012/10/12/detect-user-language-locale-gae-python/
View detact_locale.py
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 Jun 18, 2019 — forked from umrashrf/aws_ses.bash
Amazon AWS CLI - SES SEND EMAIL
View aws_ses.bash
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 Dec 4, 2020 — forked from henning/create-kube-user.sh
create k8s user, certificate, permissions and client config
View create-kube-user.sh
#!/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 — 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
View kubernetes_add_service_account_kubeconfig.sh
#!/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 Apr 25, 2019 — forked from troyharvey/deployment.yml
Using Kubernetes envFrom for environment variables
View deployment.yml
# 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