Skip to content

Instantly share code, notes, and snippets.

Jarek Zgoda zgoda

  • Czubajowizna, PL
Block or report user

Report or block zgoda

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
@zgoda
zgoda / form.html
Created Aug 1, 2019
Jinja2 macros to render simple WTForms form with Bulma
View form.html
{% 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 Jul 14, 2018
Build Python 3.7 for ARMv7 from source on amd64
View Dockerfile
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 \
@zgoda
zgoda / svgsurf.py
Last active May 9, 2019
Load svg into Pygame image using pynanosvg (https://github.com/ethanhs/pynanosvg)
View svgsurf.py
from svg import Parser, Rasterizer
def load_svg(filename, 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.
If size (w, h tuple) is provided, the image will be clipped to specified size.
If clip_from (x, y tuple) is provided, the image will be clipped from specified point.
If fit_to (w, h tuple) is provided, image will be scaled to fit in specified rect.
@zgoda
zgoda / hybridprop.py
Created May 31, 2017
Hybrid property
View hybridprop.py
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))
@zgoda
zgoda / run.py
Created Apr 24, 2017
Listen to serial communication in Twisted and route it to TCP connection
View run.py
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 Sep 6, 2016
Basic ESP8266 WiFi frame capture
View main.cpp
extern "C" {
#include <user_interface.h>
}
#include <Arduino.h>
/*
802.11 Frame Control on 2 bytes
*/
struct FrameControl {
@zgoda
zgoda / runtestscmd.py
Last active Dec 21, 2015
Flask-Script command to run test suite.
View runtestscmd.py
import unittest
from flask.ext.script import Command, Option
class RunTests(Command):
option_list = (
Option('labels', nargs='*',
help='specify individual tests to be run, in form module_name[.TestCaseName[.test_method]]'),
You can’t perform that action at this time.