Skip to content

Instantly share code, notes, and snippets.

View Vizonex's full-sized avatar

Vizonex Vizonex

View GitHub Profile
@Vizonex
Vizonex / cloudflare_error_enums.h
Last active August 30, 2023 00:36
Used to Parse and Diagnose Cloudflare Errors coming from either "error code:" or "error:"
/*
The MIT License (MIT)
Copyright © 2023 Vizonex
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the “Software”), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge,
publish, distribute, sublicense, and/or sell copies of the Software,
and to permit persons to whom the Software is furnished to do so,
@Vizonex
Vizonex / py_enum_to_c_enum.py
Last active February 14, 2023 18:22
A little snippet I made that will convert a python enum class into a C enum , this could be used to help you make Optimized C code.
# The MIT License (MIT)
#
# Copyright © 2023 Vizonex
#
# Permission is hereby granted, free of charge, to any person
# obtaining a copy of this software and associated documentation
# files (the “Software”), to deal in the Software without restriction,
# including without limitation the rights to use, copy, modify, merge,
# publish, distribute, sublicense, and/or sell copies of the Software,
# and to permit persons to whom the Software is furnished to do so,
@Vizonex
Vizonex / Readme.md
Last active February 16, 2023 23:39
An llhttp installer script for those working with python and C

This is An Installer Idea I had for those not cabable of using node-js to get or to build llhttp immediately into a small and portable virual enviornment and it is used to Compile the llhttp library for msvc compiler or for the gcc compiler to create a ".lib" & ".dll" file or a single ".a" file if your using the gcc compiler or anything besides windows. This is my alternative for installing such an amazing library and I'll proabably write one for libuv when I've figured out how to correctly install it because digging though and doing that one correctly is a nightmare.

This tool doesn't use the requests library for the sake of portability and arbitrary speed ups.

This will install the precompiled version of llhttp and get rid of other files that aren't needed it will then only grabbing nessesary files to run llhttp in C

@Vizonex
Vizonex / EventLoop.py
Created March 14, 2023 04:47
A little Concept I made inspired by Fastapi and discord.py as well as other decorator objects There's other interesting miscellaneous class objects in my code as well that you can take a look at if you want...
# The MIT License (MIT)
#
# Copyright © 2023 Vizonex
#
# Permission is hereby granted, free of charge, to any person
# obtaining a copy of this software and associated documentation
# files (the “Software”), to deal in the Software without restriction,
# including without limitation the rights to use, copy, modify, merge,
# publish, distribute, sublicense, and/or sell copies of the Software,
@Vizonex
Vizonex / ExprNodes.pyi
Created June 28, 2023 19:09
These are some typehints I'm having to work with the Cython Compiler because of how bad it is to access a hover list in VS Code... I'm also showing also this to act as a wake-up call...
# NOTE "Some of these had to be manually added since stubgen in mypy doesn't even know that some of these items even exist." - Vizonex
# -- ExprNodes.pyi --
from Cython.Compiler import Builtin as Builtin, Future as Future, Naming as Naming, Nodes as Nodes, PyrexTypes as PyrexTypes, StringEncoding as StringEncoding, Symtab as Symtab, TypeSlots as TypeSlots
from Cython import Utils as Utils
from Cython.Debugging import print_call_chain as print_call_chain
from Cython.Compiler.Annotate import AnnotationItem as AnnotationItem
from Cython.Compiler.Builtin import basestring_type as basestring_type, bytearray_type as bytearray_type, bytes_type as bytes_type, dict_type as dict_type, list_type as list_type, set_type as set_type, slice_type as slice_type, str_type as str_type, tuple_type as tuple_type, type_type as type_type, unicode_type as unicode_type
from Cython.Compiler.Code import TempitaUtilityCode as TempitaUtilityCode, UtilityCode as UtilityCode
@Vizonex
Vizonex / wintools.ps1
Last active October 7, 2025 15:58
Aiohttp Developer Tools For windows.
# Compiler script written for windows because of the following problems.
#
# 1. `make` is not well supported on windows
#
# 2. llhttp uses a `rm` command that doesn't
# work on windows so we need to make a script
# for dealing with that that.
#
# 3. Some users prefer to using virtual enviornments so finding a rational way for using them would be an
# ideal solution
@Vizonex
Vizonex / generate_cython_api.py
Last active July 1, 2025 14:52
This is a new concept for generating the New Multidict CAPI to cython using libclang, Couldn't be mypy friendly enough yet so I'm shoving it here.
"""
Generates A Multidict Cython API from multidict_api.h
by parsing the functions to generate the Cython API
Automatically.
"""
from __future__ import annotations
import argparse
import os
@Vizonex
Vizonex / _http_writer.c
Last active July 3, 2025 01:55
If Aiohttp's _http_writer were moved to C and utilized multidict's upcoming C-API it would behave something like this. I know the iterator is still not mature yet because there's 4 of them but maybe it could be optimized to just 1 in the future.
// If Aiohttp's _http_writer were moved to C and utilized multidict's upcoming C-API it would behave something like this.
// It's a little bit bigger than cython's version because more care is required to work with it but the higher control is well worth it.
// - Vizonex
// Maybe the next step might be to start looking at making everything threadsafe so that multiple threads could share different
// http writers?
#include <Python.h>
#include <string.h>
#include <stdint.h>
@Vizonex
Vizonex / socket.pxd
Created July 15, 2025 04:35
python socketmodule exposure to cython
from cpython.time cimport PyTime_t, PyTime_AsSecondsDouble
from cpython.object cimport PyObject, PyTypeObject
# After carefully observing socketmodule.h over from CPython and some
# different versions of python I've determined it might be possible to
# expose this data to the cython api by simply copying off socketmodule.h
# NOTE: Some macros that could be utilized however were too dynamic to
# be utilized here. However just getting the file descriptor object means a lot
# and has potential of being utilized with libraries such as winloop/uvloop for
@Vizonex
Vizonex / _epoll.pyx
Created August 22, 2025 04:00
_epoll.pyx Original 2006 Twisted source code I have saved a copy for archiving purposes since it is a historical artifact to helping shape CPython's selectmodule epoll system. It may or may not run correctly and I have uploaded it for viewing purposes only.
# Copyright (c) 2001-2006 Twisted Matrix Laboratories.
# See LICENSE for details.
"""
Interface to epoll I/O event notification facility.
"""
# NOTE: The version of Pyrex you are using probably _does not work_ with
# Python 2.5. If you need to recompile this file, _make sure you are using
# a version of Pyrex which works with Python 2.5_. I am using 0.9.4.1 from