Skip to content

Instantly share code, notes, and snippets.

@thomo
thomo / example.yaml
Created October 29, 2019 22:20
Solution to using numbered backreference followed by digit in lineinfile
---
- hosts: localhost
tasks:
- name: create file
copy: src=./demo dest=/tmp/demo
# not working as expected
- name: update xxxx
lineinfile:
dest: /tmp/demo
import collections
import multiprocessing
import time
startzeit = time.time()
Scientist = collections.namedtuple('Scientist', [
'name',
'born',
])
@thomo
thomo / mkdir-tmpfs
Created February 21, 2019 18:58
Creates necessary directories in tmpfs mount points
#!/bin/sh
### BEGIN INIT INFO
# Provides: mkdir-tmpfs
# Required-Start: mountall
# Required-Stop:
# Should-Stop:
# X-Start-Before:
# Default-Start: 1 2 3 4 5
# Default-Stop:
@thomo
thomo / jquery.feedToJSON.js
Created February 11, 2019 20:05
Patch retired Yahoo yql API in MagicMirror v1
//jQuery extension to fetch an rss feed and return it as json via YQL
//created by dboz@airshp.com
(function($) {
$.extend({
feedToJson: function(options, callback) {
if ($.isFunction(options)) {
callback = options;
options = null;
}
@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 / 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 / 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 / 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 / VerifyStaticCallTest.java
Created October 19, 2012 03:29
Unittest to verify that static method is called - PowerMock, Mockito, TestNG
package abc;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.eq;
import java.awt.Component;
import javax.swing.JOptionPane;
import org.powermock.api.mockito.PowerMockito;
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