Skip to content

Instantly share code, notes, and snippets.

@telecran-telecrit
telecran-telecrit / spoiler
Created July 22, 2024 20:37 — forked from beardlessman/spoiler
Spoiler [like jquery-ui accordion(no)]
//js
$('.j-spoiler').each(function(){
new Spoiler(this);
});
Spoiler = function(container) {
this.container = $(container);
this.head = this.container.find('.j-spoiler-head');
this.body = this.container.find('.j-spoiler-body');
this.close = this.container.find('.j-spoiler-close');
this.init();
@telecran-telecrit
telecran-telecrit / read_write_lock.py
Created May 2, 2024 12:47 — forked from Eboubaker/read_write_lock.py
Python Reentrant Read Write Lock: Allowing Multithreaded Read Access While Maintaining a Write Lock
import threading
from typing import List
class ReentrantRWLock:
"""
A lock object that allows many simultaneous "read locks", but only one "write lock."
it also ignores multiple write locks from the same thread
"""
@telecran-telecrit
telecran-telecrit / rwlock.py
Created May 2, 2024 12:46 — forked from tylerneylon/rwlock.py
A simple read-write lock implementation in Python.
# -*- coding: utf-8 -*-
""" rwlock.py
A class to implement read-write locks on top of the standard threading
library.
This is implemented with two mutexes (threading.Lock instances) as per this
wikipedia pseudocode:
https://en.wikipedia.org/wiki/Readers%E2%80%93writer_lock#Using_two_mutexes