Skip to content

Instantly share code, notes, and snippets.

@thomo
thomo / isDateTimeValid.lua
Created March 30, 2018 08:45
Small function to verify validity of datetime (to use with https://gist.github.com/thomo/8ac2bceb6400eb8868c651e8897be958)
function isDateTimeValid(second, minute, hour, day, month, year)
function check(x, xmin, xmax)
return x >= xmin and x <= xmax
end
return check(second, 0, 59) and check(minute, 0, 59) and check(hour, 0, 23) and
check(day, 1, 31) and check(month, 1, 12) and check(year, 0, 99)
end
@thomo
thomo / datetime2epoch.lua
Last active September 1, 2023 17:49
Convert from human readable date/time to epoch timestamp
-- The MIT License (MIT)
-- Copyright (c) 2018,2020 Thomas Mohaupt <thomas.mohaupt@gmail.com>
-- year: 2-digit (means 20xx) or 4-digit (>= 2000)
function datetime2epoch(second, minute, hour, day, month, year)
local mi2sec = 60
local h2sec = 60 * mi2sec
local d2sec = 24 * h2sec
-- month to second, without leap year
local m2sec = {
@thomo
thomo / DirectoryCollector.java
Created November 10, 2017 15:33
Java Demo Code
public class DirectoryCollector implements Collector {
private final PlainFileFilter fileFilter;
public DirectoryCollector(PlainFileFilter ff) {
fileFilter = ff;
}
@Override
public List<FileData> collect(Path path) {
@thomo
thomo / start.cmd
Created January 18, 2017 16:51
cscript mit watchdog
@ECHO off
cd "D:\Daten\Skripte\"
start /min cmd /c watchdog.cmd
c:\Windows\SysWOW64\cscript.exe "D:\Daten\Skripte\Sync.vbs" %*
del watchdog_starttimestamp.ts 2> nul
@thomo
thomo / user.lua
Last active November 28, 2021 11:07
Wifi Scanner with ESP8266 + TFT ST7735B (NodeMCU)
-- Tested with
-- NodeMCU 3.0.0.0 built on nodemcu-build.com provided by frightanic.com
-- branch: release
-- commit: d4ae3c364bd8ae3ded8b77d35745b7f07879f5f9
-- release:
-- release DTS: 202105102018
-- SSL: false
-- build type: float
-- LFS: 0x0 bytes total capacity
-- modules: bit,file,gpio,net,node,spi,tmr,uart,ucg,wifi
esptool.py --port /dev/tty.wchusbserialfa1* --baud 115200 write_flash 0x00000 nodemcu-master-10-modules-2016-08-21-14-41-09-float.bin 0x3fc000 esp_init_data_default.bin -fm=dio -fs=32m
@thomo
thomo / Sandbox Anleitung.md
Created April 25, 2016 12:36
Anleitung für die Einrichtung einer "Terraforming Sandbox" entsprechend http://idav.ucdavis.edu/~okreylos/ResDev/SARndbox/
  • Terminal Fenster öffnen (Symbol ">_")

  • "./start_sandbox.sh" eingeben -> enter

  • es erscheint ein Fenster "RawKinectViewer"

    • links: "Tiefenbild" der Kinect (eher blau)

    • rechts: Kamarabild der Kinect

    • Ausschnitt des Tiefenbilds vergößern, so dass Sandbox möglichst groß zu sehen ist

@thomo
thomo / user_dht22_influxdb.lua
Last active October 16, 2017 13:46
ESP-01 + DHT22: send temperature and humidity to influxdb
--
-- send DHT22 sensor values to influxdb database
--
LOCATION = "upstairs.bathroom"
-- #################################
INFLUXDB_HOST = "sun.thomo.de"
INFLUXDB_DB = "lhw5"
@thomo
thomo / user_dht22.lua
Last active April 9, 2016 07:07
DHT22 example (Lua 5.4.1, NodeMCU SDK 1.4.0)
-- pin = 3 -- GPIO0
pin = 4 -- GPIO2
FLOAT_FIRMWARE = (1/3) > 0
function readDht()
status, temp, humi, temp_dec, humi_dec = dht.read(pin)
if status == dht.OK then
if FLOAT_FIRMWARE then
-- Float firmware using this example
@thomo
thomo / init.lua
Last active November 29, 2021 15:17
NodeMCU init.lua with interrupt opportunity
-- Tested with
-- NodeMCU 3.0.0.0 built on nodemcu-build.com provided by frightanic.com
-- branch: release
-- commit: d4ae3c364bd8ae3ded8b77d35745b7f07879f5f9
-- release:
-- release DTS: 202105102018
-- SSL: false
-- build type: float
-- LFS: 0x0 bytes total capacity
-- modules: bit,file,gpio,net,node,spi,tmr,uart,ucg,wifi