Skip to content

Instantly share code, notes, and snippets.

View afirth's full-sized avatar

Alastair Firth afirth

View GitHub Profile
@afirth
afirth / gist:13630e948592966f1ac44532175a3696
Last active January 15, 2020 14:08
vim add phony targets for makefiles
%s/^\([a-z-]\+\):/.PHONY: \1\r\1:/
@afirth
afirth / jq_for_kubectl_items.sh
Last active March 28, 2020 05:13
jq for kubectl
#name and status
k get zb -o json | jq -r '.items[] | [.metadata.name, .status.ready] | @tsv'
#get pods by label, show image and ready status
kgp --all-namespaces -l app.kubernetes.io/component=gateway -o json | jq -r '.items[] |[ .metadata.namespace, .status.containerStatuses[0].ready, .status.containerStatuses[0].image ] | @tsv' | grep alpha <<<
@afirth
afirth / flamegraph java profile notes
Created January 9, 2020 09:12
profile java w flamegraphs
#openjdk11:
#https://blog.codecentric.de/en/2017/09/jvm-fire-using-flame-graphs-analyse-performance/
#https://www.slideshare.net/brendangregg
sudo apt-install openjfx
java --module-path /usr/share/openjfx/lib --add-modules=javafx.base,javafx.controls,javafx.fxml,javafx.graphics,javafx.media,javafx.swing,javafx.web -cp ~/honest-profiler/honest-profiler.jar com.insightfullogic.honest_profiler.ports.console.FlameGraphDumperApplication ~/Downloads/honest-profiler-log-05.hpl ~/Downloads/honest-profiler-log-05.folded
git clone --depth 1 https://github.com/brendangregg/FlameGraph
cd FlameGraph
@afirth
afirth / gist:3b78034d5df5ffa5c7416f03bf26d319
Created December 20, 2019 08:15
dlv delve test particular test
dlv test -- -test.v -test.run=TestFuncName
b filename:ln
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@afirth
afirth / getopt.bash
Created July 18, 2019 15:17
bash getopt get args getargs limoncelli
#!/bin/bash
MINITEMS=1
function usage { echo " Usage: $0 [-d] [-a author] [-c file.txt] [-h] dir1 [dir1 ...] -d debug, don't actual run command -a author name of the author -c copyright override default copyright file -h this help message " exit 1 }
# Set our defaults:
DEBUG=false DEBUGCMD= AUTHOR= COPYRIGHT=copyright.txt
# Process command-line arguments, possibly overriding defaults
args='getopt da:c:h $*'
if [ $? != 0 ] then usage fi
set -- $args
for i do
time="2019-06-14T00:20:28Z" level=info msg="running version stable-2.3.2"
INFO [ 0.001275s] linkerd2_proxy::app::main using destination service at Some(ControlAddr { addr: Name(NameAddr { name: "linkerd-destination.linkerd.svc.cluster.local", port: 8086 }), identity: Some("linkerd-controller.linkerd.serviceaccount.identity.linkerd.cluster.local") })
INFO [ 0.001575s] linkerd2_proxy::app::main using identity service at Name(NameAddr { name: "linkerd-identity.linkerd.svc.cluster.local", port: 8080 })
INFO [ 0.001750s] linkerd2_proxy::app::main routing on V4(127.0.0.1:4140)
INFO [ 0.001961s] linkerd2_proxy::app::main proxying on V4(0.0.0.0:4143) to None
INFO [ 0.002152s] linkerd2_proxy::app::main serving admin endpoint metrics on V4(0.0.0.0:4191)
INFO [ 0.002277s] linkerd2_proxy::app::main protocol detection disabled for inbound ports {25, 3306}
INFO [ 0.002407s] linkerd2_proxy::app::main protocol detection disabled for outbound ports {25, 3306}
INFO [ 0.004537s] trust_dns_proto::
@afirth
afirth / Dockerfile
Created May 29, 2019 15:29
Add jmx_exporter to Camunda BPM
FROM camunda/camunda-bpm-platform:tomcat-7.11.0
## Add prometheus exporter
RUN wget https://repo1.maven.org/maven2/io/prometheus/jmx/jmx_prometheus_javaagent/0.11.0/jmx_prometheus_javaagent-0.11.0.jar -P lib/
#9404 is the reserved prometheus-jmx port
ENV CATALINA_OPTS -javaagent:lib/jmx_prometheus_javaagent-0.11.0.jar=9404:/etc/config/prometheus-jmx.yaml
@afirth
afirth / go get binaries available on path
Last active January 2, 2021 13:51
Make binaries installed with go get available on path
# add to [bash/zsh]rc and source
# Golang
which go > /dev/null && \
export GOPATH=$(go env GOPATH) && \
export PATH=$GOPATH/bin:$PATH
@afirth
afirth / afirth.zsh-theme
Created May 15, 2019 13:44
afirth zsh theme
local ret_status="%(?:%{$fg_bold[green]%}➜ :%{$fg_bold[red]%}➜ )"
PROMPT='${ret_status} %{$fg[cyan]%}%~%{$reset_color%} $(git_prompt_info)'
ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg_bold[blue]%}(%{$fg[red]%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%} "
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[blue]%}) %{$fg[yellow]%}✗"
ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg[blue]%})"