Skip to content

Instantly share code, notes, and snippets.

View wheelq's full-sized avatar
🎯
Focusing

Michal Wiczynski wheelq

🎯
Focusing
View GitHub Profile
@wheelq
wheelq / heredoc_hacks.md
Created February 8, 2021 20:43
Heredoc hacks

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 January 31, 2021 16:42
Kubernetes- Export certificate info
#!/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
@wheelq
wheelq / docker-compose.yml
Created June 22, 2020 13:08
Logio in docker
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 June 22, 2020 08:04
entropy - docker-compose
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
@wheelq
wheelq / sinatra.README.rdoc
Created May 13, 2020 14:23 — forked from sivagao/sinatra.README.rdoc
sinatra.readme.en

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 16:37
Aliases for DNS, find files and ssh-keygen
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 March 28, 2020 11:57
Dockered go as an 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 March 28, 2020 11:56
Alias for terraform from docker
#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 March 26, 2020 12:54
Docker copy from/to volumes. Found on the internets
#!/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 February 26, 2020 09:48
logstash cheatsheet

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]"} }