Skip to content

Instantly share code, notes, and snippets.

View natcl's full-sized avatar

Nathanaël Lécaudé natcl

View GitHub Profile
@natcl
natcl / Dockerfile
Last active January 30, 2021 21:08
Node-RED Docker ENV test
FROM ubuntu:16.04
RUN \
sed -i 's/# \(.*multiverse$\)/\1/g' /etc/apt/sources.list && \
apt-get update && \
apt-get -y upgrade && \
apt-get install -y build-essential curl && \
apt-get install -y software-properties-common && \
curl -sL https://deb.nodesource.com/setup_8.x | bash - && \
apt-get install -y nodejs
@natcl
natcl / .gitignore
Last active September 6, 2018 13:37
Node-RED Json-RPC validation subflow
*.backup
[{"id":"114a5d8c.c2b092","type":"inject","z":"be63dfb5.edca6","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":160,"y":120,"wires":[["94f49e0d.136bb8"]]},{"id":"94f49e0d.136bb8","type":"function","z":"be63dfb5.edca6","name":"[0,255,0]","func":"msg.payload = Buffer.alloc(64*3, Buffer.from([0,255,0]));\nreturn msg;","outputs":1,"noerr":0,"x":320,"y":120,"wires":[["32b2de23.568a02"]]},{"id":"ee2e23c1.8721d","type":"function","z":"be63dfb5.edca6","name":"black","func":"msg.payload = Buffer.alloc(64*3, Buffer.from([0,0,0]));\nreturn msg;","outputs":1,"noerr":0,"x":310,"y":220,"wires":[["32b2de23.568a02"]]},{"id":"1b558bf5.5f2984","type":"inject","z":"be63dfb5.edca6","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":160,"y":220,"wires":[["ee2e23c1.8721d"]]},{"id":"23a4922f.e7fbae","type":"function","z":"be63dfb5.edca6","name":"[0,0,255]","func":"msg.payload = Buffer.alloc(64*3, Buffer.from(
@natcl
natcl / rpi-ws281x-native.js
Created March 9, 2018 22:16
rpi-ws281x-native
const NUM_LEDS = 64;
if (!context.ws281x) {
context.ws281x = require('rpi-ws281x-native');
context.finalArray = new Uint32Array(NUM_LEDS);
context.ws281x.init(NUM_LEDS, {dmaNum: 10});
}
if (context.ws281x) {
@natcl
natcl / flows.json
Created February 1, 2018 16:34
Node-RED + Jsonata: Add/delete from object without a function
[{"id":"da36d92a.fdbea","type":"comment","z":"f3e76b7c.c6075","name":"init flow.devices to empty object","info":"","x":190,"y":60,"wires":[]},{"id":"7fae03dc.30d794","type":"inject","z":"f3e76b7c.c6075","name":"","topic":"A","payload":"{\"host\":\"A\",\"status\":\"online\"}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":210,"y":260,"wires":[["6b94ce72.3e99b8"]]},{"id":"45b494a3.7dfc5c","type":"inject","z":"f3e76b7c.c6075","name":"","topic":"B","payload":"{\"host\":\"B\",\"status\":\"online\"}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":210,"y":300,"wires":[["6b94ce72.3e99b8"]]},{"id":"6b94ce72.3e99b8","type":"change","z":"f3e76b7c.c6075","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\t payload.host : payload\t}\t ","tot":"jsonata"},{"t":"set","p":"devices","pt":"flow","to":"$merge([$flowContext('devices'), payload])","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":540,"y":260,"wires":[["bd5
@natcl
natcl / Dockerfile
Last active March 5, 2019 00:17
Node-RED Avahi Docker
FROM nodered/node-red-docker:0.17.5
USER root
RUN apt-get update
RUN apt-get install -y libavahi-compat-libdnssd-dev avahi-daemon avahi-utils
RUN npm install node-red-node-discovery
COPY start.sh /
@natcl
natcl / docker-compose.yaml
Created January 2, 2018 15:33
Docker Compose Syslog Example
version: '2'
services:
nodered:
image: nodered/node-red-docker:0.17.5
restart: always
environment:
- TZ=America/Montreal
logging:
driver: syslog
options:
@natcl
natcl / mqtt_rpc.json
Last active December 13, 2017 16:31
MQTT JSON RPC Request
[
{
"id": "64220941.ddbd78",
"type": "subflow",
"name": "mqtt request",
"info": "",
"in": [
{
"x": 60,
"y": 220,
<artnet>
<send>1</send>
<console>1</console>
<networkAdapterIP>2.0.1.1</networkAdapterIP>
<nodeIP>2.0.1.12</nodeIP>
<nodePort>6454</nodePort>
<subnet>0</subnet>
<universe>0</universe>
<shortName>MF Banff Node</shortName>
<longName>MF Banff Video to Art-Net</longName>
@natcl
natcl / interolator.js
Last active October 18, 2017 19:15
Interpolator with NanoTimer
//Node gameloop
var NanoTimer = require('nanotimer');
var count = 0;
var source = msg.payload.source;
var target = msg.payload.target;
var interval = 16;