Skip to content

Instantly share code, notes, and snippets.

Avatar

Ruurd Moelker RRMoelker

View GitHub Profile
@RRMoelker
RRMoelker / mutli-value-labelled-arduino-serial-plotter-example.ino
Created Jul 25, 2020
Multi value labelled Arduino Serial Plotter example, open serial plotter in Arduino IDE to see the labelled lines plotted over time.
View mutli-value-labelled-arduino-serial-plotter-example.ino
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 Dec 5, 2019
Nunjuck highlight.js tag extension
View highlightjs-tag-nunjucks.js
//
// 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 Oct 24, 2019
Image marker recognition, threshold, opening, connected components and centroid calculation
View detect_marker_still.py
"""
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 Oct 24, 2019
Image marker recognition, threshold, opening, connected components and centroid calculation
View detect_marker_still.py
"""
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 Oct 21, 2019
YUV format picamera real time recording
View rapid-recording.py
# 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 Oct 21, 2019
Capture luminance still Raspberry PI camera
View capture-luminance.py
# 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 Jul 25, 2019
Performs list detail network requests in sequence
View serial_list_detail_example.py
"""
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 Jul 25, 2019
Asyncio pipeline performing concurrent network request
View asyncio_list_detail_pipeline.py
"""
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 Jul 24, 2019
Dead simple asyncio pipeline with second stage served by 3 tasks
View asyncio_pipeline_concurrent.py
"""
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
You can’t perform that action at this time.