Skip to content

Instantly share code, notes, and snippets.

View alexanderlukanin13's full-sized avatar

Alexander Lukanin alexanderlukanin13

View GitHub Profile

Limitations and pitfalls of @micropython.native

Micropython is fully compatible with Python 3 syntax... except when it isn't.

In this article, we explore one of the "dark corners" of micropython: limitations imposed by @micropython.native decorator.

Documentation on The Native code emitter is brief and a bit vague:

# This script checks which combinations
# of except/raise/with and @micropython.native
# are actually failing on Unix and ESP8266.
import micropython
import sys
class SomeException(Exception):
pass
@alexanderlukanin13
alexanderlukanin13 / avconv.md
Created September 15, 2017 07:05
avconv Cheat Sheet

Extract audio from mp4

avconv -i input.mp4 -vn -acodec pcm_s16le -ar 48000 -ac 2 stream.wav

Replace audio in mp4

avconv -i input.mp4 -i stream.wav -map 0:0 -map 1:0 -vcodec copy -acodec libfdk_aac -b:a 192k -shortest output.mp4
import os.path as op
import re
def read_requirements(filename):
"""
Reads requirements.txt file and returns list of str.
Comments and blank lines are ignored.
"-r" references are respected.
class CustomFormatter(logging.Formatter):
"""Custom logging formatter to write only WARNING, ERROR, CRITICAL."""
def format(self, record):
if record.levelno >= logging.WARNING:
record.msg = '{} {}'.format(record.levelname, record.msg)
return super(CustomFormatter, self).format(record)
import argparse
import sys
import xml.sax
from xml.sax.saxutils import XMLGenerator
class XMLFilter(XMLGenerator):
def __init__(self, output_stream, elements_to_ignore):
XMLGenerator.__init__(self, output_stream, encoding='utf-8')