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
| """Fetch an Okta access token via authorization code + PKCE flow. | |
| Caches the token (and refresh token) in ~/.okta-token/credentials.json. | |
| Refreshes automatically when expired. Opens a browser for consent when needed. | |
| Configuration is stored in ~/.okta-token/config.json. On first run, the user | |
| is prompted to fill in the details interactively. | |
| Usage: | |
| # Print a valid access token (refreshing or re-authing as needed): |
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
| # /// script | |
| # requires-python = ">=3.13" | |
| # dependencies = [ | |
| # "matplotlib>=3.10.8", | |
| # "numpy>=2.4.2", | |
| # ] | |
| # | |
| # /// | |
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 | |
| ALLOWED_VALUES=("$@") | |
| while IFS='=' read -r key value; do | |
| [[ -z "$key" || "$key" =~ ^# ]] && { echo "$key"; continue; } | |
| if [ "${#ALLOWED_VALUES[@]}" -eq 0 ]; then | |
| echo "$key=$value" | |
| continue |
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
| FROM alpine:latest AS cert-init | |
| RUN apk add openssl | |
| WORKDIR /root/ssl | |
| RUN openssl req -x509 -nodes -newkey rsa:2048 \ | |
| -keyout key.pem \ | |
| -out cert.pem \ | |
| -days 365 \ | |
| -sha256 \ | |
| -subj "/CN=localhost" \ | |
| -addext "subjectAltName=DNS:localhost,IP:127.0.0.1" |
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
| """Utility script to export the OpenAPI spec from a FastAPI service. | |
| Usage: | |
| python3 fastapi2openapi path.to.module:app -C root/of/package --file openapi.yaml | |
| Where the unnamed argument is the location of the app (the module:app_variable). -C is the working directory to import from. And --file is the file to output. | |
| Note that the output file will be relative to the current working directory and not the location in -C. | |
| """ |
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
| # Docker compose file for testing the build process locally | |
| services: | |
| frontend: | |
| container_name: frontend | |
| build: | |
| context: . | |
| args: | |
| - NEXT_PUBLIC_LOCAL=http://localhost:8080 | |
| ports: | |
| - "3000:3000" |
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
| # /// script | |
| # requires-python = ">=3.11" | |
| # dependencies = [ | |
| # "pydantic", | |
| # "fastapi", | |
| # "uvicorn[standard]", | |
| # ] | |
| # /// | |
| import datetime |
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
| """ | |
| Live utility for converting `.model_validate({...})` calls into | |
| model constructor calls with snake_case keyword arguments. | |
| The module watches itself for changes, reloads on save, transforms | |
| the code in `SAMPLE` and copies it to the clipboard. | |
| """ | |
| import importlib.util | |
| import os |
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
| def _show_commands(): | |
| """Print the help for each of the functions.""" | |
| import inspect | |
| import tokenize | |
| import scripts as module | |
| def get_docs(fns: dict[str, str]) -> dict[str, str]: | |
| result = {} |
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
| param($DURATION) | |
| $_POS = $DURATION.IndexOf(":") | |
| $MINS = $DURATION.SubString(0, $_POS) | |
| $SECS = $DURATION.SubString($_POS + 1, $DURATION.Length - [Int64]$_POS - 1) | |
| $TOTAL_SECS = (([Int64]$MINS) * 60) + $SECS | |
| $REMAINING_SECS = $TOTAL_SECS | |
| while ($REMAINING_SECS -gt 0) { | |
| Write-Host -NoNewLine "`rSleeping after $REMAINING_SECS seconds" | |
| Start-Sleep -s 1 | |
| $REMAINING_SECS-- |
NewerOlder