diff --git a/.aliases b/.aliases index 49b5c6f..008f57e 100644 --- a/.aliases +++ b/.aliases @@ -68,8 +68,102 @@ alias chromekill="ps ux | grep '[C]hrome Helper --type=renderer' | grep -v exten alias certdate='f(){ openssl s_client -connect "$@" -showcerts /dev/null | openssl x509 -inform PEM -text -out certdata | grep "Not After"; unset -f f; }; f' -# Ripgrep doesn't search hidden files by default -alias rg='rg --hidden' +# Ripgrep doesn't search hidden files by default (but ignore git) +alias rg='rg --hidden -g "!.git"' # https://twitter.com/natfriedman/status/1137094384170799104 alias agame='c=12322123;x=20;y=20;while read -sn1 p;do k=${c:$(((p-1)*2)):2};let x+=$(($k/10-2));let y+=$(($k%10-2));echo -en \\033[$y\;"$x"HX;done' + + +# pwdx +alias pwdx='f(){ lsof -p "$@" | grep cwd; }; f' + +# EC2 key fingerprint +alias aws_fingerprint='f(){ ssh-keygen -ef "$@" -m PEM | openssl rsa -RSAPublicKey_in -outform DER | openssl md5 -c; }; f' + +# urlencod a string via perl +alias url_encode="perl -MURI::Escape -e 'print uri_escape(\$ARGV[0]);'" + +# ISO 8601 date +alias iso_date='date -u +"%Y-%m-%dT%H:%M:%SZ"' + +# Run a pod in your cluster with sh +alias kubectl_ssh="kubectl run -it --rm --restart=Never alpine --image=alpine sh" + + +# Find and edit +alias rgedit='f(){ vim -p $(rg -l "$@"); unset -f f; }; f' + +# Replace docker-compose with docker cli +alias docker-compose="docker compose" + +# Count Down script +alias countdown=countdown.sh + +# Find a stash touching a specific file +git_stashes_touching() { + local file="$1" + if [ -z "$file" ]; then + echo "Usage: git_stashes_touching path/to/file" + return 1 + fi + + for stash in $(git stash list | awk -F: '{print $1}'); do + if git stash show --name-only "$stash" | grep -Fxq "$file"; then + echo "$stash touches $file" + fi + done +} + +# List the architecture of various pods: +# note you can call this like: +# kubectl-get-pods-arch -n my-namespace +# or +# kubectl-get-pods-arch -l app=frontend +kubectl-get-pods-arch() { + { + echo '{"nodes":' + kubectl get nodes -o json + echo ',"pods":' + kubectl get pods ${@} -o json + echo '}' + } | jq -r ' + (.nodes.items | map({(.metadata.name): .status.nodeInfo.architecture}) | add) as $node_arch | + ["NAME", "NODE", "ARCH"], + (.pods.items[] | [.metadata.name, .spec.nodeName, $node_arch[.spec.nodeName]]) | + @tsv + ' | column -t +} + +# Send git diff to gist +gist-diff() { + git diff | jq -Rs '{"public":false,"files":{"example.diff":{"content":.}}}' | curl -H "Authorization: token $GITHUB_TOKEN" -X POST -d @- https://api.github.com/gists | jq -r '.html_url' +} + +# curl debugging +curl-debug() { + curl -w "lookup: %{time_namelookup}s\ntime_connect: %{time_connect}s\ntime_appconnect: %{time_appconnect}s\ntime_pretransfer: %{time_pretransfer}s\ntime_redirect: %{time_redirect}s\ntime_starttransfer: %{time_starttransfer}s\n\ntime_total: %{time_total}s\n" -I "$@" +} + +# convert bytes to human readable text (from richbg) +byteme() { + SLIST="bytes,KB,MB,GB,TB,PB,EB,ZB,YB" + + POWER=1 + # Use argument if provided, otherwise read from stdin + if [ -n "$1" ]; then + DATA="$1" + else + DATA=$(cat) + fi + + VAL=$( echo "scale=2; $DATA / 1" | bc) + VINT=$( echo $VAL / 1024 | bc ) + while [ ! $VINT = "0" ] + do + let POWER=POWER+1 + VAL=$( echo "scale=2; $VAL / 1024" | bc) + VINT=$( echo $VAL / 1024 | bc ) + done + echo $VAL$( echo $SLIST | cut -f$POWER -d, ) +} diff --git a/.bazelrc b/.bazelrc index 3a1531e..04792f1 100644 --- a/.bazelrc +++ b/.bazelrc @@ -1 +1 @@ -build --google_credentials=/Users/samrossoff/.config/gcloud/application_default_credentials.json +build --google_credentials=/Users/sam/.config/gcloud/application_default_credentials.json diff --git a/.config/fish/config.fish b/.config/fish/config.fish index e154072..385cabe 100644 --- a/.config/fish/config.fish +++ b/.config/fish/config.fish @@ -19,18 +19,18 @@ set SHELL /usr/local/bin/fish # Path to Oh My Fish install. -set -gx OMF_PATH "/Users/samrossoff/.local/share/omf" +set -gx OMF_PATH "$HOME/.local/share/omf" # Customize Oh My Fish configuration path. -#set -gx OMF_CONFIG "/Users/samrossoff/.config/omf" +#set -gx OMF_CONFIG "$HOME/.config/omf" # Load oh-my-fish configuration. source $OMF_PATH/init.fish set -g fish_key_bindings fish_vi_key_bindings -set PATH /Users/samrossoff/bin $PATH /opt/pkgconfig/bin /Users/samrossoff/google-cloud-sdk/bin /Users/samrossoff/play-1.2.5.3 -set APPENGINE_HOME /Users/samrossoff/appengine-java-sdk-1.9.34 +set PATH $HOME/bin $PATH /opt/pkgconfig/bin $HOME/google-cloud-sdk/bin $HOME/play-1.2.5.3 +set APPENGINE_HOME $HOME/appengine-java-sdk-1.9.34 # BUCK #set PATH /usr/local/opt/buck/bin $PATH diff --git a/.gitconfig b/.gitconfig index c020c8c..704d94e 100644 --- a/.gitconfig +++ b/.gitconfig @@ -1,6 +1,6 @@ [user] name = Sam - email = sam@ + email = sam.rossoff@gremlin.com [push] default = current [merge] @@ -91,10 +91,16 @@ [rerere] enabled = 1 -[url "git@github.sc-corp.net:"] - insteadOf = https://github.sc-corp.net/ +[url "git@github.com:"] + insteadOf = https://github.com/ +[url "git@bitbucket.org:"] + insteadOf = https://gremsam@bitbucket.org/ [filter "lfs"] clean = git-lfs clean -- %f smudge = git-lfs smudge -- %f process = git-lfs filter-process required = true +[pull] + ff = only +[init] + defaultBranch = main diff --git a/.gitignore b/.gitignore index 7d26c67..999473c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,2 @@ -# Only track files that start in . +# Opt-In for tracking * -.snapaccess.yml diff --git a/.gradle/gradle.properties b/.gradle/gradle.properties index 6668f8b..1d5d3b7 100644 --- a/.gradle/gradle.properties +++ b/.gradle/gradle.properties @@ -1,5 +1,4 @@ -org.gradle.jvmargs=-Xmx9000M org.gradle.caching=true -org.gradle.configureondemand=true +#org.gradle.configureondemand=true org.gradle.daemon=true org.gradle.parallel=true diff --git a/.ideavimrc b/.ideavimrc index aea6d95..fe3742a 100644 --- a/.ideavimrc +++ b/.ideavimrc @@ -1 +1,2 @@ source ~/.vimrc +set ideajoin \ No newline at end of file diff --git a/.jq b/.jq new file mode 100644 index 0000000..a3a9c3a --- /dev/null +++ b/.jq @@ -0,0 +1,17 @@ +# Source: https://stackoverflow.com/questions/28593471/how-to-simplify-aws-dynamodb-query-json-output-from-the-command-line +def decode_ddb: + def _sprop($key): select(keys == [$key])[$key]; # single property objects only + ((objects | { value: _sprop("S") }) # string (from string) + // (objects | { value: _sprop("NULL") | null }) # null (from boolean) + // (objects | { value: _sprop("B") }) # blob (from string) + // (objects | { value: _sprop("N") | tonumber }) # number (from string) + // (objects | { value: _sprop("BOOL") }) # boolean (from boolean) + // (objects | { value: _sprop("M") | map_values(decode_ddb) }) # map (from object) + // (objects | { value: _sprop("L") | map(decode_ddb) }) # list (from encoded array) + // (objects | { value: _sprop("SS") }) # string set (from string array) + // (objects | { value: _sprop("NS") | map(tonumber) }) # number set (from string array) + // (objects | { value: _sprop("BS") }) # blob set (from string array) + // (objects | { value: map_values(decode_ddb) }) # all other non-conforming objects + // (arrays | { value: map(decode_ddb) }) # all other non-conforming arrays + // { value: . }).value # everything else + ; diff --git a/.profile b/.profile index 4ec202c..d55e797 100644 --- a/.profile +++ b/.profile @@ -1,4 +1,4 @@ PATH=$PATH:$HOME/.rvm/bin # Add RVM to PATH for scripting -export PATH="$HOME/.cargo/bin:$PATH" +. "$HOME/.cargo/env" diff --git a/.tmux.conf b/.tmux.conf index 9fcfb9f..cf869bc 100644 --- a/.tmux.conf +++ b/.tmux.conf @@ -47,3 +47,10 @@ unbind % # Make open work inside tmux # from https://www.elmund.io/osx/2015/07/10/open-command-in-osx-tmux/ set -g default-command "${SHELL}" + + +# Rename tmux windows to filepath +set-option -g status-interval 5 +set-option -g automatic-rename on +#set-option -g automatic-rename-format '#{b:pane_current_path}' +set-option -g automatic-rename-format '#(tmux_pwd="#{pane_current_path}"; zsh -c "source ~/.zshrc.d/09_shortcuts.zsh 2>/dev/null; print -D $tmux_pwd")' diff --git a/.vim/colors/oldzeller.vim b/.vim/colors/oldzeller.vim new file mode 100644 index 0000000..31efb61 --- /dev/null +++ b/.vim/colors/oldzeller.vim @@ -0,0 +1,54 @@ +" local syntax file - set colors on a per-machine basis: +" vim: tw=0 ts=4 sw=4 +" Vim color file +" Maintainer: Ron Aaron +" Last Change: 2003 May 02 + +set background=light +hi clear +if exists("syntax_on") + syntax reset +endif +let g:colors_name = "oldzeller" + +hi Comment term=bold ctermfg=Red guifg=Red +hi Normal guifg=black guibg=white +hi Constant term=underline ctermfg=Magenta guifg=Magenta +hi Special term=bold ctermfg=Magenta guifg=Magenta +hi Identifier term=underline ctermfg=Blue guifg=Blue +hi Statement term=bold ctermfg=DarkRed gui=NONE guifg=Brown +hi PreProc term=underline ctermfg=Magenta guifg=Purple +hi Type term=underline ctermfg=Blue gui=NONE guifg=Blue +hi Visual term=reverse ctermfg=Yellow ctermbg=Red gui=NONE guifg=Black guibg=Yellow +hi Search term=reverse ctermfg=Black ctermbg=Cyan gui=NONE guifg=Black guibg=Cyan +hi Tag term=bold ctermfg=DarkGreen guifg=DarkGreen +hi Error term=reverse ctermfg=15 ctermbg=9 guibg=Red guifg=White +hi Todo term=standout ctermbg=Yellow ctermfg=Black guifg=Blue guibg=Yellow +hi StatusLine term=bold,reverse cterm=NONE ctermfg=Yellow ctermbg=DarkGray gui=NONE guifg=Yellow guibg=DarkGray +hi! link MoreMsg Comment +hi! link ErrorMsg Visual +hi! link WarningMsg ErrorMsg +hi! link Question Comment +hi link String Constant +hi link Character Constant +hi link Number Constant +hi link Boolean Constant +hi link Float Number +hi link Function Identifier +hi link Conditional Statement +hi link Repeat Statement +hi link Label Statement +hi link Operator Statement +hi link Keyword Statement +hi link Exception Statement +hi link Include PreProc +hi link Define PreProc +hi link Macro PreProc +hi link PreCondit PreProc +hi link StorageClass Type +hi link Structure Type +hi link Typedef Type +hi link SpecialChar Special +hi link Delimiter Special +hi link SpecialComment Special +hi link Debug Special diff --git a/.vimrc b/.vimrc index 603c179..a52d2e8 100644 --- a/.vimrc +++ b/.vimrc @@ -34,6 +34,7 @@ Plugin 'YankRing.vim' Plugin 'ack.vim' Plugin 'ctrlp.vim' Plugin 'syntastic' +Plugin 'kawaz/shellcheck.vim' Plugin 'tpope/vim-fugitive' Plugin 'vimtodo' Plugin 'openurl.vim' @@ -49,6 +50,9 @@ Plugin 'bkad/CamelCaseMotion' Plugin 'tpope/vim-git' Plugin 'jiangmiao/auto-pairs' Plugin 'SirVer/ultisnips' +" OMG FINALLY!!!! +Plugin 'vim-scripts/ReplaceWithRegister' +Plugin 'tommcdo/vim-exchange' " Snippets are separated from the engine. Add this if you want them: Plugin 'honza/vim-snippets' @@ -103,6 +107,8 @@ set wildmode=longest:full " Matches only to longest filename, displays to m set complete=.,w,b,u " complete from current file, and current buffers default: .,w,b,u,t,i trying to keep down completion time set directory=$HOME/.vim/tmp " set directory for tmp files to be in .vim, so that .swp files are not littered set clipboard=unnamed " Use the * register when a register is not specified - unifies with system clipboard! +set modeline " Let individual files overrise config via modeline +set modelines=2 " Check the first/last 2 lines "set foldmethod=indent " use indent unless overridden set foldlevel=0 " show contents of all folds @@ -111,7 +117,7 @@ set foldlevel=0 " show contents of all folds filetype plugin on "turns on filetype plugin, lets matchit work well -colorscheme zellner "changes color scheme to something that looks decent on the mac +colorscheme oldzeller "changes color scheme to something that looks decent on the mac " Set the vim info options " In order: local marks for N files are saved, global marks are saved, @@ -421,3 +427,5 @@ autocmd BufWinEnter * match ExtraWhitespace /\s\+$/ autocmd InsertEnter * match ExtraWhitespace /\s\+\%#\@/dev/null | sort -u | while read app; +do + filename="$app/Contents/Frameworks/Electron Framework.framework/Electron Framework" + if [[ -f $filename ]]; then + echo "App Name: $(basename ${app})" + + electronVersion=$(strings "$filename" | grep "Chrome/" | grep -i Electron | grep -v '%s' | sort -u | cut -f 3 -d '/') + echo "Electron Version: $electronVersion" + + echo -n "File Name: $filename " + echo -e "\n" + fi +done diff --git a/bin/or b/bin/or new file mode 100755 index 0000000..390a4b5 --- /dev/null +++ b/bin/or @@ -0,0 +1,8 @@ +#!/bin/zsh + +if [ $? -eq 0 ]; then + exit $? +fi + +exec ${@:1} +exit $? diff --git a/workspace/useful-pods/bare-echo-server.yaml b/workspace/useful-pods/bare-echo-server.yaml new file mode 100644 index 0000000..4505846 --- /dev/null +++ b/workspace/useful-pods/bare-echo-server.yaml @@ -0,0 +1,22 @@ +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: echoserver + namespace: default +spec: + selector: + matchLabels: + app: echoserver + replicas: 1 + template: + metadata: + labels: + app: echoserver + spec: + containers: + - image: gcr.io/google_containers/echoserver:1.10 + imagePullPolicy: Always + name: echoserver + ports: + - containerPort: 8080 diff --git a/workspace/useful-pods/dns-pod.yaml b/workspace/useful-pods/dns-pod.yaml new file mode 100644 index 0000000..9192bf3 --- /dev/null +++ b/workspace/useful-pods/dns-pod.yaml @@ -0,0 +1,14 @@ +apiVersion: v1 +kind: Pod +metadata: + name: dnsutils + namespace: default +spec: + containers: + - name: dnsutils + image: gcr.io/kubernetes-e2e-test-images/dnsutils:1.3 + command: + - sleep + - "3600" + imagePullPolicy: IfNotPresent + restartPolicy: Always diff --git a/workspace/useful-pods/double-sleep.yaml b/workspace/useful-pods/double-sleep.yaml new file mode 100644 index 0000000..24b7851 --- /dev/null +++ b/workspace/useful-pods/double-sleep.yaml @@ -0,0 +1,44 @@ +apiVersion: v1 +kind: Pod +metadata: + annotations: + name: double-busybox-sleep + namespace: default +spec: + containers: + - args: + - sleep + - "1000000" + image: busybox + imagePullPolicy: Always + name: busybox + resources: {} + terminationMessagePath: /dev/termination-log + terminationMessagePolicy: File + - args: + - sleep + - "100000" + image: busybox + imagePullPolicy: Always + name: busybox-faster + resources: {} + terminationMessagePath: /dev/termination-log + terminationMessagePolicy: File + dnsPolicy: ClusterFirst + enableServiceLinks: true + priority: 0 + restartPolicy: Always + schedulerName: default-scheduler + securityContext: {} + serviceAccount: default + serviceAccountName: default + terminationGracePeriodSeconds: 30 + tolerations: + - effect: NoExecute + key: node.kubernetes.io/not-ready + operator: Exists + tolerationSeconds: 300 + - effect: NoExecute + key: node.kubernetes.io/unreachable + operator: Exists + tolerationSeconds: 300 diff --git a/workspace/useful-pods/escape-pod.yaml b/workspace/useful-pods/escape-pod.yaml new file mode 100644 index 0000000..8946774 --- /dev/null +++ b/workspace/useful-pods/escape-pod.yaml @@ -0,0 +1,47 @@ +apiVersion: v1 +kind: Pod +metadata: + annotations: + name: escape-pod + namespace: default +spec: + hostPID: true + hostNetwork: true + containers: + - args: + - sleep + - "1000000" + image: ubuntu + imagePullPolicy: Always + name: escape + resources: {} + terminationMessagePath: /dev/termination-log + terminationMessagePolicy: File + volumeMounts: + - mountPath: /host + name: host + securityContext: + privileged: true + dnsPolicy: ClusterFirst + enableServiceLinks: true + priority: 0 + restartPolicy: Always + schedulerName: default-scheduler + securityContext: {} + serviceAccount: default + serviceAccountName: default + terminationGracePeriodSeconds: 30 + tolerations: + - effect: NoExecute + key: node.kubernetes.io/not-ready + operator: Exists + tolerationSeconds: 300 + - effect: NoExecute + key: node.kubernetes.io/unreachable + operator: Exists + tolerationSeconds: 300 + volumes: + - name: host + hostPath: + path: / + type: Directory diff --git a/workspace/useful-pods/full-echo-server.yaml b/workspace/useful-pods/full-echo-server.yaml new file mode 100644 index 0000000..063279e --- /dev/null +++ b/workspace/useful-pods/full-echo-server.yaml @@ -0,0 +1,53 @@ +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: echoserver +spec: + selector: + matchLabels: + app: echoserver + replicas: 1 + template: + metadata: + labels: + app: echoserver + spec: + containers: + - image: gcr.io/google_containers/echoserver:1.4 + imagePullPolicy: Always + name: echoserver + ports: + - containerPort: 8080 +--- +apiVersion: v1 +kind: Service +metadata: + name: echoserver +spec: + ports: + - port: 80 + targetPort: 8080 + protocol: TCP + type: NodePort + selector: + app: echoserver +--- +apiVersion: extensions/v1beta1 +kind: Ingress +metadata: + name: echoserver + annotations: + kubernetes.io/ingress.class: alb + alb.ingress.kubernetes.io/target-type: instance + alb.ingress.kubernetes.io/scheme: internet-facing + alb.ingress.kubernetes.io/tags: Environment=dev,Team=sam +spec: + rules: + - host: a4e864e4-default-echoserve-3ea3-1161778277.us-west-1.elb.amazonaws.com + http: + paths: + - path: / + backend: + serviceName: echoserver + servicePort: 80 diff --git a/workspace/useful-pods/large-pod-test.yaml b/workspace/useful-pods/large-pod-test.yaml new file mode 100644 index 0000000..8ff3c0c --- /dev/null +++ b/workspace/useful-pods/large-pod-test.yaml @@ -0,0 +1,51 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + labels: + app: large-pod-test + name: large-pod-test + namespace: default +spec: + progressDeadlineSeconds: 600 + replicas: 800 + revisionHistoryLimit: 10 + selector: + matchLabels: + app: large-pod-test + strategy: + rollingUpdate: + maxSurge: 25% + maxUnavailable: 25% + type: RollingUpdate + template: + metadata: + creationTimestamp: null + labels: + app: large-pod-test + spec: + automountServiceAccountToken: false + containers: + - image: busybox + imagePullPolicy: IfNotPresent + name: busybox + args: + - sleep + - "1000000" + resources: {} + terminationMessagePath: /dev/termination-log + terminationMessagePolicy: File + - image: busybox + imagePullPolicy: IfNotPresent + name: busybox-2 + args: + - sleep + - "1000000" + resources: {} + terminationMessagePath: /dev/termination-log + terminationMessagePolicy: File + dnsPolicy: ClusterFirst + restartPolicy: Always + schedulerName: default-scheduler + securityContext: {} + shareProcessNamespace: false + terminationGracePeriodSeconds: 30 diff --git a/workspace/useful-pods/minikube-host.yaml b/workspace/useful-pods/minikube-host.yaml new file mode 100644 index 0000000..e69d761 --- /dev/null +++ b/workspace/useful-pods/minikube-host.yaml @@ -0,0 +1,22 @@ +apiVersion: v1 +kind: Service +metadata: + name: local-host + namespace: gremlin +spec: + type: ClusterIP + ports: + - protocol: TCP + port: 8080 + targetPort: 8080 +--- +apiVersion: v1 +kind: Endpoints +metadata: + name: local-host + namespace: gremlin +subsets: + - addresses: + - ip: 192.168.64.1 + ports: + - port: 8080 diff --git a/workspace/useful-pods/nginx-deployment.yaml b/workspace/useful-pods/nginx-deployment.yaml new file mode 100644 index 0000000..cce9dd2 --- /dev/null +++ b/workspace/useful-pods/nginx-deployment.yaml @@ -0,0 +1,69 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + labels: + app: nginx + name: nginx-fronted-service + namespace: default +spec: + progressDeadlineSeconds: 600 + replicas: 1 + revisionHistoryLimit: 10 + selector: + matchLabels: + app: nginx + strategy: + rollingUpdate: + maxSurge: 25% + maxUnavailable: 25% + type: RollingUpdate + template: + metadata: + creationTimestamp: null + labels: + app: nginx + spec: + automountServiceAccountToken: false + containers: + - image: nginx:1.7.9 + imagePullPolicy: IfNotPresent + name: nginx + ports: + - containerPort: 80 + protocol: TCP + resources: {} + terminationMessagePath: /dev/termination-log + terminationMessagePolicy: File + - image: nginx:1.7.9 + imagePullPolicy: IfNotPresent + name: nginx-8080 + ports: + - containerPort: 8080 + protocol: TCP + resources: {} + terminationMessagePath: /dev/termination-log + terminationMessagePolicy: File + - args: + - sleep + - "1000000" + image: busybox + imagePullPolicy: Always + name: busybox + resources: {} + terminationMessagePath: /dev/termination-log + terminationMessagePolicy: File + - args: + - sleep + - "100000" + image: busybox + imagePullPolicy: Always + name: busybox-faster + resources: {} + terminationMessagePath: /dev/termination-log + terminationMessagePolicy: File + dnsPolicy: ClusterFirst + restartPolicy: Always + schedulerName: default-scheduler + securityContext: {} + shareProcessNamespace: false + terminationGracePeriodSeconds: 30