This file contains 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 sys | |
import io | |
class RedirectedStdout: | |
def __init__(self): | |
self.old_stdout = sys.stdout | |
self.file = io.StringIO() | |
def __enter__(self): |
This file contains 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
#!/usr/bin/env python2 | |
from twisted.internet.protocol import Factory | |
from twisted.protocols.basic import LineReceiver | |
from twisted.internet import reactor | |
import socket | |
import time | |
class UplinkConnection: | |
def __init__(self, host, port): |
This file contains 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
#!/usr/bin/python3 | |
from cffi import FFI | |
f = FFI() | |
@f.callback("int(int)") | |
def pytest(a): | |
return a*a |
This file contains 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
00:00 | |
00:11 | |
00:22 | |
00:33 | |
00:44 | |
00:55 | |
01:01 | |
01:10 | |
02:02 | |
02:20 |
This file contains 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
#!/usr/bin/python3 | |
hour_lambdas = [ | |
lambda h, m: h==m, | |
lambda h, m: len(set("%.2d%.2d" % (h,m))) == 1, | |
lambda h, m: "%.2d" % h == ("%.2d" % m)[::-1], | |
lambda h, m: h==13 and m==37, | |
lambda h, m: len(set("%.2d" % h)) == 1 and len(set("%.2d" % m)) == 1 | |
] |
This file contains 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
#!/usr/bin/python3 | |
import serial | |
import random | |
import re | |
printer = serial.Serial('/dev/ttyUSB0', 9200) | |
if not printer.isOpen(): | |
printer.open() |
This file contains 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
#!/usr/bin/python2 | |
import pylab as plt | |
import collections | |
import random | |
import time | |
import serial | |
maxsamples = 1000 | |
Y1 = collections.deque([0] * maxsamples) | |
Y2 = collections.deque([0] * maxsamples) |
This file contains 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
TARGET=main | |
ADDITIONAL= | |
LIBS=src/startup_stm32f10x_md.o src/core_cm3.o src/system_stm32f10x.o | |
PERIPH=src/stm32f10x_adc.o src/stm32f10x_bkp.o src/stm32f10x_can.o src/stm32f10x_cec.o src/stm32f10x_crc.o src/stm32f10x_dac.o src/stm32f10x_dbgmcu.o src/stm32f10x_dma.o src/stm32f10x_exti.o src/stm32f10x_flash.o src/stm32f10x_fsmc.o src/stm32f10x_gpio.o src/stm32f10x_i2c.o src/stm32f10x_iwdg.o src/stm32f10x_pwr.o src/stm32f10x_rcc.o src/stm32f10x_rtc.o src/stm32f10x_sdio.o src/stm32f10x_spi.o src/stm32f10x_tim.o src/stm32f10x_usart.o src/stm32f10x_wwdg.o | |
OBJS=$(LIBS) $(PERIPH) $(ADDITIONAL) $(TARGET).o | |
LD_SCRIPT=misc/stm32_flash.ld | |
INCPATH=inc/ | |
OPTIMIZE = O2 | |
TARGET_CPU=cortex-m3 |
This file contains 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 repeatable_timer(delay, func, args=[], kwargs={}): | |
func(*args, **kwargs) | |
t = Timer(delay, repeatable_timer, [delay, func, args, kwargs]) | |
t.start() | |
def hello(ar): | |
print("Hello %s!" % ar) | |
repeatable_timer(1, hello, ["World"]) |