Skip to content

Instantly share code, notes, and snippets.

Paweł Kozubal pidpawel

Block or report user

Report or block pidpawel

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
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 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 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 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 gist:b79e9efb683d8e06dc11
00:00
00:11
00:22
00:33
00:44
00:55
01:01
01:10
02:02
02:20
View cffi_callback.py
#!/usr/bin/python3
from cffi import FFI
f = FFI()
@f.callback("int(int)")
def pytest(a):
return a*a
@pidpawel
pidpawel / graphite_proxy.py
Created Jul 9, 2015
Supersimple proxy for graphite allowing to inject data without timestamp.
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):
@pidpawel
pidpawel / gist:8133890
Created Dec 26, 2013
repeatable timer in python
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"])
@pidpawel
pidpawel / redirected_stdout.py
Created Dec 7, 2016
Redirected stdout mock, mostly for testing purposes
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):
You can’t perform that action at this time.