Skip to content

Instantly share code, notes, and snippets.

View shivankgtm's full-sized avatar
💭
We believe in god else it's all about Data.

Shivank Gautam shivankgtm

💭
We believe in god else it's all about Data.
View GitHub Profile
def decorator_for_print(function):
def print_args(*args):
print('GIVEN arguments are ', args)
return function(args)
return print_args
@decorator_for_print
def func(alist):
return alist
@decorator2
@decorator1
def func(arg1, arg2, ...):
pass
#IS EQUIVALENT OF
def func(arg1, arg2, ...):
pass
func = decorator2(decorator1(func))
import time
import numpy as np
np_array = np.arange(1, 1000000)
python_list = range(1, 1000000)
np_start = time.time()
result = [i**2 for i in np_array]
np_end = time.time()
print('Total time taken by numpy = ', np_end-np_start)
import time
from selenium import webdriver
import pandas as pd
#from webdriver_manager.chrome import ChromeDriverManager # Only required in Linux
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
from selenium.common.exceptions import TimeoutException
data = pd.read_excel(r'data.xlsx')
import time
from selenium import webdriver
import pandas as pd
from webdriver_manager.chrome import ChromeDriverManager # Only required in Linux
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
from selenium.common.exceptions import TimeoutException
import time
from selenium import webdriver
import pandas as pd
#from webdriver_manager.chrome import ChromeDriverManager # Only required in Linux
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
from selenium.common.exceptions import TimeoutException
import os
import pandas as pd
path = '/home/shivank98/Desktop/Motion' # Set the path for folder where all pdf are kept.
files = []
for r, d, f in os.walk(path):
for file in f:
if '.pdf' in file:
files.append(os.path.join(r, file))
import time
from selenium import webdriver
import pandas as pd
# from webdriver_manager.chrome import ChromeDriverManager # Only required in Linux
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
from selenium.common.exceptions import TimeoutException
import requests
from bs4 import BeautifulSoup
finalList = []
pages = [ 'https://simple.wikipedia.org/wiki/Category:Natural_resources',
'https://simple.wikipedia.org/wiki/Category:Hydrogen_compounds',
'https://simple.wikipedia.org/wiki/Category:Oxygen_compounds',
'https://simple.wikipedia.org/wiki/Category:Oxides']
for i in range(len(pages)):
page = requests.get(pages[i])
soup = BeautifulSoup(page.content, 'html.parser')
array = [1,3,6,10,15,32,43,46,100,150,170,290] # Given
def BinarySearch(array, target):
n = len(array) # length of array.
left = 0 # at starting are search space is
right = n-1 # full array(from index 0 to n-1)
# Now remember what we talk about condition for search.
# If are left and right index are same or they are at same positon
# It is time to stop.