CF_TOKEN="..."
curl -X GET "https://api.cloudflare.com/client/v4/user/tokens/verify" \
-H "Authorization: Bearer $CF_TOKEN"
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 | |
set -euo pipefail | |
API_BASEURL="https://api.cloudflare.com/client/v4" | |
CF_TOKEN="$(cut -d '=' -f2 < $HOME/.cloudflare.auth | xargs)" | |
INTERNAL_IP="$(tailscale ip -4)" | |
HOSTNAME="home.sib.li" | |
ZONE_NAME="$(echo "$HOSTNAME" | rev | cut -d '.' -f1,2 | rev)" |
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 '%(%Y-%m-%d %H:%M:%S)T\n' -1 | |
# Note rPi CPU and GPU are on the same chip, and GPU don't hanve any separate temperature sensor | |
# vcgencmd and sysfs provide the same data | |
cpu_temp_sysfs=$(</sys/class/thermal/thermal_zone0/temp) | |
echo "vcgencmd => $(vcgencmd measure_temp | grep -o -E '[[:digit:]].*')" | |
echo "sysfs => $((cpu_temp_sysfs/1000))'C" |
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
const multipliers = new Map(); | |
const multiplications = new Set(); | |
for (let i = 0; i < 10; i++) { | |
for (let j = i; j < 10; j++) { | |
const res = i * j; | |
multiplications.add(res); | |
multipliers.set( | |
i.toString() + j.toString(), | |
res, |
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
# List all projects with assigned billing and status | |
gcloud beta billing accounts list --format 'value(ACCOUNT_ID)' | while read -r BILLING_ACCOUNT_ID; do | |
gcloud beta billing projects list --billing-account "$BILLING_ACCOUNT_ID" --format 'value(PROJECT_ID, BILLING_ACCOUNT_ID, BILLING_ENABLED)' | |
done | |
# Check if billing is enabled for Project Id | |
GOOGLE_CLOUD_PROJECT=${1:-$(gcloud config list --format 'value(core.project)')} | |
function isBillingEnabled() { | |
GOOGLE_CLOUD_PROJECT=$1 |
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 | |
# Exit script when command fails | |
set -o errexit | |
# Exit when script tries to use undeclared variable | |
set -o nounset | |
# Exit if piped command fails | |
set -o pipefail | |
# aka: | |
# set -euo pipefail |
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
find . -name 'node_modules' -type d -not -path '*/node_modules/*/node_modules' -exec du -hs '{}' \; | |
# alias find_node_modules="find . -name 'node_modules' -type d -not -path '*/node_modules/*/node_modules' -exec du -hs '{}' \;" | |
# Same with dist, excludiong vendored thirdparty-js : | |
# find . -name 'dist' -type d -not -path '*/thirdparty-js/*/dist' -exec du -hs '{}' \; | |
# find . -name 'node_modules' -type d -not -path '*/node_modules/*/node_modules' -not -path '*/thirdparty-js/*/node_modules' -exec du -hs '{}' \; |
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 | |
# https://github.com/siberex/cancelot | |
# | |
# To download the latest version (if you trust running random bash scripts from the internets!): | |
# curl -L https://gist.github.com/siberex/bb0540b208019382d08732cc6dd59007/raw -o cancelot.sh && chmod +x cancelot.sh | |
# | |
# Provides automation for cancelling Cloud Builds | |
# Use as a first step to cancel previous builds currently in progress or queued for the same branch name and trigger id. | |
# Similar to: https://github.com/GoogleCloudPlatform/cloud-builders-community/tree/master/cancelot |
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
# App Engine: List all project regions and mapped domains | |
# Effectively: | |
# gcloud projects list --format 'get(PROJECT_ID)' | |
# gcloud app describe --project "$projectId" --format 'get(locationId)' | |
# gcloud app domain-mappings list --project "$projectId" --format 'get(ID)' | xargs | sed 's/ /, /g' | |
printf "%s\t%s\t%s\n" "ProjectId" "Region" "Domains" | |
gcloud projects list --format 'get(PROJECT_ID)' | while read -r projectId; do | |
region=$(gcloud app describe --project "$projectId" --format 'get(locationId)' 2>/dev/null || echo 'N/A') |
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 | |
# Retrieves list of files larger than 600 MB from linux distros mirror | |
# Saves maximum 10 random links for each distro in the output.txt file | |
# Usage: | |
# gen_honeypot_urls.sh | |
# or: | |
# gen_honeypot_urls.sh /path/to/out.txt | |
# Exit script when command fails |
NewerOlder