Skip to content

Instantly share code, notes, and snippets.

@nnemkin
nnemkin / conf-sample.py
Last active August 29, 2015 13:56
Sphinx extension example. It doesn't really work as is but gives you hints on what you can extend.
# -*- coding: utf-8 -*-
#
# SWT documentation build configuration file, created by
# sphinx-quickstart on Tue Feb 26 18:19:43 2013.
#
# The author of this program disclaims copyright.
import sys, os
import re
from docutils import nodes
@nnemkin
nnemkin / get_current_file.c
Created April 10, 2013 05:40
Warning: untested code.
/* Extension's __file__ attribute is not initialized until after the init
function returns. To set submodules' __file__ at init time we will
have to retrieve it from the OS. */
#if defined(_WIN32)
#include <Windows.h>
static PyObject *get_current_file() {
HMODULE hModule;
union {
CHAR nameA[MAX_PATH];
@nnemkin
nnemkin / win_inet_pton.py
Last active January 14, 2024 06:12
Native inet_pton and inet_ntop implementation for Python on Windows (with ctypes).
# This software released into the public domain. Anyone is free to copy,
# modify, publish, use, compile, sell, or distribute this software,
# either in source code form or as a compiled binary, for any purpose,
# commercial or non-commercial, and by any means.
import socket
import ctypes
class sockaddr(ctypes.Structure):
_fields_ = [("sa_family", ctypes.c_short),