Skip to content

Instantly share code, notes, and snippets.

@jyotendra
jyotendra / schema_drop.sql
Created May 25, 2021
This sql script helps to drop entire scema from a database
View schema_drop.sql
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;
@jyotendra
jyotendra / nginx.conf
Created May 16, 2021
proxy server with for port 3000 with ssl enabled
View nginx.conf
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;
View gist:14f879193e91aeac1ff7d8b775943db7
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 / arduino_counter.ino
Created Nov 12, 2019
Demonstration of receiving data from arduino via python
View arduino_counter.ino
int count=0;
void setup()
{
Serial.begin(9600);
}
void loop()
{
while(1)
@jyotendra
jyotendra / publisher.py
Created Nov 12, 2019
This gist demonstrates a simple-publisher and a simple-subscriber
View publisher.py
import paho.mqtt.publish as publish
publish.single("bv_solutions/test", "payload", hostname="mqtt.eclipse.org")
@jyotendra
jyotendra / ff_serialiser.py
Created Oct 15, 2019
This gist describes serialising a video, frame by frame, and then reconstructing the image using opencv and ffmpeg
View ff_serialiser.py
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 / string_splitter_printer.py
Created Sep 16, 2019
LSTM string splitter script
View string_splitter_printer.py
# | 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 / annotations_corrector.py
Created Aug 1, 2019
This script corrects path of voc annotations to new one -- when the files are transferred to another system
View annotations_corrector.py
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 / settings.json
Created Apr 25, 2019
licenser vs code plugin license file. To be kept inside .vscode
View settings.json
{
"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 / docker-init.md
Last active Mar 5, 2019
Important docker commands
View docker-init.md

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