Skip to content

Instantly share code, notes, and snippets.

View alacret's full-sized avatar
😎
Conquering the World!

Angel Lacret alacret

😎
Conquering the World!
View GitHub Profile
import serial
import io
import time
import os
# if __name__ == '__main__':
# try:
# # configure the serial connections (the parameters differs on the device you are connecting to)
# with serial.Serial(port='/dev/ttys000', baudrate=9600, timeout=1,
# xonxoff=False, rtscts=False, dsrdtr=True) as s:
function partialKeys (obj) {
const keys = Object.keys(obj);
keys.sort();
const handler = {
get(obj, name) {
for(let i = 0, j= keys.length; i<j;i++){
if(keys[i].startsWith(name))
return obj[keys[i]];
}
},
const S = {
TAB : "\t",
SPACE : " ",
BREAK : "\n",
}
// S.TAB = "[tab]";
// S.SPACE = "[space]";
// S.BREAK = "[LF]";
function whitespaceNumber(n) {
if (n === 0)
def tetranacci(n=5, output=[0, 0, 0], number=1):
x = n
while n > 0:
output.append(number)
if len(output) >= 4:
number = output[len(output) - 1] + output[len(
output) - 2] + output[len(output) - 3] + output[len(output) -
4]
n -= 1
return output[:x]
def extract_name(line):
start = line.find('<')
stop = line.find('>')
return line[start + 1:stop], line[:start] + line[stop + 1:]
def extract_phone(line):
"""
TA-1234123 +1-123-123-1233
"""
plus_pos = line.find('+')
def generate_hashtag(s):
# Simple edge cases
if s == '':
return False
cache = []
for i in s.split(' '):
if i != '':
cache.append(i.capitalize())
result = ''.join(cache)
def divide_list(numbers):
half = len(numbers) // 2
return numbers[:half], numbers[half:]
def add_lists(list_a, list_b):
if len(list_a) < len(list_b):
list_a.insert(0,0)
results = []
for i in range(len(list_a)):
const getDivisors = (num) => {
const divisors = [1];
for (let i = 2; i <= num; i++)
if (num % i === 0 )
divisors.push(i)
return divisors;
}
function procArrInt(listNum) {
def move_right(x,y):
return x + 1, y
def move_left(x,y):
return x - 1,y
def move_up(x,y):
return x, y - 1
def move_down(x,y):
return x, y + 1
R, L, U, D = 1,2,3,4
COLOR_CODE = { 0: 'black', 1: 'brown', 2: 'red', 3: 'orange',
4: 'yellow', 5: 'green', 6: 'blue', 7: 'violet', 8: 'gray',
9: 'white'}
def encode_resistor_colors(ohms_string):
# your code here
ohms = ohms_string.split(' ')[0]
trailing_zeros = 0
last_index = len(ohms) - 1
last = ohms[last_index]