Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Michal Wiczynski wheelq

🎯
Focusing
View GitHub Profile
View heredoc_hacks.md

variable substitution, leading tab retained, overwrite file, echo to stdout

tee /path/to/file <<EOF
${variable}
EOF

no variable substitution, leading tab retained, overwrite file, echo to stdout

@wheelq
wheelq / k8s-key-export.sh
Created Jan 31, 2021
Kubernetes- Export certificate info
View k8s-key-export.sh
#!/usr/bin/env bash
# Export CA
kubectl config view --minify --raw --output 'jsonpath={..cluster.certificate-authority-data}' | base64 -D > ca.crt
# Export Client Cert
kubectl config view --minify --raw --output 'jsonpath={..user.client-certificate-data}' | base64 -D > client.crt
# Export Client Key
kubectl config view --minify --raw --output 'jsonpath={..user.client-key-data}' | base64 -D >client.key
# Usage:
curl -k --cert client.crt --key client.key --cacert ca.crt https://[K8S_HOST]:6443/api/v1/pod
View docker-compose.yml
version: '3'
services:
logs:
image: gerchardon/docker-logio
links:
- logio:logio
volumes:
- /var/run/docker.sock:/var/run/docker.sock
command: -h logio -n docker
privileged: true
@wheelq
wheelq / entropy.sh
Created Jun 22, 2020
entropy - docker-compose
View entropy.sh
cat /proc/sys/kernel/random/entropy_avail
# around 5
apt install -y haveged
systemctl status haveged.service
cat /proc/sys/kernel/random/entropy_avail
# 2400 or more
View sinatra.README.rdoc

Sinatra

Sinatra is a DSL for quickly creating web applications in Ruby with minimal effort:

# myapp.rb
require 'sinatra'

get '/' do
  'Hello world!'
@wheelq
wheelq / zsh.aliases
Created May 11, 2020
Aliases for DNS, find files and ssh-keygen
View zsh.aliases
alias dns="scutil --dns | grep 'nameserver\[[0-9]*\]'"
alias ffile='function __ffile(){if [ -z $2 ]; then _loc=".";else _loc="${2}";fi; if [ -z $1 ]; then echo "use: ffile [filename] [path]";else find "${_loc}" -type f -iname "*$1*" 2>/dev/null;unset -f __ffile;fi }; __ffile'
alias create-ssh-key='function _create(){SUFFIX=$(date +%Y%m%d_%H%M%S);ssh-keygen -o -a 100 -t ed25519 -f ~/.ssh/id_ed25519_${SUFFIX}_wheelq -C "id_ed25519_${SUFFIX}_wheelq"; unset -f _create;echo -e "Key: ${HOME}/.ssh/id_ed25519_${SUFFIX}_wheelq\n\n$(cat ${HOME}/.ssh/id_ed25519_${SUFFIX}_wheelq.pub)"};_create'
@wheelq
wheelq / go.alias
Last active Mar 28, 2020
Dockered go as an alias
View go.alias
#echo "alias go=' function __go(){ docker run --rm -v \"\${PWD}:/usr/src/myapp\" -w /usr/src/myapp -it golang:latest go \$@;unset -f __go;}; __go'"|tee -a ~/.bash_profile >> ~/.bashrc
echo -e "#\!/usr/bin/env bash\nfunction __go(){ docker run --rm -v \"\${PWD}:/usr/src/myapp\" -w /usr/src/myapp -it golang:latest go \$@;unset -f __go;}; __go \$@" > /usr/local/bin/go && chmod 755 /usr/local/bin/go
@wheelq
wheelq / terraform.alias
Last active Mar 28, 2020
Alias for terraform from docker
View terraform.alias
#echo "alias terraform=' function __terraform(){ docker run --rm -v \"\${PWD}:/src\" -w /src -v ~/.terraform.d:/root/.terraform.d -it hashicorp/terraform:light \$@;unset -f __terraform;}; __terraform'"|tee -a ~/.bash_profile >> ~/.bashrc
echo -e "#\!/usr/bin/env bash\nfunction __terraform(){ docker run --rm -v \"\${PWD}:/src\" -w /src -v ~/.terraform.d:/root/.terraform.d -it hashicorp/terraform:light \$@;unset -f __terraform;}; __terraform \$@" >/usr/local/bin/terraform && chmod 755 /usr/local/bin/terraform
@wheelq
wheelq / dcp.sh
Created Mar 26, 2020
Docker copy from/to volumes. Found on the internets
View dcp.sh
#!/bin/bash
SOURCE=$1
DEST=$2
SOURCE_ARR=(${SOURCE//:/ })
DEST_ARR=(${DEST//:/ })
if [[ ${#SOURCE_ARR[@]} -eq 2 && ${#DEST_ARR[@]} -eq 1 ]]; then
VOL=${SOURCE_ARR[0]}
@wheelq
wheelq / Logstash.md
Created Feb 26, 2020
logstash cheatsheet
View Logstash.md

Logstash cheatsheet

mutate { add_field => {"event_data.Suspicious" => "Suspicious Activity"} } --> Dest=>Values Adds field with data.

mutate { add_field => {"event_data.Suspicious" => "[event_data][Foo]"} }