Skip to content

Instantly share code, notes, and snippets.

#replace the file_name.py by given script
ps -eaf| grep file_name.py|awk '{print $2}'|xargs kill -9
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
import json
import csv
file_name = "timestamp.csv"
prev_spo2 = 0
prev_ecg = 0
csvFile = open(file_name, 'w+')
writer = csv.writer(csvFile)
#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.
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)
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
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
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
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