Skip to content

Instantly share code, notes, and snippets.

@nazavode
nazavode / ctype_async_raise.py
Last active August 9, 2023 15:48 — forked from liuw/ctype_async_raise.py
Nasty hack to raise exception for other threads
from __future__ import print_function
import ctypes
import threading
import time
def async_raise(thread_obj, exception):
""" Raises an exception inside an arbitrary active :class:`~threading.Thread`.
Parameters
@nazavode
nazavode / classproperty.py
Last active December 17, 2015 08:35
Type-level property decorator.
# -*- coding: utf-8 -*-
#
# Copyright 2015 Federico Ficarelli
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
@nazavode
nazavode / fixtures.py
Last active March 15, 2016 14:51
Multiple queue bindings for Kombu virtual transports.
# -*- coding: utf-8 -*-
import pytest
import timeit
# from duga import *
@pytest.fixture
def domain():

Keybase proof

I hereby claim:

  • I am nazavode on github.
  • I am nazavode (https://keybase.io/nazavode) on keybase.
  • I have a public key whose fingerprint is 74C9 67CD E139 0E80 0521 33A0 51E3 130F 9AD6 20D7

To claim this, I am signing this object:

@nazavode
nazavode / aio.rst
Last active March 17, 2017 10:01
Python async projects

Amazing projects based on async/await features:

@nazavode
nazavode / .gitignore
Last active March 14, 2017 12:21
Example snippets for ISO C aliasing
*.o
@nazavode
nazavode / ast.py
Last active March 12, 2017 14:26
Snippets for Visitor pattern in Python
class AstNode(object):
pass
class Expression(AstNode):
pass
class BinOp(AstNode):
pass
class Add(BinOp):
# -*- coding: utf-8 -*-
from collections import namedtuple, Mapping
__all__ = ['defaultuple']
def defaultuple(typename, field_names, default_values=()):
""" Build a new `namedtuple` type with optional default values that
can be specified as positional or keyword arguments.
@nazavode
nazavode / attach.py
Last active April 5, 2017 08:43
Attach pdb to running Python process
def attach(sig, frame):
import pdb
pdb.Pdb().set_trace(frame)
if __name__ == '__main__':
import signal
signal.signal(signal.SIGUSR1, attach)
# ...
# kill -USR1 <pid>
*.dot
.venv