Skip to content

Instantly share code, notes, and snippets.

View dennybaa's full-sized avatar

Denis Baryshev dennybaa

View GitHub Profile
@dennybaa
dennybaa / docker-cleanup-resources.md
Last active August 6, 2018 17:20 — forked from bastman/docker-cleanup-resources.md
docker cleanup guide: containers, images, volumes, networks #docker #cleanup #cli

Docker

exec: Preserve terminal with and colors

Exec preserving terminal options:

$ docker exec -ti --env COLUMNS=`tput cols` --env LINES=`tput lines` ...

run: Pass through SSH_AUTH_SOCK

@dennybaa
dennybaa / tips.md
Last active September 2, 2018 09:20
Generate self-signed wildcard openssl certificate #openssl #tips #self-signed

Generate self-signed wildcard openssl certificate

generate csr and key

cat <<-EOF > /tmp/config.ss
[req]
distinguished_name = dn
req_extensions = v3_req
prompt = no
@dennybaa
dennybaa / semver-regex.md
Last active April 4, 2019 13:21 — forked from jhorsman/semver-regex.md
Semantic versioning regex #semver #regex

Semantic versioning regex

^([0-9]+)\.([0-9]+)\.([0-9]+)(?:-([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?(?:\+[0-9A-Za-z-]+)?$

^([0-9]|[1-9][0-9]*)\.([0-9]|[1-9][0-9]*)\.([0-9]|[1-9][0-9]*)(?:-([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?(?:\+([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?$

example

http://regexr.com/3er1i

also see

@dennybaa
dennybaa / dyndns_update.sh
Last active May 1, 2019 01:32
Update dyndns freedns http://freedns.afraid.org/ #dyndns #script
#!/bin/sh
#FreeDNS updater script
(which wget > /dev/null) || { echo "wget not found"; exit 1; }
(which nslookup > /dev/null) || { echo "nslookup not found"; exit 1; }
# FREEDNS_APIKEY (loginid|password -> SHA1)
DYNLIST=$(wget -qO- http://freedns.afraid.org/api/?action=getdyndns&sha=${FREEDNS_APIKEY})
NAME="$1"
@dennybaa
dennybaa / .bashrc.sh
Last active January 29, 2020 21:31
Helm enable TLS #helm #k8s #tls
## Enable --tls substitution for helm tls-enabled commands
#
helm() {
_context=$(kubectl config current-context)
if [ -d "${HELM_HOME:-$HOME/.helm}/tls/$_context" ]; then
export HELM_TLS_CA_CERT="${HELM_HOME:-$HOME/.helm}/tls/$_context/ca.cert.pem"
export HELM_TLS_CERT="${HELM_HOME:-$HOME/.helm}/tls/$_context/cert.pem"
export HELM_TLS_KEY="${HELM_HOME:-$HOME/.helm}/tls/$_context/key.pem"
export HELM_TLS_ENABLE="true"
fi
@dennybaa
dennybaa / deployment.yml
Created April 12, 2019 05:48 — forked from troyharvey/deployment.yml
Using Kubernetes envFrom for environment variables #k8s #envfrom
# Use envFrom to load Secrets and ConfigMaps into environment variables
apiVersion: apps/v1beta2
kind: Deployment
metadata:
name: mans-not-hot
labels:
app: mans-not-hot
spec:
replicas: 1
@dennybaa
dennybaa / backup.yml
Last active May 13, 2020 18:44
backup resource #heptio
apiVersion: ark.heptio.com/v1
kind: Backup
metadata:
creationTimestamp: 2018-11-08T14:33:07Z
generation: 1
name: my-db-test
namespace: heptio-ark
resourceVersion: "33426"
selfLink: /apis/ark.heptio.com/v1/namespaces/heptio-ark/backups/my-db-test
uid: 35c1bb4f-e363-11e8-8d80-02ec800e0240
@dennybaa
dennybaa / sonoff-flash.sh
Last active May 17, 2020 20:41
Flash sonoff with Tasmota #sonoff #tasmota
#!/bin/bash
## Hotspot should be created
# sonoffDiy 20170618sn
# ref: https://www.sigmdel.ca/michel/ha/sonoff/sonoff_mini_en.html
# ref: https://github.com/itead/Sonoff_Devices_DIY_Tools/blob/master/other/SONOFF%20DIY%20MODE%20Protocol%20Doc%20v1.4.md
download() {
# Download latest
# Get lite version (must be less 508kb!)
@dennybaa
dennybaa / tips.md
Last active July 3, 2020 14:59
K8S tips #k8s #tips

K8S tips

CLI

update config map from file

k create cm nginx-lb-config --from-file=nginx-lb.configmap --dry-run -o yaml | k replace cm nginx-lb-config -f -
templates:
- |
# Service account which can decrypt helm secrets
apiVersion: v1
kind: ServiceAccount
metadata:
name: github-actions-deployer
namespace: github-actions
annotations:
iam.gke.io/gcp-service-account: XXXX@YYYY.iam.gserviceaccount.com