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
def check(): | |
prometheus_url = "http://prometheus.kube-system.svc.cluster.local./api/v1/query" | |
metrics = {"_use_scheduled_time": True} | |
try: | |
container_selector = """{{container_name="{container_name}", pod_name="{pod_name}", namespace="{pod_namespace}"}}""".format(**entity) | |
def request_prometheus_metric(query): | |
params={"query": query.format(container_selector=container_selector)} |
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
default['sshd']['sshd_config']['AuthenticationMethods'] = 'publickey,keyboard-interactive:pam' | |
default['sshd']['sshd_config']['ChallengeResponseAuthentication'] = 'yes' | |
default['sshd']['sshd_config']['PasswordAuthentication'] = 'no' |
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
% docker build -t rust . | |
... | |
# Export the image to tarball, which itself contains tarballs and a manifest.json | |
% docker save -o rust.tar rust | |
# Extract the last layer | |
# tar's -O flag extracts a single entry from the tarball. | |
# The file we want is the last "Layer" in the manifest.json | |
% tar -xf rust.tar -O $(tar -xf rust.tar -O manifest.json | jq -r '.[].Layers[-1]') > curlbash.tar |
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
#!/usr/bin/env bash | |
HOST="???" # address of the vpn | |
LASTPASS_ENTRY="???" # entry under which the password is saved in last pass | |
USERNAME=$(lpass show --sync=auto --username $LASTPASS_ENTRY) | |
PASSWORD=$(lpass show --sync=auto --password $LASTPASS_ENTRY) | |
# escaping the special chars in the password to allow sed-ing it | |
ESC_PWD=$(echo $PASSWORD | sed -e 's/[]\/$*.^[]/\\&/g') |
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
// Please use the package https://github.com/chmike/domain as is it maintained up to date with tests. | |
// checkDomain returns an error if the domain name is not valid. | |
// See https://tools.ietf.org/html/rfc1034#section-3.5 and | |
// https://tools.ietf.org/html/rfc1123#section-2. | |
func checkDomain(name string) error { | |
switch { | |
case len(name) == 0: | |
return nil // an empty domain name will result in a cookie without a domain restriction | |
case len(name) > 255: |
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/sh | |
# | |
# The access this gives you is rather terrifing. Use sparingly. | |
# | |
set -e -x | |
node=$1 | |
trap "kubectl delete pod nodesh-$node" EXIT |
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
// (see the blog post at https://andrewdupont.net/2018/04/27/laundry-spy-part-3-the-software/) | |
// GENERAL CONFIG | |
// ============== | |
// The baud rate of serial output for logging. If necessary, change the baud | |
// rate in your Serial Monitor to match this. | |
#define BAUD_RATE 115200 | |
// The name by which this device will identify itself over mDNS (Bonjour). |
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 ( | |
"context" | |
"flag" | |
"fmt" | |
"log" | |
"net/http" | |
"os" | |
"os/signal" |
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
awk -F: 'END {print "uid:"u" gid:"g" groups:"gg}{if($1=="Uid"){split($2,a," ");u=a[1]}if($1=="Gid"){split($2,a," ");g=a[1]}if($1=="Groups"){gg=$2}}' /proc/self/status |
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
# Gawk version | |
# Remote | |
grep -v "rem_address" /proc/net/tcp | awk '{x=strtonum("0x"substr($3,index($3,":")-2,2)); for (i=5; i>0; i-=2) x = x"."strtonum("0x"substr($3,i,2))}{print x":"strtonum("0x"substr($3,index($3,":")+1,4))}' | |
# Local | |
grep -v "rem_address" /proc/net/tcp | awk '{x=strtonum("0x"substr($2,index($2,":")-2,2)); for (i=5; i>0; i-=2) x = x"."strtonum("0x"substr($2,i,2))}{print x":"strtonum("0x"substr($2,index($2,":")+1,4))}' | |
# No Gawk | |
# Local | |
grep -v "rem_address" /proc/net/tcp | awk 'function hextodec(str,ret,n,i,k,c){ |