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 | |
if [[ "${BASH_SOURCE[0]}" != "${0}" ]]; then | |
echo "Fatal: Sourcing detected. Cannot source ${BASH_SOURCE[0]}." | |
return | |
exit 1 | |
fi | |
set -e | |
set -o pipefail | |
script_root="$(cd $(dirname ${BASH_SOURCE[0]}) && pwd)" | |
cd "$script_root" |
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
WITH base AS ( | |
SELECT | |
'{"id": 26770, "name": "hello world"}'::jsonb AS some_json | |
) | |
SELECT | |
pg_typeof(some_json), | |
/* non-compliant, pseudo-JSON */ | |
some_json AS pseudo_json, | |
/* use ::text cast to product compliant JSON */ | |
some_json::text AS compliant_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
from math import floor, log10 | |
def display_sigfig(x, sigfigs=2) -> str: | |
''' | |
Suppose we want to show 2 significant figures. Implicitly we want to show 3 bits of information: | |
- The order of magnitude | |
- Significant digit #1 | |
- Significant digit #2 | |
''' |