Skip to content

Instantly share code, notes, and snippets.

View imneonizer's full-sized avatar
:octocat:
Developing for the python community!

Nitin Rai imneonizer

:octocat:
Developing for the python community!
  • SmartCow.ai
  • Delhi, India
  • 11:58 (UTC +05:30)
  • X @imneonizer
View GitHub Profile

1. Automatic authentication to remote machine

Note:- with this you don't need to type password every time to do the ssh connection.

Step One—Create the RSA Key Pair (your machine)

ssh-keygen -t rsa

Step Two—Store the Keys and Passphrase (your machine)

import threading
class Thread(threading.Thread):
def __init__(self, group=None, target=None, name=None, args=(), kwargs=None, *, daemon=None):
threading.Thread.__init__(self, group, target, name, args, kwargs, daemon=daemon)
self._return = None
def run(self):
if self._target is not None:
self._return = self._target(*self._args, **self._kwargs)
# use multiple gpu devices by index
import os
#GPU_id = '0'
GPU_id = '0,1,2,3'
os.environ['CUDA_VISIBLE_DEVICES'] = GPU_id
@imneonizer
imneonizer / hash_engine.py
Created May 1, 2021 18:36
Image hashing techniques
import os
import cv2
import hashlib
import numpy as np
import scipy.fftpack
class HashEngine:
def __init__(self, htype="dhash", hash_size=8):
self.hash_size = hash_size
self.htype = htype
@imneonizer
imneonizer / main.py
Created May 2, 2021 10:36
Custom waitKey for opencv
# make sure terminal window is active when pressing any key
import cv2
import numpy as np
import time
from waitKey import waitKey
frame = np.zeros((300, 300, 3))
idx, st = 0, time.time()
while True:
# https://github.com/linghu8812/blur_detector/blob/master/blur_detector.py
import cv2
import numpy as np
class BlurDetector(object):
def __init__(self):
"""Initialize a DCT based blur detector"""
# https://github.com/yogin16/prototxt_parser
# pip install parsy==1.3.0
from parsy import generate, regex, string
# Convert an array of tuples array [[(a,b),(a,c)]] to an object {a: [b,c]}
def tuples_to_dict(a):
# print(a)
new_dict = {}
for tuples in a:

1. Stop the docker daemon

sudo service docker stop

2. Add a configuration file to tell the docker daemon what is the location of the data directory Using your preferred text editor add a file named daemon.json under the directory /etc/docker.

sudo vim /etc/docker/daemon.json
@imneonizer
imneonizer / generate_colors.py
Created July 7, 2021 06:43
Generate consistent random colors
import random
import colorsys
def generate_colors(n):
random.seed(10101)
hsv_tuples = [(x / n, 1., 1.) for x in range(n)]
colors = list(map(lambda x: colorsys.hsv_to_rgb(*x), hsv_tuples))
colors = list(map(lambda x: (int(x[0] * 255), int(x[1] * 255), int(x[2] * 255)), colors))
random.shuffle(colors)
random.seed(None)
@imneonizer
imneonizer / capture.sh
Created August 30, 2021 04:11
capture rtsp snapshot using gstreamer
# https://stackoverflow.com/questions/59025321/capture-jpeg-images-from-rtsp-gstreamer
gst-launch-1.0 rtspsrc location="rtsp://admin:123456@192.168.0.123/stream0" num-buffers=1 \
! rtph264depay ! avdec_h264 \
! nvjpegenc ! multifilesink location="./frame.jpg"