Skip to content

Instantly share code, notes, and snippets.

View residualmind's full-sized avatar
🕹️
i fight for the users

residualmind

🕹️
i fight for the users
View GitHub Profile
tmp_containers_running=$(mktemp) # make tempfile
echo $tmp_containers_running # print tempfile location
docker ps -q >$tmp_containers_running # save ids
# whatever you need to do, for instance:
sudo systemctl restart docker # restart docker
docker start $(<$tmp_containers_running) # restart containers from saved ids
@residualmind
residualmind / k8s-helper-functions
Created June 4, 2019 14:08
k8s-helper-functions
$ which pods
pods () {
kubectl get pod -o name | ag "^pod?/$1" | cut -c 5-
}
$ which pod
pod () {
pods $1 | head -1
}
# in .bashrc/.zshrc
alias note="echo ' - '>>.plan"
alias task="echo ' · '>>.plan"
alias event="echo ' o '>>.plan"
alias n=note
alias t=task
alias e=event
alias planner="vim .plan"
alias plan="echo '\n= .plan =';cat .plan;echo"
#!/bin/bash
# monkeyoperator.sh
# saves precious devops time
# just run at random intervals
hosts="badhost1
badhost2
badhost3
badhost4"
changelog() {
name=$(basename `git rev-parse --show-toplevel`)
lasttag=`git tag -l | sort -V | tail -${1-1} | head -1`
echo "$name - changes since $lasttag:\n"
git --no-pager log "$lasttag.." --pretty=format:' + %s' --reverse;
echo "\n";
}
changelog() {
name=$(basename `git rev-parse --show-toplevel`)
lasttag=`git describe --tags --abbrev=0`
echo "$name - changes since $lasttag:\n"
git --no-pager log "$lasttag.." --pretty=format:' + %s' --reverse;
echo "\n";
}
> obj = {Infinity:Infinity, NaN:'and beyond'}
{ Infinity: Infinity, NaN: 'and beyond' }
> obj[1/0]
Infinity
> obj[0/0]
'and beyond'
@residualmind
residualmind / gist:6204605
Created August 11, 2013 12:05
Simple lazy QA check for ALT, TARGET, TITLE attributes in A and IMG tags. Include and execute globally, then cry or swear // jQuery
function lazyQACheck(){
$("a").each(function(){
if( $(this).attr("title") === undefined || $(this).attr("title") === "" ) {
console.warn("QA: <A> tag with TEXT \"" + $(this).text() + "\" has no TITLE attribute");
}
if( $(this).attr("href") && $(this).attr("target") === undefined && !!(1+$(this).attr("href").indexOf("//")) ) {
console.warn("QA: <A> tag with external HREF "+$(this).attr("href")+" has no TARGET attribute");
}
});
$("img").each(function(){