View redirected_stdout.py
import sys | |
import io | |
class RedirectedStdout: | |
def __init__(self): | |
self.old_stdout = sys.stdout | |
self.file = io.StringIO() | |
def __enter__(self): |
View graphite_proxy.py
#!/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): |
View cffi_callback.py
#!/usr/bin/python3 | |
from cffi import FFI | |
f = FFI() | |
@f.callback("int(int)") | |
def pytest(a): | |
return a*a |
View gist:b79e9efb683d8e06dc11
00:00 | |
00:11 | |
00:22 | |
00:33 | |
00:44 | |
00:55 | |
01:01 | |
01:10 | |
02:02 | |
02:20 |
View godziny.py
#!/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 | |
] |
View bash_printer.py
#!/usr/bin/python3 | |
import serial | |
import random | |
import re | |
printer = serial.Serial('/dev/ttyUSB0', 9200) | |
if not printer.isOpen(): | |
printer.open() |
View live_graph.py
#!/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) |
View Makefile_cmsis
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 |
View gist:8133890
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"]) |