View gist:2910aac6cdeb21eea29813289117b377
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
[tool.poetry] | |
name = "ai-worker" | |
version = "0.1.0" | |
description = "api server that posts capabilities, and accepts jobs" | |
authors = ["erik aronesty <erik@q32.com>"] | |
license = "MIT" | |
readme = "README.md" | |
packages = [{include = "ai_worker"}] | |
[tool.poetry.dependencies] |
View test_unique_queue.py
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
class TestUniqueQueue(unittest.TestCase): | |
def test_basic(self): | |
q = util.UniqueQueue() | |
for i in range(100): | |
q.put(i) | |
res = set(q) | |
for i in range(100): |
View future_wait_queue.py
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
class FutureWaitQueue: | |
"""Wait for futures without making an infinite list. | |
Any exceptions are ignored at put() time, except for timeout errors, which are raised. | |
The last exception raised is raised at wait() time | |
""" | |
def __init__(self, maxsize, timeout, err_on_timeout=concurrent.futures.TimeoutError): | |
"""Construct a future wait queue. |
View tracemalloc-report.py
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 | |
import sys | |
from tracemalloc import Snapshot | |
def main(): | |
# todo: argparser | |
fil = sys.argv[1] | |
num = 10 | |
if len(sys.argv) > 2: | |
num = int(sys.argv[2]) |
View random_bytes.py
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
import os | |
import sys | |
import json | |
import math | |
from runstats import Statistics, Regression | |
__all__ = ["randtest", "randtestall", "buildstats"] | |
def primes(givenNumber): | |
# Initialize a list |
View gist:c1cd4c634cfc1f9e3f34d0b4b056651c
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
class LRUSet(set): | |
def __init__(self, *args, max_size=None, **kws): | |
self.max_size = max_size | |
super().__init__(*args, **kws) | |
def add(self, ent): | |
if len(self) >= self.max_size: | |
self.pop() | |
super().discard(ent) | |
super().add(ent) |
View qpydoc.py
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
""" | |
Generate api-style github markdown-files from python docstrings. | |
Example: | |
qpydoc my_module > API.md | |
""" | |
import re |
View mock for subprocess run
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
# allows you to say with mock_run(...): | |
# .... | |
# good for testing scripts that do a lot of subprocess.run calls | |
class CmdMatch(NamedTuple): | |
cmd: str | |
matches: str = ".*" | |
result: str = "" | |
side_effect: Union[Callable, Exception] = None |
View quip.py
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
import requests | |
import string | |
import random | |
import argparse | |
import json | |
def main(): | |
parser = argparse.ArgumentParser(description='Post cryptoquips') | |
parser.add_argument("--generate", action="store_true") |
View coinmarketcap volume weighted mcap
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
import os | |
import argparse | |
from typing import NamedTuple | |
from coinmarketcapapi import CoinMarketCapAPI, CoinMarketCapAPIError | |
api_key = os.environ["COINMARKETCAP_API_KEY"] | |
cmc = CoinMarketCapAPI(api_key) | |
NewerOlder