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
| # Include this in your shell *rc file (e.g. .bashrc, .zshrc, etc). | |
| # Update the folder name to your convention. | |
| # This uses venv as the virtual environment name, but if you use .venv, change it in the script. | |
| # Auto-activate virtual environment for any project with a venv directory | |
| function chpwd() { | |
| # Function to find venv directory in current path or parent directories | |
| local find_venv() { | |
| local dir="$PWD" |
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
| import hashlib | |
| import os | |
| from typing import Optional | |
| from pyramid.request import Request | |
| from pyramid.response import Response | |
| def build_cache_id( | |
| filename: str, |
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
| # Global settings | |
| [global] | |
| exclude = ["node_modules", "build", "dist"] | |
| respect_gitignore = true | |
| # Disable specific rules | |
| disable = ["MD013", "MD033", "MD045", "MD025", "MD042", "MD041", "MD024", "MD042", "MD052", "MD036", "MD029", "MD026", "MD002", "MD014"] | |
| # MD013 - Line length: Allows lines longer than the default limit for better readability in technical docs | |
| # MD033 - Inline HTML: Permits HTML tags within markdown for enhanced formatting when needed | |
| # MD045 - Images should have alternate text: Allows images without alt text (useful for decorative images) |
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
| # See details about Turnstile at https://blog.cloudflare.com/turnstile-private-captcha-alternative/ | |
| from typing import Optional | |
| import pydantic | |
| import requests | |
| cloudflare_secret_key: Optional[str] = None | |
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
| import datetime | |
| import sys | |
| from typing import Optional | |
| import colorama | |
| import pyramid.config | |
| from loguru import logger | |
| from pyramid.request import Request | |
| from pyramid.response import Response |
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
| import datetime | |
| import random | |
| from typing import List | |
| def main(): | |
| random.seed(172) | |
| count = 1_000_000 | |
| data = build_data(count) | |
| run_with_except(data) |
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
| # Short usage example in form post handler on the server: | |
| def form_post_handler(): | |
| turnstile_response = form_dict.get('cf-turnstile-response') | |
| validation_response = turnstile.validate(turnstile_response, get_client_ip()) | |
| if not validation_response.success: | |
| # Handle the error | |
| ... | |
| # All is good from here out... |
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 pathlib import Path | |
| # Creates a file watcher that runs `python build_assets.py`, a utility based on | |
| # webassets package whenever a css or js file is edited. It bundles a bunch of | |
| # our CSS files into a single minified one and does the same for our JS files. | |
| def main(): | |
| # Only import this if we run it, don't let the webframework try to pull it in prod. | |
| import livereload.server |
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
| # requires the uvloop package | |
| import asyncio | |
| import threading | |
| import time | |
| import uuid | |
| from typing import Any, Coroutine | |
| import uvloop |
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
| // ************************************************************************* | |
| // server-hot-reload.js v1.0.5 | |
| // | |
| // Server-side hot reload check by Michael Kennedy (https://mkennedy.codes). | |
| // Released under the MIT open source license, 2023. | |
| // | |
| // When the contents of the page change in any way, the page will be reloaded. | |
| // | |
| // Usage: | |
| // |
NewerOlder