Skip to content

Instantly share code, notes, and snippets.

@jyotendra
jyotendra / docker-init.md
Last active March 5, 2019 18:09
Important docker commands

Command to initialize docker container as non-root user

This command also demonstrates "bind volume mount", transferring webcam device to container, port transfer and x11 linux graphic server.

nvidia-docker run -it --device=/dev/video0:/dev/video0 --user=$(id -u $USER):$(id -g $USER) -p=5000:5000 -v /etc/passwd:/etc/passwd -v /etc/group:/etc/group -v /etc/shadow:/etc/shadow -v /tmp/.X11-unix:/tmp/.X11-unix -v /home/jyotendra/project/DeepStream/sample-scripts:/root/ -e DISPLAY=$DISPLAY -w /root 94a 

The following volumes are mounted so as to help with initiating container as non-root user:

  • /etc/passwd
@jyotendra
jyotendra / settings.json
Created April 25, 2019 12:31
licenser vs code plugin license file. To be kept inside .vscode
{
"licenser.license": "Custom",
"licenser.author": "Jyotendra Sharma",
"licenser.projectName": "SignalRApp",
"licenser.useSingleLineStyle": false,
"licenser.customHeader": "@FILE@ - @PROJECT@\r\nCopyright @YEAR@ - Bitvivid Solutions Pvt. Ltd. \r\n*********************************************************\r\nAuthor - @AUTHOR@ \r\n*********************************************************\r\nNo part of this software may be copied or distributed without written consent from Bitvivid Solutions Pvt. Ltd (company).\r\nThe company holds right to prosecute the individual\/organisation\/company found guilty of misusing company's intellectual properties."
}
@jyotendra
jyotendra / annotations_corrector.py
Created August 1, 2019 10:39
This script corrects path of voc annotations to new one -- when the files are transferred to another system
import glob, os
import argparse
import xml.etree.ElementTree as ET
import ntpath
parser = argparse.ArgumentParser()
parser.add_argument("-i", "--images", required=True, help="enter path where images are stored")
parser.add_argument("-l", "--labels", required=True, help="enter path where labels are stored")
@jyotendra
jyotendra / string_splitter_printer.py
Created September 16, 2019 10:10
LSTM string splitter script
# | diving 42.6% | accident 79.7% | collapsing 79.9%
def splitter(text, threshold):
text = text.strip()
text = text.split("|")
new_text_array = []
for txt in text:
txt = txt.strip()
if txt == '':
continue
@jyotendra
jyotendra / ff_serialiser.py
Created October 15, 2019 10:04
This gist describes serialising a video, frame by frame, and then reconstructing the image using opencv and ffmpeg
import subprocess as sp
import cv2 as cv
import numpy as np
import ffmpeg
probe = ffmpeg.probe('/home/jyotendra/Videos/pandas.mp4')
video_info = next(s for s in probe['streams'] if s['codec_type'] == 'video')
width = int(video_info['width'])
height = int(video_info['height'])
num_frames = int(video_info['nb_frames'])
@jyotendra
jyotendra / publisher.py
Created November 12, 2019 02:29
This gist demonstrates a simple-publisher and a simple-subscriber
import paho.mqtt.publish as publish
publish.single("bv_solutions/test", "payload", hostname="mqtt.eclipse.org")
@jyotendra
jyotendra / arduino_counter.ino
Created November 12, 2019 02:48
Demonstration of receiving data from arduino via python
int count=0;
void setup()
{
Serial.begin(9600);
}
void loop()
{
while(1)
import { ajax } from 'rxjs/ajax';
// action creators
const fetchUser = username => ({ type: FETCH_USER, payload: username });
const fetchUserFulfilled = payload => ({ type: FETCH_USER_FULFILLED, payload });
// epic
const fetchUserEpic = action$ => action$.pipe(
ofType(FETCH_USER),
mergeMap(action =>
@jyotendra
jyotendra / nginx.conf
Created May 16, 2021 18:10
proxy server with for port 3000 with ssl enabled
GNU nano 4.8 metabase.com # sample nginx.conf
# proxy requests to Metabase instance
server {
listen 80;
listen [::]:80;
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/metabase.covidindiaresources.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/metabase.covidindiaresources.com/privkey.pem;
@jyotendra
jyotendra / schema_drop.sql
Created May 25, 2021 07:47
This sql script helps to drop entire scema from a database
SET FOREIGN_KEY_CHECKS = 0;
SET SESSION group_concat_max_len = 1000000;
SET @TABLES = NULL;
SELECT GROUP_CONCAT('`', table_schema, '`.`', table_name,'`') INTO @TABLES FROM information_schema.tables
WHERE table_schema = 'databaseName';
SET @TABLES = CONCAT('DROP TABLE IF EXISTS ', @TABLES);
PREPARE stmt FROM @TABLES;