This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import threading | |
import weakref | |
import boto3 | |
import boto3.session | |
from queue_consumer import Consumer | |
s3_pool = weakref.WeakKeyDictionary() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class RWLock: | |
def __init__(self): | |
self._r_num = 0 | |
self._w_num = 0 | |
self._w_lock = Lock() | |
self._r_lock = Lock() | |
self._s_lock = Lock() | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from contextlib import contextmanager | |
from threading import Lock | |
class RWLock(object): | |
def __init__(self): | |
self.w_lock = Lock() | |
self.num_r_lock = Lock() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from threading import Lock | |
class Node: | |
def __init__(self, value=None): | |
self.value = value | |
self.next = None | |
self.lock = Lock() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from threading import Lock | |
class Node: | |
def __init__(self, value=None): | |
self.value = value | |
self.next = None | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from threading import Lock | |
class Node: | |
def __init__(self, value=None): | |
self.value = value | |
self.next = None | |
self.lock = Lock() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Node: | |
def __init__(self, value=None): | |
self.value = value | |
self.next = None | |
class LinkedList: | |
def __init__(self): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from contextlib import contextmanager | |
from threading import Lock | |
class RWLock: | |
def __init__(self): | |
self._r_num = 0 | |
self._w_num = 0 | |
self._w_lock = Lock() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const checkBalance = string => { | |
const map = { | |
']': '[', | |
'}': '{', | |
')': '(', | |
}; | |
const left = Object.values(map); | |
const right = Object.keys(map); | |
const arr = ["'", '"', '|']; | |
const stack = []; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def count_chars(s): | |
f = {} | |
for c in s: | |
f[c] = f.setdefault(c, 0) + 1 | |
return f | |
def get_frequency(s): | |
chars = count_chars(s) | |
return list(chars.values()) |