Skip to content

Instantly share code, notes, and snippets.

@ntamas
ntamas / urwid-trio-nursery.patch
Created Jan 7, 2020
Patch for urwid.TrioEventLoop to allow running it in an existing Trio event loop
View urwid-trio-nursery.patch
diff --git a/urwid/_async_kw_event_loop.py b/urwid/_async_kw_event_loop.py
index cc7728f..f7c3f0a 100644
--- a/urwid/_async_kw_event_loop.py
+++ b/urwid/_async_kw_event_loop.py
@@ -30,15 +30,8 @@ class TrioEventLoop(EventLoop):
``trio`` is an async library for Python 3.5 and later.
"""
- def __init__(self, nursery=None):
- """Constructor.
View keybase.md

Keybase proof

I hereby claim:

  • I am ntamas on github.
  • I am ntamas (https://keybase.io/ntamas) on keybase.
  • I have a public key ASClM5botlxl4Q__0JMBdMM0fFqQAIxFMLAH00CCU0hffwo

To claim this, I am signing this object:

@ntamas
ntamas / underflow.txt
Created Sep 6, 2016
sample data that causes an underflow in plfit
View underflow.txt
400.00
6.00
260.00
50.00
50.00
75.00
50.00
50.00
50.00
250.00
@ntamas
ntamas / hlc.py
Created Nov 19, 2013
Hierarchical link clustering algorithm of Ahn et al (see http://barabasilab.neu.edu/projects/linkcommunities/), implemented using Python and igraph for fun.
View hlc.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Hierarchical link clustering
============================
:Author: Tamás Nepusz
This is an implementation of the hierarchical link clustering algorithm of Ahn
et al. The results provided by this implementation match those of the original
@ntamas
ntamas / walker.py
Last active Apr 15, 2020
Weighted sampling with replacement using Walker's alias method - NumPy version
View walker.py
#!/usr/bin/env python
from numpy import arange, array, bincount, ndarray, ones, where
from numpy.random import seed, random, randint
__author__ = "Tamas Nepusz, Denis Bzowy"
__version__ = "27jul2011"
class WalkerRandomSampling(object):
"""Walker's alias method for random objects with different probablities.
@ntamas
ntamas / complementerset.py
Created Feb 16, 2011
complementerset object for Python
View complementerset.py
class complementerset(object):
"""This object behaves more or less like a set, with one exception,
the membership checking. For a `complementerset` object, you can
define the elements which are *not* in the set, everything else is
contained in it. The semantics of the operators are the same as for
sets.
Usage example::
>>> s = complementerset()
@ntamas
ntamas / drop
Created Sep 22, 2010
Simple shell script to copy a file to a Dropbox public folder and get its URL. Needs socat and xclip.
View drop
#!/bin/sh
#
# Simple shell script to copy a file to the Dropbox
# public folder and get its URL.
#
# The URL of the last file copied also stays on the
# X clipboard.
#
# Symlink the script as dropmv to move the file to the
# public folder instead of copying it.
@ntamas
ntamas / video.py
Created Sep 13, 2010
Animation add-on for the Python interface of igraph
View video.py
#!/usr/bin/env python
"""Classes to produce videos from igraph plots.
"""
from __future__ import with_statement
from contextlib import contextmanager
from igraph.drawing import BoundingBox, Plot
from shutil import rmtree
View vuvuzela.py
"""
``vuvuzela.py`` adds the glorious sound of the vuvuzela to any
Python program.
Based on the excellent idea of Chris Williams. See also:
<http://search.cpan.org/~bingos/Acme-Vuvuzela-0.02>
Usage::
>>> import vuvuzela