Skip to content

Instantly share code, notes, and snippets.

View scionoftech's full-sized avatar

Sai Kumar Yava scionoftech

  • Hyderabad, India
View GitHub Profile
# Deeplearning Environment Setup for tensorflow_2.3.1 with CUDA 10.1 and cuDNN 7.6.0
### If you have previous installation remove it first.
sudo apt-get purge nvidia*
sudo apt remove nvidia-*
sudo apt remove --autoremove nvidia-cuda-toolkit
sudo rm /etc/apt/sources.list.d/cuda*
sudo apt-get autoremove && sudo apt-get autoclean
sudo rm -rf /usr/local/cuda*
import mysql.connector
from mysql.connector import errorcode
def mysql_connection(f):
def with_connection_(*args, **kwargs):
conn = mysql.connector.connect(
host=host,
user=user,
@scionoftech
scionoftech / jira_fastapi.py
Created February 20, 2021 15:58
Jira API with FastAPI
from jira import JIRA
import uvicorn
from pydantic import BaseModel
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from fastapi.encoders import jsonable_encoder
from fastapi.responses import JSONResponse
# REST API Settings
app = FastAPI(title="JiraTicketApp",
@scionoftech
scionoftech / dir_path.py
Created July 7, 2020 10:13
Get Direcroty path in python
import os
from os.path import dirname, abspath
print("Path at terminal when executing this file")
print(os.getcwd() + "\n")
print("This file path, relative to os.getcwd()")
print(__file__ + "\n")
print("This file full path (following symlinks)")
full_path = os.path.realpath(__file__)
@scionoftech
scionoftech / google_translator_selenium.py
Created January 1, 2020 13:54
Google translator using Selenium
from selenium import webdriver
from selenium.common.exceptions import NoSuchElementException
from selenium.webdriver.chrome.options import Options
import time
try:
language_code = "te"
chrome_options = Options()
#chrome_options.add_argument("--disable-extensions")
#chrome_options.add_argument("--disable-gpu")
chrome_options.add_argument("--headless")
@scionoftech
scionoftech / multiprocessing.py
Created October 10, 2019 06:44
A small python code to use multiprocessing package
from multiprocessing import Pool
# import time
def square(x):
# calculate the square of the value of x
# time.sleep(2)
return x*x
if __name__ == '__main__':
# Define the dataset
@scionoftech
scionoftech / run_on_gpu.py
Created October 3, 2019 10:02
How to run python script on GPU
# pip install --user numba
from numba import jit, cuda
import numpy as np
# to measure exec time
from timeit import default_timer as timer
# normal function to run on cpu
def func(a):
for i in range(10000000):
@scionoftech
scionoftech / GetWiki.py
Last active June 9, 2024 21:33
A small Python Code to get Wikipedia page content in plan text
# https://en.wikipedia.org/wiki/Python_(programming_language)
# https://www.mediawiki.org/wiki/API:Main_page
# 1. Get a plain text representation of either the entire page or the page "extract" straight from the API with the extracts prop
# Note that this approach only works on MediaWiki sites with the TextExtracts extension. This notably includes Wikipedia, but not some smaller Mediawiki sites like, say, http://www.wikia.com/
# You want to hit a URL like
# https://en.wikipedia.org/w/api.php?action=query&format=json&titles=Bla_Bla_Bla&prop=extracts&exintro&explaintext
@scionoftech
scionoftech / rotate_upside_down_text_image.py
Created September 10, 2019 13:12
This python script rotates upside down text image to proper image
from PIL import Image as pillowimg
import numpy as np
import cv2
import pytesseract
# PIL image
def check_orientation(img):
newdata = pytesseract.image_to_osd(np.array(img))
orgi_orientation = re.search('(?<=Rotate: )\d+', newdata).group(0)
# check image orientation
if orgi_orientation != 0:
@scionoftech
scionoftech / sporting macthes elimination formulas
Created September 1, 2019 07:17
This gist is for round robin and Single Eliminaiton rules formulas
***** round robin macthes *****
(Even number participants)
----------
n = no of participants
matches = n(n-1)/2
rounds = n-1
byes = 0
Eg.
participants = 10