Skip to content

Instantly share code, notes, and snippets.

View nik123's full-sized avatar

Nikita Kodenko nik123

View GitHub Profile
@nik123
nik123 / gist:6ad572d2160ba8483506fbeb7dafa731
Created March 11, 2024 16:59
datumaro yolo loose import traceback
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
Cell In[41], line 1
----> 1 print(ds)
File ~/anaconda3/envs/datumaro/lib/python3.10/site-packages/datumaro/components/dataset.py:261, in Dataset.__repr__(self)
257 def __repr__(self) -> str:
258 separator = "\t"
259 return (
260 f"Dataset\n"
@nik123
nik123 / main.py
Last active November 7, 2023 17:53
Delayed video recording in gstreamer
import gi
from time import sleep, time
from threading import Thread
gi.require_version("Gst", "1.0")
from gi.repository import Gst, GLib # noqa
def bus_call(bus, message, loop):
t = message.type
@nik123
nik123 / logging.py
Last active February 25, 2021 11:38
Python logging example
import logging
# if you call "getLogger" with same name several times it will return same instance:
logger = logging.getLogger("UniqueLoggerName")
# Uncomment lines to test different debug levels:
# Possible "level" values: https://docs.python.org/3/library/logging.html#levels
logger.setLevel(logging.DEBUG)
# logger.setLevel(logging.INFO)
# logger.setLevel(logging.ERROR)
@nik123
nik123 / log.txt
Created February 5, 2020 21:28
log_pip_install_dvc_all_after_pip_install_numpy
Collecting dvc[all]
Using cached dvc-0.82.9-py2.py3-none-any.whl (298 kB)
Processing /home/nik123/.cache/pip/wheels/41/99/17/7135f635215e1f61e906295afd11f4f791cfe4ab45f3bfdca2/nanotime-0.5.2-cp36-none-any.whl
Processing /home/nik123/.cache/pip/wheels/e8/e3/d0/a2d476b9cd09b8f5979789e0aaf07119726a3cfb19ee67aa1e/voluptuous-0.11.7-cp36-none-any.whl
Collecting pyasn1>=0.4.1
Using cached pyasn1-0.4.8-py2.py3-none-any.whl (77 kB)
Processing /home/nik123/.cache/pip/wheels/de/63/64/3699be2a9d0ccdb37c7f16329acf3863fd76eda58c39c737af/networkx-2.3-py2.py3-none-any.whl
Processing /home/nik123/.cache/pip/wheels/20/5a/d8/1d875df03deae6f178dfdf70238cca33f948ef8a6f5209f2eb/funcy-1.14-py2.py3-none-any.whl
Collecting packaging>=19.0
Using cached packaging-20.1-py2.py3-none-any.whl (36 kB)
@nik123
nik123 / log.txt
Created February 4, 2020 13:17
pip install dvc[all] on ARM error log
Collecting dvc[all]
Using cached dvc-0.82.8-py2.py3-none-any.whl (298 kB)
Processing /home/nik123/.cache/pip/wheels/69/86/6c/f8b8593bc273ec4b0c653d3827f7482bb2001a2781a73b7f44/humanize-0.5.1-cp36-none-any.whl
Processing /home/nik123/.cache/pip/wheels/3f/eb/fd/69e5177f67b505e44acbd1aedfbe44b91768ee0c4cd5636576/shortuuid-0.5.0-cp36-none-any.whl
Requirement already satisfied: setuptools>=34.0.0 in ./venv/lib/python3.6/site-packages (from dvc[all]) (45.1.0)
Collecting zc.lockfile>=1.2.1
Using cached zc.lockfile-2.0-py2.py3-none-any.whl (9.7 kB)
Collecting pydot>=1.2.4
Using cached pydot-1.4.1-py2.py3-none-any.whl (19 kB)
Collecting flatten-json>=0.1.6
@nik123
nik123 / gist:30381c0aef7e8d5918c9112cd3014fe5
Created November 8, 2019 05:02
push error: unknown idna encoding
This file has been truncated, but you can view the full file.
DEBUG: PRAGMA user_version;
DEBUG: fetched: [(3,)]
DEBUG: CREATE TABLE IF NOT EXISTS state (inode INTEGER PRIMARY KEY, mtime TEXT NOT NULL, size TEXT NOT NULL, md5 TEXT NOT NULL, timestamp TEXT NOT NULL)
DEBUG: CREATE TABLE IF NOT EXISTS state_info (count INTEGER)
DEBUG: CREATE TABLE IF NOT EXISTS link_state (path TEXT PRIMARY KEY, inode INTEGER NOT NULL, mtime TEXT NOT NULL)
DEBUG: INSERT OR IGNORE INTO state_info (count) SELECT 0 WHERE NOT EXISTS (SELECT * FROM state_info)
DEBUG: PRAGMA user_version = 3;
DEBUG: Path ../../../.dvc/cache/ce/a5bf3143684c3b83dffd98b4d93bef.dir inode 105261837
DEBUG: SELECT mtime, size, md5, timestamp from state WHERE inode=?
DEBUG: fetched: [('1573024010213697792', '457200', 'cea5bf3143684c3b83dffd98b4d93bef.dir', '1573188173411892992')]
@nik123
nik123 / randomfile.py
Created June 10, 2019 15:58
Selecting random file
#! /usr/bin/python
# Script recursively walks through all files in current directory and saves them in the list.
# Then script selects random item from list of files created on previous step.
import random
import os
import argparse
@nik123
nik123 / sequence.py
Last active May 27, 2019 13:01
sequence.py - an interface to simplify batch-by-batch data access for low-level TensorFlow API
"""
Sequence class and its derivatives.
Sequence provides an interface for batch-by-batch extraction of data from dataset
"""
import abc
from typing import Tuple, Any
import numpy as np
from sklearn.utils import shuffle
@nik123
nik123 / argparse.md
Last active April 29, 2020 16:01
argparse Cheet Sheat

Boolean flags

parser.add_argument('--feature', dest='feature', action='store_true')
parser.add_argument('--no-feature', dest='feature', action='store_false')
parser.set_defaults(feature=True)

Usage:

@nik123
nik123 / timer.py
Last active March 26, 2020 08:26
Logging time intervals in Python
from contextlib import contextmanager
import time
@contextmanager
def timelogger(print_fn=print, msg: Optional[str]=None):
t1 = time.time()
try:
yield
finally: