Skip to content

Instantly share code, notes, and snippets.

View zgoda's full-sized avatar

Jarek Zgoda zgoda

  • Poland
  • 07:16 (UTC +02:00)
View GitHub Profile
@zgoda
zgoda / run.py
Created April 24, 2017 12:11
Listen to serial communication in Twisted and route it to TCP connection
import sys
from twisted.internet import reactor
from twisted.internet.serialport import SerialPort
from twisted.internet.protocol import Protocol, Factory
from twisted.python import log
class SerialProtocol(Protocol):
@zgoda
zgoda / main.cpp
Created September 6, 2016 11:29
Basic ESP8266 WiFi frame capture
extern "C" {
#include <user_interface.h>
}
#include <Arduino.h>
/*
802.11 Frame Control on 2 bytes
*/
struct FrameControl {
@zgoda
zgoda / svgsurf.py
Last active August 2, 2022 03:16
Load svg into Pygame image using pynanosvg (https://github.com/ethanhs/pynanosvg)
from svg import Parser, Rasterizer
import pygame
import sys
def load_svg(filename, mode='RGBA', scale=None, size=None, clip_from=None, fit_to=None):
"""Returns Pygame Image object from rasterized SVG
If scale (float) is provided and is not None, image will be scaled.
@zgoda
zgoda / form.html
Created August 1, 2019 07:44
Jinja2 macros to render simple WTForms form with Bulma
{% macro field_description(field) %}
{% if field.errors %}
{% for error in field.errors %}
<p class="help is-danger">{{ error }}</p>
{% endfor %}
{% else %}
{% if field.description %}
<p class="help is-italic">{{ field.description }}</p>
{% endif %}
{% endif %}
@zgoda
zgoda / Dockerfile
Created July 14, 2018 17:00
Build Python 3.7 for ARMv7 from source on amd64
FROM resin/armv7hf-debian-qemu
VOLUME /src
VOLUME /target
RUN echo "deb http://deb.debian.org/debian/ oldstable main contrib non-free" > /etc/apt/sources.list && \
echo "deb http://deb.debian.org/debian/ oldstable-updates main contrib non-free" >> /etc/apt/sources.list && \
echo "deb http://deb.debian.org/debian-security oldstable/updates main" >> /etc/apt/sources.list && \
apt-get update && \
apt-get install -qy --no-install-recommends \

Keybase proof

I hereby claim:

  • I am zgoda on github.
  • I am jzgoda (https://keybase.io/jzgoda) on keybase.
  • I have a public key ASBGSKa3VvDmjq_e6goR-OvFiq2_ayvwCaxQD5ndq6n-Zgo

To claim this, I am signing this object:

"""
This is Python Markdown extension that adds support for centered blocks similar to Vuepress.
"""
class CenterBlockProcessor(BlockProcessor):
RE_START = r'^->'
RE_END = r'<-$'
def test(self, parent, block):
return re.match(self.RE_START, block)
@zgoda
zgoda / hybridprop.py
Created May 31, 2017 09:44
Hybrid property
class Platform(db.Model, ModelMixin):
__tablename__ = 'platform'
id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String(200), nullable=False, index=True)
homepage = db.Column(db.String(200))
description = db.Column(db.Text)
@property
def versions_ordered(self):
return self.versions.order_by(db.desc(PlatformVersion.release_date))