Using Python's built-in defaultdict we can easily define a tree data structure:
def tree(): return defaultdict(tree)That's it!
| # From "A simple unix/linux daemon in Python" by Sander Marechal | |
| # See http://stackoverflow.com/a/473702/1422096 and http://web.archive.org/web/20131017130434/http://www.jejik.com/articles/2007/02/a_simple_unix_linux_daemon_in_python/ | |
| # | |
| # Modified to add quit() that allows to run some code before closing the daemon | |
| # See http://stackoverflow.com/a/40423758/1422096 | |
| # | |
| # Modified for Python 3 (see also: http://web.archive.org/web/20131017130434/http://www.jejik.com/files/examples/daemon3x.py) | |
| # | |
| # Joseph Ernest, 20200507_1220 |
| import re | |
| ip_middle_octet = u"(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5]))" | |
| ip_last_octet = u"(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))" | |
| regex = re.compile( | |
| u"^" | |
| # protocol identifier | |
| u"(?:(?:https?|ftp)://)" | |
| # user:pass authentication |
| # 30 minutes Lisp in Ruby | |
| # Hong Minhee <http://dahlia.kr/> | |
| # | |
| # This Lisp implementation does not provide a s-expression reader. | |
| # Instead, it uses Ruby syntax like following code: | |
| # | |
| # [:def, :factorial, | |
| # [:lambda, [:n], | |
| # [:if, [:"=", :n, 1], | |
| # 1, |
Using Python's built-in defaultdict we can easily define a tree data structure:
def tree(): return defaultdict(tree)That's it!
Service Mesh
| // Use Gists to store code you would like to remember later on | |
| console.log(window); // log the "window" object to the console |
| sync-settings |