Skip to content

Instantly share code, notes, and snippets.

View neerajvashistha's full-sized avatar
🏠
Working from home

Neeraj Vashistha neerajvashistha

🏠
Working from home
View GitHub Profile
import logging
logger = logging.getLogger('handler')
logger.setLevel(logging.DEBUG)
# create file handler which logs even debug messages
fh = logging.FileHandler('handler.log')
fh.setLevel(logging.DEBUG)
# create console handler with a higher log level
ch = logging.StreamHandler()
ch.setLevel(logging.DEBUG)
# create formatter and add it to the handlers
def find_next_index(a_string:str, substring:str)->list:
"""
return find all index of a substring in a_string in a list
"""
raw_substring = r'\b{0}\b'.format(substring)
matches = re.finditer(raw_substring, a_string)
matches_positions = [match.start() for match in matches]
return matches_positions
# Taken from https://github.com/leandrotoledo/python-telegram-bot/blob/master/telegram/emoji.py
"""This module contains a object that represents an Emoji"""
class Emoji(object):
"""This object represents an Emoji."""
GRINNING_FACE_WITH_SMILING_EYES = b'\xF0\x9F\x98\x81'
FACE_WITH_TEARS_OF_JOY = b'\xF0\x9F\x98\x82'
@neerajvashistha
neerajvashistha / multiprocessing_code.py
Created March 4, 2021 01:25
Simple multi processing based on list
import glob
from multiprocessing import Pool, freeze_support
def multicore_function(function_name, alist, wfname):
'''
this function accept 3 arguments
1.function name: name of that function which will be called.
2.wfname: name of file which will be written.
3.alist: list of data which we breaks in four parts and assigned to different core.
'''
@neerajvashistha
neerajvashistha / dos.py
Last active August 23, 2020 10:19
Multi-Threaded DOS attack
import socket
import random
import Queue
from threading import Thread
import logging
import os
import sys
import time,re,subprocess
reload(sys)
sys.setdefaultencoding('utf8')
@neerajvashistha
neerajvashistha / gupload.sh
Created May 6, 2020 14:13
Google Drive upload facility
#!/bin/bash
# https://github.com/mbrother2/butgg
# curl -o butgg.bash https://raw.githubusercontent.com/mbrother2/butgg/master/butgg.bash
# bash butgg.bash --setup
# Google API client_id: 10xxxxxxxxxxxxxxxxxxxxxxxxxxxx.apps.googleusercontent.com
# Google API client_secret: rxxxxxxxxxxxxxxxxxxxxxxxxl
DatasetsID='1CIsxxxxxxxxxxxxxxxxeswHISm'
DocumentsID='1pA2kxxxxxxxxxxxxxxxxxesjYfXzv7YK'
ModelsID='1E7nJkmxxxxxxxxxxxxxxxxxxxxxxxSo8F3vsqc-'
@neerajvashistha
neerajvashistha / motion.md
Last active April 25, 2020 23:29 — forked from endolith/readme.md
How to stream a webcam to a web browser in Ubuntu

Grr this took hours to figure out. I was trying to install MJPG-streamer and running VLC command lines and all this crap but nothing worked.

First install motion:

~> sudo apt-get install motion

Then create a config file:

~> mkdir ~/.motion

~> nano ~/.motion/motion.conf

@neerajvashistha
neerajvashistha / custom-juno.sh
Created March 28, 2020 05:49 — forked from evertontrindade/custom-juno.sh
Things to do after install Elementary OS 5.0 Juno
cd ~/Downloads
sudo apt-get update && sudo apt-get upgrade
#####################################################################
# Clean-up System
#####################################################################
sudo apt-get purge epiphany-browser epiphany-browser-data
sudo apt-get purge noise
sudo apt-get purge scratch-text-editor
#https://www.osc.edu/resources/getting_started/howto/howto_locally_installing_software
mkdir -p $HOME/local/src $HOME/local/share/lmodfiles
cd $HOME/local/src
wget https://github.com/git/git/archive/v2.9.0.tar.gz
tar zxvf v2.9.0.tar.gz
cd git-2.9.0
git clone https://github.com/CMU-Perceptual-Computing-Lab/openpose
sudo apt purge cmake-qt-gui
sudo apt-get install qtbase5-dev libssl-dev
tar xvzf Downloads/cmake-3.17.0-rc2.tar.gz
cd cmake-3.17.0-rc2.tar.gz
./configure --qt-gui
./bootstrap && make -j`nproc` && sudo make install -j`nproc`