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
# TODO: Thread & async safety | |
import sys | |
import time | |
from collections.abc import Callable | |
if sys.version_info >= (3, 11): | |
from typing import Self | |
else: | |
from typing_extensions import Self |
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
# -*- coding: utf-8 -*- | |
# Copyright © 2022 by Gregory Werbin | |
# | |
# Permission to use, copy, modify, and/or distribute this software for any | |
# purpose with or without fee is hereby granted, provided that the above | |
# copyright notice and this permission notice appear in all copies. | |
# | |
# THE SOFTWARE IS PROVIDED “AS IS” AND ISC DISCLAIMS ALL WARRANTIES WITH REGARD | |
# TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND |
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
import sys | |
from collections import UserString | |
from collections.abc import Callable, Mapping | |
from typing import Any, ParamSpec, TypeVar, overload | |
if sys.version_info >= (3, 11): | |
from typing import Self, Unpack | |
else: | |
from typing_extensions import Self, Unpack |
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
import unicodedata | |
def is_whitespace(c: str) -> bool: | |
"""Detect if a character is "whitespace". | |
As of 3.10, this is how CPython defines "whitespace" for string operations like `str.split`. | |
Sources: | |
* https://github.com/python/cpython/blob/v3.10.4/Objects/unicodeobject.c#L311-L340 | |
* https://github.com/python/cpython/blob/v3.10.4/Tools/unicode/makeunicodedata.py#L420-L422= |
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 zsh | |
setopt \ | |
err_exit \ | |
pipe_fail \ | |
warn_create_global \ | |
warn_nested_var \ | |
no_unset | |
version='1.0.0' |
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
module DoubleStuff | |
%foreignImport "scheme,chez:(double-stuff utils)" | |
"python:double_stuff" | |
-- "python:double_stuff,*" | |
namespace Exact | |
%foreign "scheme,chez:idris-fl=-2" | |
"python:double_stuff.idris_fleq2" | |
-- "python:idris_fleq2" |
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/sh | |
### Bootstrap build from an existing Idris 2 compiler. | |
set -eux | |
cd idris2 | |
## Build and install to final location, using whatever `idris2` is already in PATH. | |
install_prefix="${XDG_MISC_HOME:-$HOME/.local/opt}/idris2" |
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 zsh | |
emulate zsh | |
setopt err_exit pipe_fail warn_create_global warn_nested_var no_unset | |
if (( ${#@} == 0 )); then | |
data="$(cat)" | |
elif (( ${#@} == 1)); then | |
case $1 in | |
-) data="$(cat)" ;; |
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
"""Demo of logging in a multi-processing context. | |
Based on the Python "Logging Cookbook": | |
https://docs.python.org/3/howto/logging-cookbook.html#logging-to-a-single-file-from-multiple-processes | |
Note on `QueueListener`: | |
The main difference between the Cookbook example and this demo is that I use | |
the `QueueListener` convenience class, whereas they write a bespoke | |
`listener_process` function which does more or less the same thing as |
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
module TaxExample | |
import Data.So | |
-- Can't use `total` as a variable name! Boo :( | |
%default total | |
-- NOTE: Weird things happen when you use the same name in both a record | |
-- parameter and a record field name. Don't do it. |