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
^\b([a-zA-Z0-9][\.\-_a-zA-Z0-9]+)\b@\b([a-zA-Z0-9][\-_a-zA-Z0-9]+)\b\.{1}\b(.*)\b$ | |
# | |
# not massively well tested, or spectacular, but it works for generally agreeable, mostly typical [email protected] style addresses | |
# | |
# | |
# passing | |
# | |
[email protected] |
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
def day_ordinal(day: int) -> str: | |
"""For a given day of the month, return its ordinal 📅""" | |
if 4 <= day <= 20 or 24 <= day <= 30: | |
return "th" | |
else: | |
return ["st", "nd", "rd"][day % 10 - 1] | |
for day in range(1, 31+1): | |
print(f"{day}{day_ordinal(day)}") |
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
# | |
# Specifically linked to eu-west-2 so tweak as necessary | |
# | |
^arn:aws:sns:eu-west-2:\d{12}:([\w\-]{1,256}|[\w\-]{1,251}\.fifo)$ | |
# | |
# passing | |
# | |
arn:aws:sns:eu-west-2:123456789012:MyTopic | |
arn:aws:sns:eu-west-2:123456789012:mytopic |
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
# | |
# hat tip: https://stackoverflow.com/users/173003/aristide via https://stackoverflow.com/a/65063284/259122 | |
# | |
# shamelessly copied and included here for easier self-location! | |
# | |
for i in range(5): | |
print(f"{i} bottle{'s'[:i^1]} of beer.") |
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
<!DOCTYPE html> | |
<html lang="en-GB"> | |
<head> | |
<title>🖖</title> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
<!-- favicon idea stolen! https://twitter.com/LeaVerou/status/1241619866475474946 --> | |
<link rel="icon" href="data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 100 100%22><text y=%22.9em%22 font-size=%2290%22>📺</text></svg>"> | |
<style> | |
html, body { |
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
# | |
# Specifically linked to eu-west-2 so tweak as necessary | |
# | |
arn:aws:s3:eu-west-2:\d{12}:(?=.{3,63}$)(?!(\d+\.)+\d+$)((([a-z0-9]|[a-z0-9][a-z0-9\-]*[a-z0-9])\.)*([a-z0-9]|[a-z0-9][a-z0-9\-]*[a-z0-9])$) | |
# | |
# passing | |
# | |
arn:aws:s3:eu-west-2:123456789012:abc | |
arn:aws:s3:eu-west-2:123456789012:abcd |
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 logging | |
import os | |
log_level = os.environ['LOG_LEVEL'] if 'LOG_LEVEL' in os.environ else 'INFO' | |
logging_levels = {"DEBUG": logging.DEBUG, "INFO": logging.INFO, "WARNING": logging.WARNING, "ERROR": logging.ERROR, "CRITICAL": logging.CRITICAL} # https://docs.python.org/3/library/logging.html#levels | |
logging_level = logging_levels[log_level] if log_level in logging_levels else logging.INFO | |
logger = logging.getLogger() | |
logger.setLevel(logging_level) |
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
# | |
# Trivial script to explore only using built-in Python 3 modules to establish a connection to | |
# a host that issues certs signed by a CA that isn't well known... | |
# | |
# It does require that the root cert is available, so primarily an enterprise that has an | |
# internal or private CA and signs server certs with that... | |
# | |
import urllib.request | |
import ssl |