This file contains hidden or 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
// Base64 encode | |
new String(java.util.Base64.getEncoder.encode("hello".getBytes()),java.nio.charset.StandardCharsets.UTF_8) | |
// Base64 decode | |
new String(java.util.Base64.getDecoder.decode("aGVsbG8=".getBytes()),java.nio.charset.StandardCharsets.UTF_8) |
This file contains hidden or 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 multiprocessing import Pool, Process, Manager | |
import time | |
import logging | |
import os | |
logging.basicConfig(level=logging.INFO, format='[%(levelname)s] [%(asctime)s] [%(process)s] %(message)s', datefmt='%d/%m/%Y %I:%M:%S %p') | |
def writer(queue): |
This file contains hidden or 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 multiprocessing import Process, Value | |
def func(val): | |
val.value = val.value * 2 | |
return True | |
if __name__ == '__main__': | |
val = Value("l", 1, lock=False) # "l" -> typecode_or_type , 1 -> the value. |
This file contains hidden or 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 multiprocessing import Pool, Process, Manager | |
import time | |
def writer(queue): | |
""" Queue writer worker """ | |
# Produce data into the queue | |
for i in range(10000): | |
t = time.time() | |
print({'message': i, 'time': t, 'queue_size': queue.qsize()}) |
NewerOlder