Skip to content

Instantly share code, notes, and snippets.

View tdewin's full-sized avatar

tdewin

View GitHub Profile
@tdewin
tdewin / vcard.txt
Last active August 26, 2023 15:03
QR templates, use if you don't trust online generators
BEGIN:VCARD
VERSION:4.0
FN: John Doe
N:Doe;John;;Dr;
TEL;TYPE=cell:+3221234567
EMAIL;TYPE=work:john.doe@fakeidentity.be
ORG:FakeIdentity
TITLE:Identity Engineering Team Lead
END:VCARD
@tdewin
tdewin / toc.md
Last active September 6, 2023 09:45
TOC openxml that you can use in markdown/pandoc to docx without using --toc and thus insert where you want
<w:sdt>
            <w:sdtPr>
                <w:docPartObj>
                    <w:docPartGallery w:val="Table of Contents"/>
                    <w:docPartUnique/>
                </w:docPartObj>
            </w:sdtPr>
            <w:sdtEndPr>
                <w:rPr>
@tdewin
tdewin / main.go
Last active September 6, 2023 23:18
Prototype xlsx to svg table (pretty complete but code needs cleaning)
package main
import (
"archive/zip"
"encoding/xml"
"flag"
"fmt"
"io/ioutil"
"log"
"strconv"
@tdewin
tdewin / exclude.ps1
Created September 29, 2023 08:47
Exclude files from VSS snapshot with entire computer / volume backup
$reglocation = "HKLM:\SYSTEM\CurrentControlSet\Control\BackupRestore\FilesNotToSnapshot"
$exclusions = @'
$AllVolumes$\TemporaryFiles\*.* /s
C:\backup\exclusions\*.* /s
'@ -split "\n"
for($i=0;$i -lt $exclusions.Count;$i++) {
$e = $exclusions[$i]
Set-ItemProperty -Type MultiString -Path $reglocation -Name ("veeam-{0}" -f $i) -Value $e
}
@tdewin
tdewin / blueprint.sh
Created October 4, 2023 13:00
Postgres checkpoint with kanister blueprint & fingerprint (BlueprintBinding)
Follow kubectl logs to see the immidiate force write
kubectl logs stockdb-postgresql-0 -f
```yaml
cat << 'EOF' | kubectl apply -f -
kind: Blueprint
apiVersion: cr.kanister.io/v1alpha1
metadata:
name: postgresql-hooks
namespace: kasten-io
@tdewin
tdewin / statserver.go
Last active January 5, 2024 14:20
very simple static file server for transporting big files easily
package main
import (
"encoding/json"
"sync"
"crypto/rand"
"crypto/tls"
"flag"
"fmt"
"io/ioutil"
@tdewin
tdewin / sidecar.sh
Last active October 5, 2023 16:26
sidecar injection on sts or deploy with pics
#!/bin/bash
kubectl get sts,deploy -A -o json \
| jq '[.items[] | select(.metadata.namespace as $i | ["kube-system","kasten-io"] | index($i) | not ) ]' \
> wl-with-vol.json
for (( COUNTER=0; COUNTER<$(jq 'length' wl-with-vol.json); COUNTER+=1 )); do
ELEM=$(jq $(printf ".[%d]" $COUNTER) wl-with-vol.json)
@tdewin
tdewin / manage.sh
Last active September 26, 2024 17:33
GOVC wrapper on Mac, install vmrc for remote console and imagemagick for cropping. Useful mainly for a lab
#!/bin/zsh
export PATH=$PATH:/Users/$(whoami)/go/bin/
export GOVC_URL=https://192.168.
export GOVC_USERNAME=root
export GOVC_PASSWORD=Pleaseshareallyourcredentialsongithubnow!
export GOVC_INSECURE=true
export DEF_SSH_USER=root
@tdewin
tdewin / govc-inject-ps.sh
Last active October 6, 2023 19:16
Inject powershell script in VM on ESXi host with govc (require a powershell command to be open, and us-keyboard-layout)
cat <<EOF > data.txt
write-host "All your base, base, base, are belong to us"
write-host "@tdewin"
EOF
VMNAME=vm
govc vm.keystrokes -vm=$VMNAME -s=$(printf "[System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String(\"%s\"))>data.ps1" $(cat data.txt | base64))
govc vm.keystrokes -vm=$VMNAME -c=0x28
@tdewin
tdewin / govc-screenshot.sh
Last active October 12, 2023 11:43
govc screenshot bash/zsh
# use ctrl c to exit loop
VM=myvm
[ ! -z "$(uname -a | grep Darwin)" ] && open $(govc vm.console $VM)
NOW=$(date +%s)
PAUSE=2
while [ 1 -eq 1 ];do