This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class cirQueue(): | |
def __init__(self, size): | |
self.size = size | |
self.array = [None] * self.size | |
self.front = -1 | |
self.rear = -1 | |
def isFull(self): | |
if self.front == self.rear + 1 and self.front != -1: | |
return True |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class queue(): | |
def __init__(self, size=10): | |
self.size = size | |
self.array = [None for _ in range(self.size)] | |
self.front = -1 | |
self.rear = -1 | |
def isFull(self): | |
if self.rear >= self.size -1 and self.front == 0: | |
return True |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class stack: | |
def __init__(self, size=10): | |
self.size = size | |
self.array = [None]*self.size | |
self.i = -1 | |
def push(self, element): | |
if self.isFull(): | |
raise Exception("Array out of bound") | |
self.i += 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def partition(array, low, high): | |
pivot = array[high] | |
i = low - 1 | |
for j in range(low , high): | |
if array[j] < pivot: | |
print(array) | |
i = i + 1 | |
array[i], array[j] = array[j], array[i] | |
array[high], array[i + 1] = array[i + 1], array[high] | |
return i + 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def mergeSort(array): | |
if len(array) > 1: | |
r = len(array)//2 | |
left_half = array[:r] | |
right_half = array[r:] | |
i = j = k = 0 | |
mergeSort(right_half) | |
mergeSort(left_half) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from time import time | |
def calculate_time(f): | |
def wrapper(*args, **kwargs): | |
initial_time = time() | |
output = f(*args, **kwargs) | |
time_taken = time() - initial_time | |
print("the time taken by {function} is {time} and output is {output}".format(function=f.__name__, time=time_taken, output=output)) | |
return output | |
return wrapper |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#1. Place the script in the phone's internal storage. | |
#2.Give the command 'adb tcpip 5555' in the command line. This has to be given when the phone is connected to the laptop via usb cable. | |
#If successful, you will get the print "restarting in TCP mode port: 5555" | |
#3. Switch On the phone's hotspot and connect laptop to the hotspot. | |
#4. You can remove the usb cable now. | |
#5. Just check whether you can connect adb over tcpip by giving the below command. | |
#adb connect <ip of phone>:5555 | |
#6. Login to adb shell using command | |
#adb shell | |
#7. Go to the place where you have kept the script and run it using the below command. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
import csv | |
file_name = "timestamp.csv" | |
prev_spo2 = 0 | |
prev_ecg = 0 | |
csvFile = open(file_name, 'w+') | |
writer = csv.writer(csvFile) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def retry(retry_count=2, time_out=1): | |
def decorator(func): | |
def wrapper(*args, **kwargs): | |
init_time = time() | |
for i in range(1, retry_count): | |
print("loop count: %d" % i) | |
while (time() - init_time <= time_out): | |
# if the execution happends we return output | |
# Incase it failes we will retrun the funciton for timeout seconds | |
# If it executes without error in any of the retruns we return the output |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#replace the file_name.py by given script | |
ps -eaf| grep file_name.py|awk '{print $2}'|xargs kill -9 |