Skip to content

Instantly share code, notes, and snippets.

View not-much-io's full-sized avatar

Kristo Koert not-much-io

View GitHub Profile
def len_of_bytes_as_repr(b):
return str_to_bytes(str(hex(int(len(bytes_to_str(b)) / 2))[2:]).zfill(3).upper())
import serial
from threading import Thread
from py_test_framework_utils.framework_utils import bytes_to_str
from uart_tool.telegram import Telegram
from time import sleep
class _LoggingTool:
def __init__(self, com_port, log_file_path):
self._log_file_path = log_file_path
(defn sum-digits [number-str]
(reduce + (map #(Character/digit % 10) number)))
vs.
def digits_sum(number_str):
sum = 0
for c in number_str:
sum += int(c)
def __init__(self, telegram):
try:
{str: self._init_from_str,
dict: self._init_from_dict,
bytearray: self._init_from_bytearray}[type(telegram)](telegram)
except KeyError:
raise ValueError("Invalid type of constructor argument")
import serial
from threading import Thread
from py_test_framework_utils.framework_utils import bytes_to_str
from abc import ABCMeta, abstractmethod, abstractproperty
class _LoggingTool:
def __init__(self, com_port, log_file_path):
self._log_file_path = log_file_path
self._serial_conn = serial.Serial(port=com_port, baudrate=115200)
import java.util.*;
/*
What you need to do:
1) Write a method to build a tree from the left parenthetic string representation (return the root node of the tree)
Left parenthetic string representation:
#------------------------------------------Wrapping DLL------------------------------------------
#Create an object that contains the C/C++ lib
optolyzer_dll = CDLL("libBOoptoLyzer_dll.so")
#Define functions and c types for argument and return values in lib
#int Connect(char* ip, unsigned int port);
dll_connect = optolyzer_dll.Connect
dll_connect.argtypes = [c_char_p, c_uint]
import time
from datetime import datetime
def get_time():
"""ex. get_time() -> [19, 05, 10]"""
pass
def _int_to_digits(time_int):
import RPi.GPIO as GPIO
from time import sleep
clock = 27
data = 22
# Tell the GPIO module to use GPIO numbering used by processor
GPIO.setmode(GPIO.BCM)
GPIO.setup(clock, GPIO.OUT)
import RPi.GPIO as GPIO
from time import sleep
clock = 27
data = 22
# Tell the GPIO module to use GPIO numbering used by processor
GPIO.setmode(GPIO.BCM)
GPIO.setup(clock, GPIO.OUT)