-
These are not to be blindly followed; strive to understand these and ask
when in doubt. Sometimes standards are a bad idea. -
Don't duplicate the functionality of a built-in library.
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 base64 | |
import os | |
from hashlib import sha256 | |
from typing import Optional | |
import coincurve as secp256k1 | |
"""Minimalist pub/priv key classes for signing and verification based on coincurve""" | |
class PublicKey: |
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] |
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
# very simple RPC server in python | |
import sys, json | |
from http.server import BaseHTTPRequestHandler, HTTPServer | |
import urllib.parse as urlparse | |
import threading | |
import logging | |
log = logging.getLogger(__name__) | |
class ApiError(Exception): |
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): |
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, tempfile, gc | |
class TemporaryFile: | |
def __init__(self, name, io, delete): | |
self.name = name | |
self.__io = io | |
self.__delete = delete | |
def __getattr__(self, k): |
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. |
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]) |
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
/* | |
* Very simple test runner for nodejs: | |
* | |
* Supports: | |
* | |
* before, after, beforeAll, afterAll | |
* fixture object passed to each test, that before/after/beforeAll/afterAll can modify | |
* -[t]est option on command line to pick tests to run | |
* -[l]inear option on command to disable parallel | |
* built in fixture logger, captures log lines, adds line numbers/file names/timestamps |
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
#pragma once | |
#include <codecvt> | |
#include <condition_variable> | |
#include <fstream> | |
#include <iostream> | |
#include <locale> | |
#include <memory> | |
#include <mutex> | |
#include <ostream> |
NewerOlder