Skip to content

Instantly share code, notes, and snippets.

@richturner
richturner / WeatherAssetCalculations.groovy
Created October 27, 2022 16:42
Example OpenRemote calculated attribute groovy rule
package org.openremote.setup.load1
import org.openremote.manager.rules.RulesBuilder
import org.openremote.model.asset.impl.WeatherAsset
import org.openremote.model.attribute.AttributeEvent
import org.openremote.model.query.AssetQuery
import org.openremote.model.rules.AssetState
import org.openremote.model.rules.Assets
import org.openremote.model.rules.Notifications
import org.openremote.model.rules.Users
@richturner
richturner / selfsigned_generator.sh
Created June 8, 2020 19:21
openssl generate selfsigned PEM cert
#!/usr/bin/env sh
openssl req -x509 -new -nodes -subj "/C=GB/CN=OpenRemote Demo Cert/O=OpenRemote/OU=Demo" -addext "subjectAltName = DNS:localhost,IP:127.0.0.1" -newkey rsa:2048 -keyout localhost.pem -out localhost.pem -days 10950
@richturner
richturner / BasicFixAuthenticationMechanism.java
Created June 4, 2020 15:46
An authentication mechanism for Undertow to fix the broken BasicAuthenticationMechanism and conform to RFC2617
/**
* This is a fix for {@link BasicAuthenticationMechanism} which doesn't conform to RFC2617.
* see: https://issues.redhat.com/browse/UNDERTOW-1727
* <p>
* When no {@link io.undertow.util.Headers#AUTHORIZATION} header is supplied then a 401 is returned with
* {@link io.undertow.util.Headers#WWW_AUTHENTICATE} header unless {@link #silent} is true in which case
* a 403 will be returned.
* <p>
* When an {@link io.undertow.util.Headers#AUTHORIZATION} header is supplied and is valid then the request
* can proceed otherwise a 403 is returned.
@richturner
richturner / circuit.diagram
Created April 7, 2020 19:39
VMB8PBU as output module
VMB8PBU COMMON (+) ----R1-------- OPTO-COUPLER +
|
C1
|
VMB8PBU CH (-) -------------- OPTO-COUPLER -
R1 = 220Ohm
C1 = 330uF
OPTO-COUPLER = Either a standalone opto-coupler as a switch (must have very low current draw) or an opto-coupler on a
@richturner
richturner / VirtualSenorGroovyRule.groovy
Created February 11, 2020 11:05
An example Groovy rule for OpenRemote 3.0 for periodically generating sensor values
package demo.rules
import org.openremote.manager.rules.RulesBuilder
import org.openremote.model.asset.*
import org.openremote.model.attribute.*
import org.openremote.model.value.*
import org.openremote.model.rules.*
import java.util.logging.*
Logger LOG = binding.LOG
@richturner
richturner / wiegand.c
Created October 13, 2019 10:55 — forked from hsiboy/wiegand.c
Wiegand API for Raspberry Pi
/*
* Wiegand API Raspberry Pi
* By Kyle Mallory All rights reserved.
* 12/01/2013
* Based on previous code by Daniel Smith (www.pagemac.com) and Ben Kent (www.pidoorman.com)
* Depends on the wiringPi library by Gordon Henterson: https://projects.drogon.net/raspberry-pi/wiringpi/
*
* This is linked with -lpthread -lwiringPi -lrt
*
* The Wiegand interface has two data lines, DATA0 and DATA1. These lines are normall held
@richturner
richturner / Dockerfile
Last active December 5, 2018 08:14
A docker file for creating an image of tileserver-gl that uses the public_url functionality
FROM klokantech/tileserver-gl
RUN wget -O /tmp/patch.zip https://github.com/koumoul-dev/tileserver-gl/archive/2.10.2.zip
RUN unzip -q -o /tmp/patch.zip -d /tmp
RUN rm /tmp/patch.zip
RUN cp -r /tmp/tileserver-gl-2.10.2/* /usr/src/app
RUN rm -r /tmp/tileserver-gl-2.10.2
RUN cd /usr/src/app && npm install --production