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 / 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
library(plyr)
find_zones <- function(x) {
x.mean <- mean(x)
x.sd <- sd(x)
boundaries <- seq(-4, 4)
# creates a set of zones for each point in x
zones <- sapply(boundaries, function(i) {
i * rep(x.sd, length(x))
})