This file contains hidden or 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
| """ | |
| Script for turning a Wikibooks book into a single HTML file | |
| that can be converted to other formats by Calibre. | |
| Currently hardcoded for https://en.wikibooks.org/wiki/Professionalism, | |
| "Cases and Ideas in Professional Ethics". | |
| """ | |
| import re | |
| import time |
This file contains hidden or 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
| """ | |
| Minimal UFW pyinfra operation. | |
| ufw.ufw( | |
| name="firewall", | |
| enabled=True, | |
| rules=[ | |
| "allow 22/tcp", | |
| "allow 80/tcp", | |
| "allow 443/tcp", |
This file contains hidden or 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
| """ | |
| local certbot + remote challenge proof of concept, using --manual-auth-hook[1] | |
| a pyinfra operation using this may do something like: | |
| if cert not on server: | |
| if cert not locally: | |
| get_certificate(domain) | |
| yield "copy cert to server" command | |
This file contains hidden or 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
| """ | |
| entry_dedupe prototype that supports multiple heuristics for finding potential duplicates. | |
| see https://github.com/lemon24/reader/issues/371 for details. | |
| """ | |
| import itertools, re | |
| from math import * | |
| from urllib.parse import urlparse | |
| from reader import make_reader |
This file contains hidden or 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
| """ | |
| Say you have a SQLite connection to database `main` | |
| with attached database `attached`. | |
| Does a long insert on the `attached` database in a similar connection | |
| lock the `main` database in this connection? | |
| No, it only locks `attached`. | |
| Output: |
This file contains hidden or 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
| """ | |
| ...in which we use property-based / model-based testing to find | |
| an eventually consistent way of synchronizing entries | |
| from the main reader storage to an (unrelated) search index, | |
| without coupling the storage and search with transactions / triggers. | |
| A real model checker like TLA+ or Alloy may have been a better tool for this, | |
| but I don't know how to use them. | |
| This is the first step in https://github.com/lemon24/reader/issues/323. |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or 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
| """ | |
| Distributed key-value store prototype, with no kind of consistency. | |
| --- | |
| A demo (from before we had bootstapping): https://asciinema.org/a/616231 | |
| On one machine: | |
| >>> d = dkv.DKV() |
This file contains hidden or 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
| """ | |
| measure how much time it takes for requests to make many localhost requests | |
| try do so some optimizations | |
| initial results on on an old mac: | |
| $ python req.py http 100 | |
| itrg 0.3003 |
This file contains hidden or 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
| """ | |
| stricter typing | |
| for https://github.com/lemon24/reader/blob/master/src/reader/_parser.py | |
| for https://github.com/lemon24/reader/issues/271 | |
| """ | |
| from typing import * | |
| import io | |
| from dataclasses import dataclass | |
| from random import choice |
NewerOlder