Skip to content

Instantly share code, notes, and snippets.

View tomeaton17's full-sized avatar

Tom Eaton tomeaton17

View GitHub Profile
try:
exponent = len(self.lineEdit.text().split('.')[1])
rounded_answer = round(self.answer, exponent)
except:
divisor = math.floor(self.answer)
if len(str(divisor)) == 2:
divisor = 10
elif len(str(divisor)) == 3:
divisor = 100
rounded_answer = self.answer / divisor
@tomeaton17
tomeaton17 / lookuptable.h
Created January 17, 2017 16:40
Lookup table for Bourns encoder
/*
* This file decodes the output of a Bourns EAW0J-B24-AE0128L 8-bit Absolute Contacting Encoder.
* Index this table using the 8-bit value read from encoder, and the output is
* the position, from 0-127.
*
* Direction info: If position=0 corresponds with robot steerable-wheel pointing straight ahead,
* then position=1 is a tiny clockwise rotation of the steering wheel, i.e. robot is steering to
* the right when travelling forwards.
*
* Half the possible numbers aren't used. In the table these are set to 255 = x'FF'.
@tomeaton17
tomeaton17 / stunnel.conf
Created February 6, 2017 18:59
openvpn over stunnel
cert = /etc/stunnel/stunnel.pem
pid = /var/run/stunnel.pid
output = /var/log/stunnel
[openvpn]
accept=443
connect=127.0.0.1:1194
[!] Server is down
[ ] Executing cron jobs
[ ] Cron jobs completed in 0 seconds
[ ] Waiting 86400 seconds
[ ] Running on Windows 6.2
[.] Reading configuration from file stunnel.conf
[.] UTF-8 byte order mark detected
[.] FIPS mode disabled
[ ] Compression disabled
[ ] Snagged 64 random bytes from C:/.rnd
@tomeaton17
tomeaton17 / lettercount.py
Created February 7, 2017 15:49
Doesn't work
import math
values1 = [0,3,3,5,4,4,3,5,5,4,3,6,6,8,8,7,7,9,8,8]
values2 = [0,3,6,6,5,5,5,7,6,6]
values3 = [0,10,10,12,11,11,10,12,12,11]
def returnLetterCount(n):
digits = int(len(str(n)))
letterCount = 0
if n < 20:
letterCount += values1[n]
@tomeaton17
tomeaton17 / lettercount.py
Created February 7, 2017 15:50
Not working
import math
values1 = [0,3,3,5,4,4,3,5,5,4,3,6,6,8,8,7,7,9,8,8]
values2 = [0,3,6,6,5,5,5,7,6,6]
values3 = [0,10,10,12,11,11,10,12,12,11]
def returnLetterCount(n):
digits = int(len(str(n)))
letterCount = 0
if n < 20:
letterCount += values1[n]
@tomeaton17
tomeaton17 / lettercount.py
Created February 7, 2017 15:50
Doesn't work
import math
values1 = [0,3,3,5,4,4,3,5,5,4,3,6,6,8,8,7,7,9,8,8]
values2 = [0,3,6,6,5,5,5,7,6,6]
values3 = [0,10,10,12,11,11,10,12,12,11]
def returnLetterCount(n):
digits = int(len(str(n)))
letterCount = 0
if n < 20:
letterCount += values1[n]
@tomeaton17
tomeaton17 / maximumpathsum.py
Created February 7, 2017 21:30
Not working
f = open("trianglepath.txt", "r")
triangle = []
newTriangle = []
for x in f.readlines():
triangle.append([int(n) for n in x.split(" ")])
print(triangle)
tempNumbers = 0
tempList = [4, 62, 98, 27, 23, 9, 70, 98, 73, 93, 38, 53, 60, 4, 23]
secondaryList = []
for z in range(len(triangle) -1, -1, -1):
Linking build/project.elf
build/obj/HAL/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_uart.o: In function `HAL_UART_Transmit_DMA':
/home/tom/shiny-octo/HAL/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_uart.c:964: undefined reference to `HAL_DMA_Start_IT'
build/obj/HAL/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_uart.o: In function `HAL_UART_Receive_DMA':
/home/tom/shiny-octo/HAL/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_uart.c:1035: undefined reference to `HAL_DMA_Start_IT'
build/obj/HAL/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_uart.o: In function `HAL_UART_DMAStop':
/home/tom/shiny-octo/HAL/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_uart.c:1156: undefined reference to `HAL_DMA_Abort'
/home/tom/shiny-octo/HAL/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_uart.c:1161: undefined reference to `HAL_DMA_Abort'
build/obj/main.o: In function `main':
/home/tom/shiny-octo/main.c:55: undefined reference to `HAL_UART_TransmitIT'
@tomeaton17
tomeaton17 / coefficients.py
Created September 12, 2017 11:04
Calculates the Steinhart-Hart coefficients given 3 known resistance temperature pairs.
"""
Calculates the Steinhart-Hart coefficients for given resistance and temperature pairs.
"""
import sys
import math
titleString = """\
______ _ __ __ __ __ __ _____ _______ _ __
/ __/ /____ (_)__ / / ___ _____/ /_____/ // /__ _____/ /_ / ___/__ ___ / _/ _(_)___(_)__ ___ / /____
_\ \/ __/ -_) / _ \/ _ \/ _ `/ __/ __/___/ _ / _ `/ __/ __/ / /__/ _ \/ -_) _/ _/ / __/ / -_) _ \/ __(_-<