Skip to content

Instantly share code, notes, and snippets.

View MtkN1's full-sized avatar

MtkN1 MtkN1

View GitHub Profile
@MtkN1
MtkN1 / bittrade_http.py
Last active September 6, 2024 18:30
pybotters 1.5 Sample code
# /// script
# requires-python = ">=3.8"
# dependencies = [
# "pybotters>=1.5",
# "rich>=9.1",
# ]
# ///
import asyncio
import os
@MtkN1
MtkN1 / pydantic_cattrs_timeit.ipynb
Created July 28, 2024 16:00
pydantic vs. cattrs performance
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@MtkN1
MtkN1 / README.md
Created June 6, 2024 07:54 — forked from florimondmanca/httpx-urllib3.md
URLLib3 transport implementation (Extracted from HTTPX)

urllib3-transport

An HTTPCore transport that uses urllib3 as the HTTP networking backend. (This was initially shipped with HTTPX.)

When used with HTTPX, this transport makes it easier to transition from Requests to HTTPX by keeping the same underlying HTTP networking layer.

Compatible with: HTTPX 0.15.x, 0.16.x (i.e. HTTPCore 0.11.x and HTTPCore 0.12.x).

Note: not all urllib3 pool manager options are supported here — feel free to adapt this gist to your specific needs.

@MtkN1
MtkN1 / pyproject.toml
Created May 10, 2024 08:54
pyproject.toml differences between Hatch v1.9 and v1.10
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"
[project]
name = "hatch-demo"
dynamic = ["version"]
description = ''
readme = "README.md"
requires-python = ">=3.8"
@MtkN1
MtkN1 / noxfile.py
Created April 4, 2024 14:06
nox for Rye (it works, sort of)
import nox
import os
from pathlib import Path
PYTHON_VERSIONS = ["3.8", "3.9", "3.10", "3.11", "3.12"]
VENV_BACKEND = "uv"
def ensurepath():
rye_home = os.getenv("RYE_HOME")
@MtkN1
MtkN1 / Dockerfile
Created March 26, 2024 13:01
Dockerfile for uv
# build stage
FROM python:3.12-bookworm AS build
RUN curl -LsSf https://astral.sh/uv/install.sh | sh
ENV PATH="/root/.cargo/bin:$PATH"
WORKDIR /app
COPY requirements.txt requirements.txt
@MtkN1
MtkN1 / tmp.pOln6CFBQq.py
Created February 5, 2024 15:15
Rate limit test for GMO Coin WebSocket
import asyncio
import json
import logging
from contextlib import AsyncExitStack
import websockets
logger = logging.getLogger("websockets.client")
logger.setLevel(logging.DEBUG)
ch = logging.StreamHandler()
@MtkN1
MtkN1 / model.py
Last active January 22, 2024 15:45
Binance Spot Pydantic Models from datamodel-code-generator
# generated by datamodel-codegen:
# filename: https://github.com/binance/binance-api-swagger/raw/master/spot_api.yaml
# timestamp: 2024-01-22T15:18:47+00:00
from __future__ import annotations
from typing import List, Optional
from pydantic import BaseModel, Field, RootModel
@MtkN1
MtkN1 / mkdocs.yml
Created September 18, 2023 09:21
mkdocs.yml sample for pybotters]
site_name: "pybotters Docs"
nav:
- "Introduction": "README.md"
- "Usage":
- "QuickStart": "Home.md"
- "Advanced Usage": "Advanced-Usage.md"
- "Guides":
- "Exchanges": "Exchanges.md"
- "Example": "Example.md"
@MtkN1
MtkN1 / httpx_http2_async.py
Created September 5, 2023 05:36
Asynchronous request to bitFlyer using HTTP/2 with HTTPX.
import asyncio
import time
import httpx
async def main():
for use_http2 in (False, True):
async with httpx.AsyncClient(
base_url="https://api.bitflyer.com", http2=use_http2