Skip to content

Instantly share code, notes, and snippets.

View dfang's full-sized avatar
🎯
Focusing

fang duan dfang

🎯
Focusing
View GitHub Profile
@dfang
dfang / go.mod
Last active October 13, 2020 03:59
crud crd example
# go mod init crud-crd-example
module crud-crd-example
go 1.15
require (
github.com/imdario/mergo v0.3.11 // indirect
golang.org/x/time v0.0.0-20200630173020-3af7569d3a1e // indirect
k8s.io/apimachinery v0.17.2
git config --global alias.co checkout
git config --global alias.br branch
git config --global alias.ci commit
git config --global alias.st status
git config --global alias.unstage 'reset HEAD --'
git config --global alias.last 'log -1 HEAD'

echo alias gl=\'git log --pretty=oneline\' >> ~/.bashrc
echo alias gs=\'git status\' >> ~/.bashrc
@dfang
dfang / app.js.md
Last active August 19, 2020 17:34
aws cognito UI customization

if you only need email and password fields in sign up and sign in page and you want to customize labals .....

<AmplifyAuthenticator>
    <AmplifySignIn
        headerText="Custom form"
        formFields={[
            {
                type: 'username',
@dfang
dfang / ec2.md
Last active August 14, 2020 03:04
aws cli tips
aws ec2 describe-regions --output table

for region in `aws ec2 describe-regions --output text | cut -f4`
do
     echo -e "\nListing Instances in region:'$region'..."
     aws ec2 describe-instances --region $region | jq '.Reservations[] | ( .Instances[] | {state: .State.Name, name: .KeyName, type: .InstanceType, key: .KeyName})'
done

@dfang
dfang / mirror.md
Last active August 24, 2023 06:50
设置npm yarn的镜像源 或者走代理
npm set registry https://registry.npm.taobao.org && \
npm set disturl https://npm.taobao.org/dist && \
npm set sass_binary_site https://npm.taobao.org/mirrors/node-sass && \
npm set fse_binary_host_mirror https://npm.taobao.org/mirrors/fsevents && \
npm set electron_mirror https://npm.taobao.org/mirrors/electron/ && \
npm set puppeteer_download_host https://storage.googleapis.com.cnpmjs.org && \
npm set chromedriver_cdnurl https://npm.taobao.org/mirrors/chromedriver && \
npm set operadriver_cdnurl https://npm.taobao.org/mirrors/operadriver && \
npm set phantomjs_cdnurl https://npm.taobao.org/mirrors/phantomjs && \
@dfang
dfang / elk.md
Last active July 19, 2020 00:45
es, kibana

On Mac

brew install elasticsearch kibana heartbeat metricbeat filebeat

test elasticsearch

the elasticsearch installed by homebrew is oss version (without x-pack)

@dfang
dfang / k8s.md
Last active October 15, 2020 16:37
expose services on k8s via nginx-ingress-controller, traefik, ambassador

httpbin, whoami, qotm (quote of the moment) 服务特别适合用来作为测试

kubectl create namespace httpbin
kubectl create deploy httpbin --image=citizenstig/httpbin --port=8000 -n httpbin
kubectl expose deployment httpbin --name=httpbin -n httpbin --port=80 --target-port=8000

kubectl create ns whoami
kubectl create deploy whoami --image=containous/whoami --port=80 -n whoami --replicas=3
kubectl expose deployment whoami --name=whoami -n whoami --port=80 --target-port=80
@dfang
dfang / rsync_from_server.md
Last active January 1, 2020 07:08 — forked from lgloege/rsync_from_server.md
Use rsync to copy from a server with bastion server between them. Does not require scp or ssh tunneling.

Setup keyless login

  1. On local make an RSA key if you haven't already (ssh-keygen)
  2. Copy that key into .ssh/authorized_keys on the first (i.e. bastion) server (ssh-copy-id user@bastion.server) 2b. Test that you can ssh user@bastion.server and connect without password
  3. ssh to bastion.server and create an RSA key on bastion.server if you haven't already (ssh-keygen)
  4. ssh-copy-id to the server you want to access (what I am calling real.server) 4b. test that you can ssh from bastion.server to real.server without entering a password

To copy from server to local

rsync -e "ssh user@bastion.server ssh" user@real.server:/path/to/file /path/to/local/dest

@dfang
dfang / curl.md
Created December 15, 2019 06:49 — forked from subfuzion/curl.md
curl POST examples

Common Options

-#, --progress-bar Make curl display a simple progress bar instead of the more informational standard meter.

-b, --cookie <name=data> Supply cookie with request. If no =, then specifies the cookie file to use (see -c).

-c, --cookie-jar <file name> File to save response cookies to.

@dfang
dfang / gist:ff45c0df555903085158cccb7a7f8054
Last active September 27, 2019 10:36
debugging dns, network in k8s
kubectl apply -f https://github.com/infrabricks/kubernetes-standalone/raw/master/examples/alpine.yml
kubectl apply -f https://github.com/infrabricks/kubernetes-standalone/raw/master/examples/busybox.yml

then

kubectl exec -ti alpine -- nslookup/ping/curl/sh