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
| >>> import math, collections | |
| >>> from reader import * | |
| >>> | |
| >>> reader = make_reader('db.sqlite') | |
| >>> | |
| >>> def word_count_magnitude(text): | |
| ... if not text: | |
| ... return 0 | |
| ... return int(math.log10(len(text.split()))) | |
| ... |
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
| import string | |
| import random | |
| from reader import make_reader, SearchError | |
| reader = make_reader("db.sqlite") | |
| def queries(): | |
| for i in range(256): |
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
| >>> from reader import make_reader | |
| >>> | |
| >>> reader = make_reader('db.sqlite') | |
| >>> reader.add_feed('http://www.hellointernet.fm/podcast?format=rss') | |
| >>> reader.update_feeds() | |
| >>> | |
| >>> entries = list(reader.get_entries(feed='http://www.hellointernet.fm/podcast?format=rss')) | |
| >>> [e.title for e in entries] | |
| ['H.I. #108: Project Cyclops', 'H.I. #107: One Year of Weird', ...] | |
| >>> |
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
| import timeit | |
| import shutil | |
| import textwrap | |
| import functools | |
| import bs4 | |
| # reader 0.18 | |
| 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
| import timeit | |
| import shutil | |
| import textwrap | |
| import functools | |
| import bs4 | |
| # reader 0.18 | |
| 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
| -- fts5 | |
| CREATE VIRTUAL TABLE entries USING fts5( | |
| id UNINDEXED, | |
| content | |
| ); | |
| INSERT INTO entries | |
| VALUES | |
| ('one', 'one'), |
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
| import textwrap | |
| import collections | |
| class BaseQuery: | |
| indent = ' ' | |
| separators = collections.defaultdict( | |
| lambda: ',', | |
| WHERE=' AND', |
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
| CREATE TABLE entries ( | |
| id TEXT NOT NULL, | |
| feed TEXT NOT NULL, | |
| title TEXT, | |
| summary TEXT, | |
| content TEXT, | |
| PRIMARY KEY (id, feed) | |
| ); |
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
| """ | |
| Read commands from stdin, run them in parallel, and send the output to stdout. | |
| Command output looks like: | |
| <command_id> <pid> (stdout|stderr) <original_line> | |
| When a command exits, a single line containing the status is output: | |
| <command_id> <pid> exited <status_code> |