So you are interested in rounding a number to its lowest multiple. Let's say you want numbers to be rounded to 10:
>>> for number in range(30):
... print(f"{number}: {10 * (number // 10)}")
...
0: 0
1: 0
2: 0
#!/bin/sh | |
set -eux -o pipefail | |
export GIT_USER=hughdbrown | |
export GIT_REPO_NAME_USER=AIE5 # What the user is going to call the repo | |
export GIT_REPO_NAME_AI_MAKER=AIE5 # What the repo is already called by AI_MAKER | |
mkdir -p ~/workspace/${GIT_USER}/maven.com/${GIT_REPO_NAME_USER} | |
cd ~/workspace/${GIT_USER}/maven.com/${GIT_REPO_NAME_USER} |
>>> import requests | |
>>> IDS = { | |
42919502: "2025-02-01", | |
42575537: "2025-01-01", | |
42297424: "2024-12-01", | |
42017580: "2024-11-01", | |
41709301: "2024-10-01", | |
41425910: "2024-09-01", | |
41129813: "2024-08-01", | |
40846428: "2024-07-01", |
#!/usr/bin/env python3 | |
import asyncio | |
from pathlib import Path | |
async def line_count(filename): | |
try: | |
count = filename.read_text(encoding='utf-8').count('\n') | |
except: | |
count = -1 |
#!/usr/bin/env python3 | |
import math | |
# from sys import stderr | |
def w_function_dx(x): | |
return (x + 1) * math.exp(x) | |
def w_function(x, x0): | |
return x * math.exp(x) - x0 |
import os | |
os.environ["NUMBA_LOOP_VECTORIZE"] = "0" | |
os.environ["NUMBA_SLP_VECTORIZE"] = "0" | |
from datetime import datetime | |
from numba import jit, uint32, uint64 | |
import numpy as np | |
>>> from graphlib import TopologicalSorter | |
>>> data = {"A": ["B", "D"], "B": [], "D": [], "C": ["A"]} | |
>>> ts = TopologicalSorter(data) | |
>>> for a in ts.static_order(): | |
... print(a) | |
... | |
B | |
D | |
A |
import logging | |
FORMAT = '%(asctime)s %(message)s' | |
logging.basicConfig( | |
format=FORMAT, | |
datefmt="%Y-%m-%dT%H:%M:%S", | |
# logger levels are: DEBUG, INFO, WARNING, ERROR, CRITICAL | |
level=os.environ.get('LOGLEVEL', 'INFO').upper(), | |
) | |
logger = logging.getLogger() |
-------------------- 2019-01-01 hacker-news-2019-01-01.txt: 782 | |
-------------------- 2019-02-01 hacker-news-2019-02-01.txt: 702 | |
-------------------- 2019-03-01 hacker-news-2019-03-01.txt: 759 | |
-------------------- 2019-04-01 hacker-news-2019-04-01.txt: 757 | |
-------------------- 2019-05-01 hacker-news-2019-05-01.txt: 829 | |
-------------------- 2019-06-01 hacker-news-2019-06-01.txt: 675 | |
-------------------- 2019-07-01 hacker-news-2019-07-01.txt: 767 | |
-------------------- 2019-08-01 hacker-news-2019-08-01.txt: 741 | |
-------------------- 2019-09-01 hacker-news-2019-09-01.txt: 615 | |
-------------------- 2019-10-01 hacker-news-2019-10-01.txt: 733 |
#!/usr/bin/env python3 | |
from pathlib import Path | |
from PIL import Image, ImageChops | |
def trim(im): | |
bg = Image.new(im.mode, im.size, im.getpixel((0,0))) | |
diff = ImageChops.difference(im, bg) | |
diff = ImageChops.add(diff, diff, 2.0, -100) |