The following compares the output of several creative hash functions designed for human readability.
sha1's are merely used as arbitrary, longer, distributed input values.
| input | 1 word output | 2 word output | 3 word output |
|---|
| #!/usr/bin/env python3 | |
| # -*- coding: utf-8 -*- | |
| # See : https://github.com/docker/docker-py | |
| import docker | |
| import argparse | |
| import pathlib | |
| from collections import deque | |
| import time | |
| import datetime |
| >>> from collections import namedtuple | |
| >>> d = {"name": "joe", "age": 20} | |
| >>> d | |
| {'age': 20, 'name': 'joe'} | |
| >>> d_named = namedtuple("Employee", d.keys())(*d.values()) | |
| >>> d_named | |
| Employee(name='joe', age=20) | |
| >>> d_named.name | |
| 'joe' |
The following compares the output of several creative hash functions designed for human readability.
sha1's are merely used as arbitrary, longer, distributed input values.
| input | 1 word output | 2 word output | 3 word output |
|---|
| def dict_to_redis_hset(r, hkey, dict_to_store): | |
| """ | |
| Saves `dict_to_store` dict into Redis hash, where `hkey` is key of hash. | |
| >>> import redis | |
| >>> r = redis.StrictRedis(host='localhost') | |
| >>> d = {'a':1, 'b':7, 'foo':'bar'} | |
| >>> dict_to_redis_hset(r, 'test', d) | |
| True | |
| >>> r.hgetall('test') |
| # I place this in the public domain | |
| # This only handles non-nested lists, emphasis, headings and horizontal rules (which are converted to page breaks) | |
| # Sufficient for converting Markdown generated HTML to reportlab flowables... | |
| import xml.sax as sax | |
| def html_to_rl(html, styleSheet): | |
| elements = list() |
| import redis | |
| import threading | |
| class Listener(threading.Thread): | |
| def __init__(self, r, channels): | |
| threading.Thread.__init__(self) | |
| self.redis = r | |
| self.pubsub = self.redis.pubsub() | |
| self.pubsub.subscribe(channels) | |