Skip to content

Instantly share code, notes, and snippets.

View MarkTiedemann's full-sized avatar

Mark Tiedemann MarkTiedemann

View GitHub Profile
@MarkTiedemann
MarkTiedemann / pull-all.ps1
Created August 17, 2017 12:25
Git pull all subdirectories
ls -dir | % {
cd "$_"
write-host "~ $_" -foregroundcolor magenta
git pull
cd ..
}
<#
PS dir> .\pull-all.ps1
~ subdir1
@MarkTiedemann
MarkTiedemann / docker-rm-all.ps1
Last active August 23, 2017 02:51
Remove all docker containers and images in Powershell
(docker ps -q -a).split('\n') | % { docker rm $_ }
(docker images -q -a).split('\n') | % { docker rmi $_ }
get-dnsclientserveraddress |
where { $_.InterfaceAlias -like "*(DockerNAT)" } | % {
set-dnsclientserveraddress `
-interfaceindex $_.InterfaceIndex `
-serveraddresses @("8.8.8.8", "8.8.4.4")
}
@MarkTiedemann
MarkTiedemann / hosts.cmd
Last active August 24, 2017 20:13
Manage Windows hosts file from command line
@echo off
powershell -f %~dp0hosts.ps1 %1 %2 %3
@MarkTiedemann
MarkTiedemann / USAGE.md
Created August 31, 2017 15:54
Get build minutes of a Bitbucket repository
λ set BITBUCKET_USERNAME=me
λ set BITBUCKET_PASSWORD=secret
λ buildmins org/repo
42
@MarkTiedemann
MarkTiedemann / setvar.cmd
Created August 31, 2017 23:53
Set command output to env var in batch script
@echo off
:: print help
if "%~1" == "--help" (
type %~dp0setvar.txt
) else (
:: assign output of command to env var
for /f "delims=" %%i in ('%~2') do set %~1=%%i
@MarkTiedemann
MarkTiedemann / k8s-node-status.sh
Created September 13, 2017 14:32
Kubernetes node status
kubectl get nodes -o json | jq ".items[] | {name: .metadata.name, conditions: [.status.conditions[] | {type: .type, status: .status}]}"
document.body.animate(
[
'translateX(-6px)',
'translateX(12px)',
'translateX(-9px)',
'translateX(15px)',
'translateX(-6px)',
]
.map(transform => ({ transform })),
{

If you have cmd open two times, and you wanna use the same directory in both sessions:

  1. Type cd | clip in the first one.
  2. Then alt+tab to the second one.
  3. Type cd and hit ctrl+v.

And you're done (you don't even need to hit enter anymore).

#!/bin/bash
set -o errexit
set -o nounset
set -o pipefail
TEMPLATE='{range .items[*]}{.metadata.name}{";"}{end}'
DEPLOYMENTS=$(
kubectl get deployments --output="jsonpath" --template="$TEMPLATE" \