Skip to content

Instantly share code, notes, and snippets.

View RRMoelker's full-sized avatar

Ruurd Moelker RRMoelker

View GitHub Profile
@RRMoelker
RRMoelker / mutli-value-labelled-arduino-serial-plotter-example.ino
Created July 25, 2020 09:49
Multi value labelled Arduino Serial Plotter example, open serial plotter in Arduino IDE to see the labelled lines plotted over time.
int t = 0;
void setup() {
Serial.begin(38400);
}
void loop() {
double a = sin(t / 100.0);
double b = cos(t / 110.0);
double c = sin(t / 50.0) + 1.0;
@RRMoelker
RRMoelker / highlightjs-tag-nunjucks.js
Created December 5, 2019 15:22
Nunjuck highlight.js tag extension
//
// Allows highlighting of code blocks in Nunjucks template.
// https://mozilla.github.io/nunjucks/api.html#custom-tags
//
const nunjucks = require('nunjucks');
const hljs = require('highlight.js');
function HighlightJsExtension() {
this.tags = ['highlightjs'];
@RRMoelker
RRMoelker / detect_marker_still.py
Last active October 24, 2019 16:44
Image marker recognition, threshold, opening, connected components and centroid calculation
"""
Detect markers in image and display results
"""
import time
import numpy as np
import matplotlib.pyplot as plt
from scipy import ndimage
from skimage import io
from skimage import morphology
@RRMoelker
RRMoelker / detect_marker_still.py
Created October 24, 2019 15:32
Image marker recognition, threshold, opening, connected components and centroid calculation
"""
Detect markers in image and display results
"""
import time
import numpy as np
import matplotlib.pyplot as plt
from scipy import ndimage
from skimage import io
from skimage import morphology
@RRMoelker
RRMoelker / rapid-recording.py
Created October 21, 2019 13:22
YUV format picamera real time recording
# python3
# based on https://raspberrypi.stackexchange.com/questions/58871/pi-camera-v2-fast-full-sensor-capture-mode-with-downsampling/58941#58941
import time
import picamera
import numpy as np
from PIL import Image
RECORD_TIME = 5 # number of seconds to record
WRITE_IMAGES = False
@RRMoelker
RRMoelker / capture-luminance.py
Last active March 22, 2023 15:37
Capture luminance still Raspberry PI camera
# python3
# based on https://raspberrypi.stackexchange.com/questions/58871/pi-camera-v2-fast-full-sensor-capture-mode-with-downsampling/58941#58941
import time
import picamera
import numpy as np
from PIL import Image
RESOLUTION = (1640, 1232)
# Calculate the actual image size in the stream (accounting for rounding
@RRMoelker
RRMoelker / serial_list_detail_example.py
Created July 25, 2019 16:16
Performs list detail network requests in sequence
"""
Example program that retrieves sink speed for first 100 meetbouten.
First fetches ids using list endpoint and calls detail endpoint for each id.
p.s. A meetbout is a physical screw on the outside of a building which is used to determine the "sink" rate of the
structure.
"""
import logging
import json
import sys
@RRMoelker
RRMoelker / asyncio_list_detail_pipeline.py
Created July 25, 2019 16:15
Asyncio pipeline performing concurrent network request
"""
Asyncio pipeline example program that retrieves sink speed for first 100 meetbouten.
First fetches ids using list endpoint and calls detail endpoint for each id.
p.s. A meetbout is a physical screw on the outside of a building which is used to determine the "sink" rate of the
structure.
"""
import asyncio
import json
import random
@RRMoelker
RRMoelker / asyncio_pipeline_concurrent.py
Created July 24, 2019 18:46
Dead simple asyncio pipeline with second stage served by 3 tasks
"""
Example program for asyncio pipeline with concurrent stages.
Program takes string as input and converts it to upper case.
An overview of the stages:
step B-1
step A -> step B-2 -> step C
step B-3