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 mmap | |
| def count_lines(fn: str | Path) -> int: | |
| """count lines in file""" | |
| with open(fn, "rb") as f: | |
| buf = mmap.mmap(f.fileno(), 0, prot=mmap.PROT_READ) | |
| return sum(1 for _ in iter(buf.readline, b"")) |
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
| """super quick script for getting the file urls for download""" | |
| import sys | |
| import requests | |
| from bs4 import BeautifulSoup | |
| from itertools import count | |
| url = "https://cytomine.com/collection" | |
| for page_idx in count(): | |
| page = requests.get(url, params={"page": page_idx}) |
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 __future__ import annotations | |
| import itertools | |
| def merge_intervals( | |
| intervals: list[tuple[int, int]], | |
| *, | |
| merge_adjacent: bool = False, | |
| inplace: bool = False, |
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
| # fizzbuzz abusing pep634. run with python 3.10 | |
| class ZZMeta(type): | |
| def __new__(mcls, name, bases, attr, **kw): | |
| attr['d'] = kw.get('divisor', None) | |
| return super().__new__(mcls, name, bases, attr) | |
| def __instancecheck__(cls, obj): | |
| if not obj % cls.d: | |
| print(cls.__name__, end="") | |
| return True |
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
| alias md5b64tohex="python -c 'import base64, binascii, sys; print binascii.hexlify(base64.urlsafe_b64decode(sys.argv[1]))'" |
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
| /** | |
| * Run a per project startup script on project load, if the project ships a | |
| * 'startup.groovy' script in its project scripts directory. | |
| * | |
| * @author Andreas Poehlmann | |
| */ | |
| import java.awt.image.BufferedImage | |
| import javafx.beans.value.ChangeListener | |
| import javafx.beans.value.ObservableValue | |
| import qupath.lib.gui.scripting.DefaultScriptEditor |
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
| #!/bin/bash | |
| # | |
| # Python on 19.04 on Android | |
| # ========================== | |
| # | |
| # Setup an ubuntu dev environment for Python on Android. | |
| # | |
| DEVUSER=poehlmann | |
| # update termux packages |
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 numpy as np | |
| import matplotlib.pyplot as plt | |
| import matplotlib.patches as mpatches | |
| def plot_fly(ax, c, s, o): | |
| # center, scale, orientation(deg) | |
| c = np.array(c) | |
| v = np.array([np.cos(np.radians(o)), np.sin(np.radians(o))]) | |
| t = np.array([np.cos(np.radians(o+90)), np.sin(np.radians(o+90))]) |
This file has been truncated, but you can view the full file.
This file has been truncated, but you can view the full file.
NewerOlder