Skip to content

Instantly share code, notes, and snippets.

@adambom
adambom / README.md
Last active May 22, 2020 05:09
Backup Kubernetes Cluster State

Run this in order to backup all you k8s cluster data. It will be saved in a folder bkp. To restore the cluster, you can run kubectl apply -f bkp.

Please note: this recovers all resources correctly, including dynamically generated PV's. However, it will not recover ELB endpoints. You will need to update any DNS entries manually, and manually remove the old ELB's.

Please note: This has not been tested with all resource types. Supported resource types include:

  • services
  • replicationcontrollers
  • secrets
  • deployments
  • horizontal pod autoscalers
@mlapida
mlapida / EC2-Tag-Assets-Lambda.py
Last active January 17, 2024 08:10
A lambda function that will copy EC2 tags to all related Volumes and Network Interfaces. A full writeup can be found on my site https://empty.coffee/tagging-and-snapshotting-with-lambda/ - Thank you to the community for keeping this updated!
from __future__ import print_function
import json
import boto3
import logging
#setup simple logging for INFO
logger = logging.getLogger()
logger.setLevel(logging.ERROR)
@mgsisk
mgsisk / html.regex
Last active January 13, 2022 21:49
[HTML Regex] Regular expression pattern for matching HTML tags.
<(?(?=!--)!--[\s\S]*--|(?(?=\?)\?[\s\S]*\?|(?(?=\/)\/[^.\d-][^\/\]'"[!#$%&()*+,;<=>?@^`{|}~ ]*|[^.\d-][^\/\]'"[!#$%&()*+,;<=>?@^`{|}~ ]*(?:\s[^.\d-][^\/\]'"[!#$%&()*+,;<=>?@^`{|}~ ]*(?:=(?:"[^"]*"|'[^']*'|[^'"<\s]*))?)*)\s?\/?))>
< # Tags always begin with <.
(? # What if...
(?=!--) # We have a comment?
!--[\s\S]*-- # If so, anything goes between <!-- and -->.
| # OR
(? # What if...
(?=\?) # We have a scripting tag?
\?[\s\S]*\? # If so, anything goes between <? and ?>.
@founddrama
founddrama / gist:1013614
Created June 8, 2011 01:42
a jshint pre-commit hook for git
#!/bin/sh
# A pre-commit hook for git to lint JavaScript files with jshint
# @see https://github.com/jshint/jshint/
if git rev-parse --verify HEAD >/dev/null 2>&1
then
against=HEAD
else
# Initial commit: diff against an empty tree object
against=4b825dc642cb6eb9a060e54bf8d69288fbee4904
@henrik
henrik / .bashrc
Created December 3, 2008 17:56
Git branch and dirty state in Bash prompt.
# http://henrik.nyh.se/2008/12/git-dirty-prompt
# http://www.simplisticcomplexity.com/2008/03/13/show-your-git-branch-name-in-your-prompt/
# username@Machine ~/dev/dir[master]$ # clean working directory
# username@Machine ~/dev/dir[master*]$ # dirty working directory
function parse_git_dirty {
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] && echo "*"
}
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/[\1$(parse_git_dirty)]/"