Skip to content

Instantly share code, notes, and snippets.

View shivanandmn's full-sized avatar

Shivanand shivanandmn

View GitHub Profile
from concurrent.futures import ThreadPoolExecutor, ProcessPoolExecutor
from tqdm import tqdm
def concurrency(function,data,length,method="thread"):
if method=="thread":
print("Mode :",method)
with ThreadPoolExecutor() as pe:
res = list(tqdm(pe.map(function,data),total=length))
return res
elif method=="process":
@shivanandmn
shivanandmn / README.md
Created June 19, 2021 04:06 — forked from hofmannsven/README.md
Git Cheatsheet
@shivanandmn
shivanandmn / condaenv.txt
Created May 31, 2021 10:08 — forked from pratos/condaenv.txt
To package a conda environment (Requirement.txt and virtual environment)
# For Windows users# Note: <> denotes changes to be made
#Create a conda environment
conda create --name <environment-name> python=<version:2.7/3.5>
#To create a requirements.txt file:
conda list #Gives you list of packages used for the environment
conda list -e > requirements.txt #Save all the info about packages to your folder
@shivanandmn
shivanandmn / Installing work-tools in Mac
Created May 30, 2021 00:14
Installing Brew, ImageMagick, mongoldb, robo3t and latex_parse
To install Brew:
-/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Install ImageMagick
-brew uninstall --force imagemagick
-brew install imagemagick@6
-echo 'export PATH="/usr/local/opt/imagemagick@6/bin:$PATH"' >> ~/.bash_profile
-brew link imagemagick@6 --force
If you need to have imagemagick@6 first in your PATH, run:
@shivanandmn
shivanandmn / git basic commands
Last active June 28, 2021 04:08
Basic git commands I am learning while at work.
git branch -a #get all branch
git checkout master #get to the master branch
git checkout -b new_branch #(create and get) new branch
git push -u origin new_branch #push changes to new_branch to repo. for first push -u will set upstream/tracker.
git pull origin guru #pull the repo from guru branch
git add . # add present changes
git commit -m "fdhkfjd" # commit all the added changes.
git push origin guru #then push it
@shivanandmn
shivanandmn / web_browser.py
Created May 24, 2021 13:05
Open URL directly in browser from python code.
import webbrowser
import pandas as pd
df = pd.read_csv("sub.csv")
for i in df["files"].values.tolist():
urls = "http://127.0.0.1:5000/question/"+str(i[:-3])
#opens url in default browser, you can also use open_tab()
webbrowser.get().open(url=urls)
@shivanandmn
shivanandmn / dlib_face_landmarks.py
Created March 5, 2021 00:43
Detecting face and landmarks from image using dlib and opencv
#pip install dlib
#download pretrained dlib file and unzip
#$wget http://dlib.net/files/shape_predictor_68_face_landmarks.dat.bz2
#$bzip2 -d /content/shape_predictor_68_face_landmarks.dat.bz2
import sys
import numpy as np
import cv2
#below line of code is used only in colab
from google.colab.patches import cv2_imshow
@shivanandmn
shivanandmn / download_from_kaggle_api..py
Last active February 25, 2021 23:43
Download the Kaggle Dataset via API in Google Colab Directly.
#install upgraded to get full-dataset, otherwise you may get sample of it.
!pip install -q kaggle==1.5.6
#upload kaggle.json file
from google.colab import files
files.upload()
#must create ~/.kaggle directory and copy kaggle.json to it.
!mkdir ~/.kaggle
!cp kaggle.json ~/.kaggle
@shivanandmn
shivanandmn / compile_makefile.py
Created December 18, 2020 02:48
Compile makefile in google collab using Boost.
#install boost library
!sudo apt-get install libboost-dev
#boost-root or boost-include-directory may be here /usr/include/boost
####follow below with example
"""Consider your installing mesh from https://github.com/MPI-IS/mesh, it has makefile(filename:makefile)"""
#--Cloning repository
!git clone https://github.com/MPI-IS/mesh.git
#--Providing permission to admin rights
!chmod 755 /content/mesh/Makefile
#--move to its project root directory by following command
@shivanandmn
shivanandmn / rename_files.py
Created December 5, 2020 02:37
Changing the list of PDFs files from directory by using digit-only
# changing the names of the files in a directory
import os
import re
path = os.getcwd()
k = os.listdir(path)
for files in k:
x = re.search("\d+", files)
if x is None:
continue