Skip to content

Instantly share code, notes, and snippets.

View moi90's full-sized avatar

Simon-Martin Schröder moi90

View GitHub Profile
@platdrag
platdrag / Threadsafe_iter.py
Last active March 24, 2024 17:37
An example generic wrapper for making any iterator / generator thread-safe compatible with python 3
import threading
'''
A generic iterator and generator that takes any iterator and wrap it to make it thread safe.
This method was introducted by Anand Chitipothu in http://anandology.com/blog/using-iterators-and-generators/
but was not compatible with python 3. This modified version is now compatible and works both in python 2.8 and 3.0
'''
class threadsafe_iter:
"""Takes an iterator/generator and makes it thread-safe by
serializing call to the `next` method of given iterator/generator.
"""
@tuxfight3r
tuxfight3r / 01.bash_shortcuts_v2.md
Last active May 4, 2024 16:58
Bash keyboard shortcuts

Bash Shortcuts

visual cheetsheet

Moving

command description
ctrl + a Goto BEGINNING of command line
@AlexandreAbraham
AlexandreAbraham / unsupervised_alt.py
Last active February 5, 2023 23:00
These are two implementations of the silhouette score. They are compatible with the scikit learn implementation but offers different drawbacks in term of complexity and memory usage. The slow version needs no memory but is painfully slow and should, I think, not be used. The second one is based on a block strategy: distance between samples and c…
""" Unsupervised evaluation metrics. """
# License: BSD Style.
from itertools import combinations
import numpy as np
from sklearn.utils import check_random_state
from sklearn.metrics.pairwise import distance_metrics
from sklearn.metrics.pairwise import pairwise_distances