This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func getPodNamespace() string { | |
const namespaceEnvVar = "POD_NAMESPACE" | |
const namespaceFile = "/var/run/secrets/kubernetes.io/serviceaccount/namespace" | |
namespaceName := os.Getenv(namespaceEnvVar) | |
if namespaceName != "" { | |
return namespaceName | |
} | |
namespaceNameBytes, err := os.ReadFile(namespaceFile) | |
if err != nil { | |
log.Printf("[ERROR] '%s' environment variable not specified and could not read file '%s': '%#v'", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"crypto/hmac" | |
"crypto/sha256" | |
"encoding/binary" | |
"encoding/hex" | |
"flag" | |
"fmt" | |
"log" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ( | |
"io" | |
"regexp" | |
"go.uber.org/zap" | |
"go.uber.org/zap/zapcore" | |
) | |
// Replaces hashicorp/logutils by directing Golang's log package to Zap but | |
// extracting the log level from any `[$severity]` pattern in the message. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
param ( | |
[int]$drag = 4 | |
) | |
# https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-systemparametersinfoa | |
$importDefinition= @' | |
[DllImport("user32.dll", EntryPoint = "SystemParametersInfo")] | |
public static extern bool SystemParametersInfo(uint uiAction, uint uiParam, uint pvParam, uint fWinIni); | |
'@ | |
$importType = Add-Type -MemberDefinition $importDefinition -Name WinAPICall -Namespace SetDragSystemParametersInfo –PassThru |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
cat <<'EOF' >.dockerfile.content-tag | |
FROM busybox:1 | |
WORKDIR /src/ | |
ENTRYPOINT ["/bin/sh", "-c", "find . -type f \\! -path ./.dockerfile.content-tag -exec sha256sum -b {} +"] | |
COPY . /src/ | |
EOF | |
iid=$( docker image build -q -f .dockerfile.content-tag . ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
print_usage () { | |
printf 'Usage: kubectl evict -n <namespace> <pod>\n' >&2 | |
} | |
main () { | |
if [ "-n" != "$1" ] && [ "--namespace" != "$1" ] | |
then | |
print_usage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apt-get install -y \ | |
apt-transport-https \ | |
binutils \ | |
build-essential \ | |
python-pip \ | |
socat \ | |
sysstat \ | |
traceroute \ | |
unzip \ | |
zip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
while read -r commit_hash | |
do | |
message=$( | |
git cat-file commit "${commit_hash}" | | |
sed '1,/^$/d' | |
) | |
if [ "${message:0:5}" = 'Merge' ] || [ "${message:0:6}" = 'Revert' ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
printf '%s,%s,%s,%s,%s,%s,%s,%s\n' \ | |
'dir' 'usage_in_bytes' \ | |
'cache' 'total_cache' \ | |
'rss' 'total_rss' \ | |
'rss_huge' 'total_rss_huge' | |
cd /sys/fs/cgroup/memory/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
printf '%s,%s,%s,%s,%s,%s,%s,%s\n' \ | |
'dir' 'usage_in_bytes' \ | |
'cache' 'total_cache' \ | |
'rss' 'total_rss' \ | |
'rss_huge' 'total_rss_huge' | |
cd /sys/fs/cgroup/memory/ |
NewerOlder