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
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
#!/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
# 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
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 | |
set -euo pipefail | |
# https://www.jetbrains.com/help/idea/shared-indexes.html | |
# USAGE: | |
# idea.indexes.sh /path/to/project/dir | |
CDN_ROOT="$HOME/_idea_cdn" | |
mkdir -p "$CDN_ROOT" |
let i = 0,
spin = () => process.stdout.write(` ${[...'⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏'][i++ % 10]}\r`),
stop = (id => () => clearInterval(id))(setInterval(spin, 100));
And I simply could not resist from sticking generator in it:
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 | |
# Usage: _setup_gcloud.sh [PROJECT_ID] | |
set -euo pipefail | |
BASEDIR="$( | |
cd "$(dirname "$0")" || true | |
pwd -P | |
)" |
let input = await fetch('https://adventofcode.com/2019/day/1/input').then(r => r.text());
input = input.split('\n').filter(Boolean);
// Part 1
input = input.split('\n').map(v => parseInt(v));
for (let i = 0; i < input.length; i++) {
const a = input[i];
for (let j = i + 1; j < input.length; j++) {
NewerOlder