Skip to content

Instantly share code, notes, and snippets.

Avatar
🎹
Piano

earonesty

🎹
Piano
View GitHub Profile
View testman.js
/*
* 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
View loggy.h
#pragma once
#include <codecvt>
#include <condition_variable>
#include <fstream>
#include <iostream>
#include <locale>
#include <memory>
#include <mutex>
#include <ostream>
View random_bytes.py
import os
import sys
import json
import math
from runstats import Statistics, Regression
__all__ = ["randtest", "randtestall", "buildstats"]
def primes(givenNumber):
# Initialize a list
View CodingGuidelines.md

Coding Guidelines

General

  • 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.

View yq
#!/bin/env python
import yaml
import sys
import json
import argparse
from subprocess import Popen, PIPE
import argparse
import os
View coinmarketcap volume weighted mcap
import os
import argparse
from typing import NamedTuple
from coinmarketcapapi import CoinMarketCapAPI, CoinMarketCapAPIError
api_key = os.environ["COINMARKETCAP_API_KEY"]
cmc = CoinMarketCapAPI(api_key)
@earonesty
earonesty / gist:c1cd4c634cfc1f9e3f34d0b4b056651c
Created Mar 21, 2022
extremely simple lru set in python
View gist:c1cd4c634cfc1f9e3f34d0b4b056651c
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
"""
Generate api-style github markdown-files from python docstrings.
Example:
qpydoc my_module > API.md
"""
import re
View propagating_thread.py
import threading
from typing import Any
class PropagatingThread(threading.Thread):
"""A Threading Class that raises errors it caught, and returns the return value of the target on join."""
def __init__(self, *args, **kwargs):
self._target = None
self._args = ()
View apiserver.py
# 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):