This file contains hidden or 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
# This will generate a monospaced progress bar with a progress percentage displayed in the center of it | |
# Usage: progress-bar <percentage> <width> | |
# Example output: "———————— 80% —————— " | |
progress-bar() { | |
local percentage=$1 | |
local width=$2 | |
local fill_bars; fill_bars=$(( width * percentage / 100 )) | |
local fill_spaces; fill_spaces=$(( width - fill_bars )) | |
local bar="" |
This file contains hidden or 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 | |
# | |
# Automatically updates the IP addresses for the ingress rules for SSH access | |
# at my home proxy instance on Vultr | |
# | |
# Requires: jq, curl, dig | |
config() { | |
# Define your Vultr API Key | |
export VULTR_API_KEY=YOUR-VULTR-API-KEY |
This file contains hidden or 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
// Here after the $auth is properly initialized, we add the idToken as part of the Authorization | |
// header sent to our API, as it is authenticatable by using the IDToken (JWT), not the AuthToken. | |
$axios.interceptors.request.use((config) => { | |
config.headers['Authorization'] = `Bearer ${$auth.strategy.idToken.get()}` | |
return config | |
}) | |
// By default, axios request interceptors are executed in the order they are added in the | |
// interceptors stack. At this point on runtime, Nuxt Auth has already injected an interceptor | |
// that adds an Authorization token to the requests, so we are unable to override it unless we |
This file contains hidden or 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
export default function ({ $axios }) { | |
// Because API is always considered as a cross-domain call, the default | |
// XSRF feature available on axios will not work for us, because they use | |
// cookies and cookies aren't readable in cross-domains. Instead we must | |
// rely on having CSRF sent on every header request by the backend, and | |
// then we store that value to send on the next subsequent request. | |
// | |
// See: https://github.com/axios/axios#interceptors | |
$axios.interceptors.request.use((config) => { | |
if (!config.method.includes('get', 'head', 'options')) { |
This file contains hidden or 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
# This is useful for loading a .env file and ensuring you don't override the | |
# environment variables already set. | |
# | |
# Usage: load-env-file filename.env | |
load-env-file() { | |
local env_file=$1 | |
# Save a reference of all existing variables | |
while IFS= read -rd $'\0' var; do | |
name="${var%%=*}" |
This file contains hidden or 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 log | |
import ( | |
"context" | |
"log/slog" | |
"os" | |
"time" | |
"github.com/charmbracelet/lipgloss" | |
"github.com/charmbracelet/log" |
OlderNewer