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 collections import namedtuple | |
Element = namedtuple('Element', 'symbol, z, weight') | |
ATOMS = { | |
'H': Element('H', 1, 1.008), # Wasserstoff | |
'D': Element('D', 1, 2.0141), # Deuterium | |
'He': Element('He', 2, 4.002602), # Helium | |
'Li': Element('Li', 3, 6.94), # Lithium |
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/python3 | |
# | |
# Purpose: | |
# Use watchdog to monitor a directory. After a certain amount of time without any change | |
# the processing is triggered. | |
# | |
import os.path | |
import time | |
import threading |
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
{ | |
"@context": "http://schema.org/", | |
"@type": "TechArticle", | |
"headline": "Working with systemd timers", | |
"abstract": "A complete overview of systemd timers that covers creating, maintaining, testing, troubleshooting and migrating from cron.", | |
"datePublished": "2023-02-28", | |
"dateModified": "2023-07-25", |
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
No titlepage template for: quote | |
No localization for keycap/keycap in en, using "MISSING" | |
No localization for keycap/keycap in en, using "MISSING" | |
Type error at char 11 in expression in xsl:variable/@select on line 94 column 57 of objects.xsl: | |
XPTY0004 An empty sequence is not allowed as the first argument of array:size() | |
invoked by xsl:iterate at file:/home/tom/repos/GH/tomschr/docbook-xslt3-fo/docbook-xslTNG-2.0.2/xslt/modules/objects.xsl#62 | |
In template rule with match="element(Q{http://docbook.org/ns/docbook}mediaobject)" on line 23 of objects.xsl | |
invoked by xsl:apply-templates at file:/home/tom/repos/GH/tomschr/docbook-xslt3-fo/docbook-xslTNG-2.0.2/xslt/modules/blocks.xsl#20 | |
In template rule with match="element(Q{http://docbook.org/ns/docbook}informalfigure)" on line 17 of blocks.xsl | |
invoked by xsl:apply-templates at file:/home/tom/repos/GH/tomschr/docbook-xslt3-fo/docbook-xslTNG-2.0.2/xslt/modules/sections.xsl#20 |
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
<?xml version="1.0" encoding="UTF-8"?> | |
<!-- | |
Purpose: | |
Process xi:include elements and add xml:base into included root | |
element, pointing to the original file | |
Reason: | |
Neither xmllint nor lxml API provides something to get the origin | |
of an included file. For lxml, see | |
https://mailman-mail5.webfaction.com/pipermail/lxml/20130831/014852.html |
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 child loggers | |
# | |
import logging | |
from logging.config import dictConfig | |
LOGGING_CFG = { | |
"version": 1, |
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 | |
""" | |
Proof-of-concept to retrieve (GET) and store (POST) ratings from | |
documentation URLs similar to doc.suse.com. | |
Requirements | |
------------ | |
* aiohttp | |
* Python >=3.6, preferably a more recent version |
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
# https://learning.oreilly.com/library/view/mastering-object-oriented-python/9781789531367/beafb66d-a1c5-444c-b22d-9ecf0d75e3f5.xhtml | |
from typing import Any, Callable, TypeVar, cast | |
FuncType = Callable[..., Any] | |
F = TypeVar('F', bound=FuncType) | |
def my_decorator(func: F) -> F: | |
... |
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
# Source | |
# Mastering Object-Oriented Python - Second Edition by Steven F. Lott Published by Packt Publishing, 2019 | |
# https://learning.oreilly.com/library/view/mastering-object-oriented-python/9781789531367/c34be237-5ccd-4775-a0b0-ec1f7652f7bc.xhtml | |
# | |
from pathlib import Path | |
# write JSON files: | |
with Path("temp.json").open("w", encoding="UTF-8") as target: | |
json.dump(travel3, target, default=blog_j2_encode) |
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
""" | |
The "ddict" is able to create nested structures. With the help of "defaultdict", | |
it creates arbitrary levels of "dict"-like objects. | |
Run the doctests with: | |
$ python3 -m doctest nested_dict.py | |
>>> d = ddict(a=ddict(b=ddict(c=10)) ) |
NewerOlder