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
# This code is a verbatim excerpt from the Jinja2 library that I'm preserving in a Gist for posterity | |
# https://github.com/pallets/jinja/blob/5b498453b5898257b2287f14ef6c363799f1405a/jinja2/debug.py | |
# -*- coding: utf-8 -*- | |
""" | |
jinja2.debug | |
~~~~~~~~~~~~ | |
Implements the debug interface for Jinja. This module does some pretty | |
ugly stuff with the Python traceback system in order to achieve tracebacks |
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 -o xtrace | |
set -o errexit | |
set -o errtrace | |
set -o nounset | |
set -o pipefail | |
SCRIPTNAME="$0" | |
HELP_TEXT=" |
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
""" | |
Example of a pluginized architecture breaking up a large app | |
with complex behavior (ArchiveBox), into a series of steps | |
that plugins can hook into. | |
(read from the bottom to top to get a quick overview) | |
""" | |
import re | |
import json |
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
function getUrlParams(search) { | |
const hashes = search.slice(search.indexOf('?') + 1).split('&') | |
const params = {} | |
hashes.map(hash => { | |
const [key, val] = hash.split('=') | |
params[key] = decodeURIComponent(val) | |
}) | |
return params | |
} |
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 | |
# This is a script that provides infinite history to get around Alfred's 3-month limit. | |
# It works by regularly backing up and appending the items in the alfred db to a | |
# sqlite database in the user's home folder. It also provides search functionality. | |
# https://www.alfredforum.com/topic/10969-keep-clipboard-history-forever/?tab=comments#comment-68859 | |
# https://www.reddit.com/r/Alfred/comments/cde29x/script_to_manage_searching_backing_up_and/ | |
# Example Usage: | |
# alfred-clipboard.sh backup |
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
# This implements a SafeNumber class which wraps Decimal and Fraction to warn | |
# when infix math or comparison operators may cause dangerous implicit type conversion. | |
# | |
# Implicit type conversion when using operators is sneaky with Decimal/Fraction: | |
# >>> Fraction(10) == 10.0000000000000001 | |
# True | |
# | |
# But with SafeNumber, this throws an error to protect against this scenario: | |
# >>> SafeNumber(10) == 10.0000000000000001 | |
# Traceback (most recent call last): |
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 python3 | |
# asymptotic_progress_bar.py | |
# MIT License © 2021 | |
# | |
# A pretty non-blocking python progress bar timer that fills up asymptotically until you stop it. | |
# Good for when you don't know how long a task is going to take (up to some max timeout), | |
# but you want it to feel fast and accurate / not stuck the whole time. | |
# ████████████████████ 0.9% (1/60sec) | |
# useful for animating e.g. file copy progress, download progress, package install progress, etc. | |
# |
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 | |
# Requires: ffmpeg, exiftool (install via apt/brew first) | |
# Usage: | |
# $ cd ~/Videos | |
# $ ./compress_videos.sh | |
# [+] Converting all .mp4 files in ~/Videos to .x265.mp4 files... | |
# - √ GP013838.mp4 (2.5GB) -> GP013838.x265.mp4 (142MB) | |
# - √ ... | |
# [√] Done converting all .mp4 files in $PWD. |
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
# Example database container setups for PostgreSQL, MariaDB, Redis, Memcached, MongoDB, Neo4j, Hasura GraphQL, CockroachDB, and TiDB in Docker Compose | |
# https://gist.github.com/pirate/1fafaa18a47254f388aa5c0f79f7d263 | |
# Goes well with these docker-compose networking/ingress container examples: | |
# https://gist.github.com/pirate/1996d3ed6c5872b1b7afded250772f7c | |
version: '2.4' | |
services: | |
postgres: |
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
""" | |
This is an extended HTTP response class for Django >=2.0 that adds lots of fancy features. | |
It's most useful when needing to accellerate slow view functions that return templates, | |
but it can be used anywhere where you need to return an HTTPResponse() or render(...). | |
It works by subclassing the builtin Django HttpResponse and StreamingHttpResponse, | |
and adding improvements in many areas, including functionality, speed, and security. | |
The most up-to-date version of this code can be found here: |