Skip to content

Instantly share code, notes, and snippets.

View marcelstoer's full-sized avatar
👨‍👩‍👧‍👧
The Earth was made round so that we would not see too far down the road - K.B.

Marcel Stör marcelstoer

👨‍👩‍👧‍👧
The Earth was made round so that we would not see too far down the road - K.B.
View GitHub Profile
@marcelstoer
marcelstoer / debounce.lua
Last active October 3, 2018 14:31
Debounce with NodeMCU with two separate functions for down/up trigger
-- inspired by: http://www.esp8266-projects.com/2015/03/buttons-pushbuttons-and-debouncing-story.html
local GPIO14 = 5
local debounceDelay = <however-many-ms-your-sensor-requires>
local debounceAlarmId = <0-6>
gpio.mode(GPIO14, gpio.INT, gpio.PULLUP)
gpio.trig(GPIO14, "down", doorLocked)
function doorLocked()
-- don't react to any interupts from now on and wait 50ms until the interrupt for the up event is enabled
-- within that 50ms the switch may bounce to its heart's content
# see https://frightanic.com/web-authoring/website-hosting-with-git-a-tutorial/ for the full picture
#
# create remote repository
ssh user@host.com
mkdir repos
cd repos
mkdir example.git
cd example.git
git --bare init
# create local clone on development machine
@marcelstoer
marcelstoer / debounce-with-tmr.lua
Last active December 7, 2019 06:05
NodeMCU debounce based on timer with GPIO pullup
-- inspired by https://github.com/hackhitchin/esp8266-co-uk/blob/master/tutorials/introduction-to-gpio-api.md
-- and http://www.esp8266.com/viewtopic.php?f=24&t=4833&start=5#p29127
local pin = 4 --> GPIO2
function debounce (func)
local last = 0
local delay = 50000 -- 50ms * 1000 as tmr.now() has μs resolution
return function (...)
local now = tmr.now()
@marcelstoer
marcelstoer / publish-bme280-data-from-raspberry_pi-to-thingspeak.py
Last active July 24, 2020 21:26
Publish BME280 data from Raspberry Pi to ThingSpeak
import thingspeak # from https://thingspeak.readthedocs.io/en/latest/
import bme280 # from https://www.raspberrypi-spy.co.uk/2016/07/using-bme280-i2c-temperature-pressure-sensor-in-python/
# return the Pi CPU/GPU temperature in degree Celcius; it's a SoC and thus there's no need to read both, see
# https://www.cyberciti.biz/faq/linux-find-out-raspberry-pi-gpu-and-arm-cpu-temperature-command/#comment-796904
def get_temp():
with open('/sys/class/thermal/thermal_zone0/temp', 'r') as infile:
return float(infile.read()) * 1e-3
ch = thingspeak.Channel(275145, "*********", "*********")
@marcelstoer
marcelstoer / SamlAssertionExtractor.java
Created September 7, 2020 13:50
SamlAssertionExtractor.java
import com.google.common.base.Preconditions;
import lombok.extern.slf4j.Slf4j;
import net.shibboleth.utilities.java.support.xml.ParserPool;
import net.shibboleth.utilities.java.support.xml.XMLParserException;
import org.apache.commons.lang3.StringUtils;
import org.opensaml.core.config.InitializationException;
import org.opensaml.core.config.InitializationService;
import org.opensaml.core.xml.config.XMLObjectProviderRegistrySupport;
import org.opensaml.core.xml.io.Unmarshaller;
import org.opensaml.core.xml.io.UnmarshallerFactory;
@marcelstoer
marcelstoer / wifimanager.h
Created October 17, 2020 21:02
ESP32 WiFi Manager based on ESPAsync_WiFiManager
/**************************************************************************************************/
/* */
/* Adaptation and simplification of the blue-print sketch at */
/* https://github.com/khoih-prog/ESPAsync_WiFiManager/tree/master/examples/Async_ConfigOnSwitch */
/* */
/**************************************************************************************************/
#include <esp_wifi.h>
#include <WiFi.h>
#include <WiFiClient.h>
import okhttp3.Credentials
import okhttp3.OkHttpClient
import okhttp3.Request
import okhttp3.Response
import org.json.JSONObject
import java.time.Duration
import java.time.Instant
import java.util.logging.Logger
// Inspired by https://www.pimwiddershoven.nl/entry/request-an-api-bearer-token-from-gitlab-jwt-authentication-to-control-your-private-docker-registry
$ ssh <user>@<mac-without-screen>
$ sudo defaults write /var/db/launchd.db/com.apple.launchd/overrides.plist com.apple.screensharing -dict Disabled -bool false
$ sudo launchctl load /System/Library/LaunchDaemons/com.apple.screensharing.plist
/System/Library/LaunchDaemons/com.apple.screensharing.plist: Service is disabled
$ sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.screensharing.plist
@marcelstoer
marcelstoer / Arduino-uint64ToString.c
Created April 9, 2018 20:37
Arduino uint64ToString
// source: https://github.com/markszabo/IRremoteESP8266/blob/master/src/IRutils.cpp#L48
String uint64ToString(uint64_t input) {
String result = "";
uint8_t base = 10;
do {
char c = input % base;
input /= base;
if (c < 10)
@marcelstoer
marcelstoer / validate-email.php
Created May 12, 2016 19:52
How to validate email with PHP
<?php
// inspired by a note at http://php.net/manual/en/function.getmxrr.php
// further inspiration from https://github.com/webdigi/SMTP-Based-Email-Validation
function validateEmail($email)
{
$emailValid = false;
$domain = extractFullyQualifiedDomainFromEmail($email);
$mxHost = findPreferredMxHostForDomain($domain);