Skip to content

Instantly share code, notes, and snippets.

View aurthurm's full-sized avatar
💭
Code Bliss

Aurthur Musendame aurthurm

💭
Code Bliss
View GitHub Profile
@aurthurm
aurthurm / recategoriser.py
Last active June 27, 2025 16:11
BreakPoints from whonet exploration
import pandas as pd
breakpoints = pd.read_csv('Breakpoints.txt', sep='\t', low_memory=False)
antibiotics = pd.read_csv('Antibiotics.txt', sep='\t', low_memory=False)
organisms = pd.read_csv('Organisms.txt', sep='\t', low_memory=False)
# limit breakpoints to 2024 CLSI for Humans only
breakpoints = breakpoints[
breakpoints['TEST_METHOD'].isin(['MIC', 'DISK']) &
(breakpoints['GUIDELINES'] == 'CLSI') &
from bika.lims import api
from nmrl.lims.scripts import setup_script_environment
from senaite.core.catalog import SETUP_CATALOG, SAMPLE_CATALOG
import transaction
def fix_services():
services = api.search({"portal_type": "AnalysisService"}, SETUP_CATALOG)
print("Total services found: {}".format(len(services)))
@aurthurm
aurthurm / fix_invalid_categories.py
Last active June 10, 2025 11:52
Fix invalid categories and reassign analysis
from nmrl.lims.scripts import setup_script_environment
from bika.lims import api
import transaction
from senaite.core.catalog import SETUP_CATALOG
import re
def create_category(parent, title):
category = api.create(parent, "AnalysisCategory", title=title)
category.reindexObject()
return category
from typing import Any, Mapping, Generic, TypeVar
from pydantic import BaseModel
from sqlalchemy import Column, String, select
from sqlalchemy.ext.asyncio import AsyncAttrs
from sqlalchemy.orm import DeclarativeBase
from sqlalchemy_mixins import ReprMixin, SerializeMixin, SmartQueryMixin, SessionMixin
from sqlalchemy_mixins.utils import classproperty
from custom_flake_uid import get_flake_uid
@aurthurm
aurthurm / snowflake.py
Created March 12, 2023 11:47 — forked from wakingyeung/snowflake.py
Twitter snowflake id generator for Python.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import multiprocessing
import re
import threading
import time
LAST_TIMESTAMP = -1
SEQUENCE = 0
@aurthurm
aurthurm / shell.py
Created December 1, 2020 08:21 — forked from samv/shell.py
A proposal for a SQLAlchemy Shell
"""
The SQLAlchemy Shell.
This is just a wrapper for code.InteractiveConsole with some useful
defaults for using SQLAlchemy
"""
import os
import sys
from code import InteractiveConsole
@aurthurm
aurthurm / sqlalchemy_bind_two_database.py
Created August 16, 2020 06:02 — forked from mydreambei-ai/sqlalchemy_bind_two_database.py
sqlalchemy bind multiple databases
from sqlalchemy import (String,
Integer,
engine_from_config,
Column)
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import sessionmaker
Base_1 = declarative_base()
Base_2 = declarative_base()
@aurthurm
aurthurm / db_bind_sharding.py
Created August 15, 2020 16:08 — forked from ziplus4/db_bind_sharding.py
flask, sqlalchemy sample : sharding
# -*- coding:utf8 -*-
import re
from flask import Flask
from flask_sqlalchemy import SQLAlchemy as BaseSQLAlchemy
from flask_sqlalchemy import _SignallingSession as BaseSignallingSession
from flask_sqlalchemy import orm, partial, get_state
from datetime import datetime
@aurthurm
aurthurm / System Design.md
Created August 15, 2020 14:57 — forked from vasanthk/System Design.md
System Design Cheatsheet

System Design Cheatsheet

Picking the right architecture = Picking the right battles + Managing trade-offs

Basic Steps

  1. Clarify and agree on the scope of the system
  • User cases (description of sequences of events that, taken together, lead to a system doing something useful)
    • Who is going to use it?
    • How are they going to use it?
@aurthurm
aurthurm / convert.py
Created December 15, 2016 09:25 — forked from paulgb/convert.py
Convert the Yelp Academic dataset from JSON to CSV files with Pandas.
'''
Convert Yelp Academic Dataset from JSON to CSV
Requires Pandas (https://pypi.python.org/pypi/pandas)
By Paul Butler, No Rights Reserved
'''
import json
import pandas as pd