Skip to content

Instantly share code, notes, and snippets.

View gbrault's full-sized avatar
Working from home

Gilbert Brault gbrault

Working from home
  • Vence
View GitHub Profile
gbrault / load iframe including script
Last active April 18, 2016 07:37
How to load scripts in an iframe
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "">
<html xmlns="" xml:lang="en" lang="en">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<div id="test"></div>
gbrault / angular js function call
Last active July 19, 2016 11:36
How to call functions or watch variables in NODE-RED UI (angular.js)
(function(scope) { = "Here I am!!!";
/* = function(val){alert(val);return val}; */
scope.$watch('msg.payload', function(newValue, oldValue) {
/* Do something clever here */
if(!angular.equals(newValue, oldValue)){
gbrault / Play sound with Node-RED UI
Created July 19, 2016 12:01
Add this code in a Node-Red UI "Template" node
var playSound = (function beep() {
var snd = new Audio("data:audio/wav;base64,//uQRAAAAWMSLwUIYAAsYkXgoQwAEaYLWfkWgAI0wWs/ItAAAGDgYtAgAyN+QWaAAihwMWm4G8QQRDiMcCBcH3Cc+CDv/7xA4Tvh9Rz/y8QADBwMWgQAZG/ILNAARQ4GLTcDeIIIhxGOBAuD7hOfBB3/94gcJ3w+o5/5eIAIAAAVwWgQAVQ2ORaIQwEMAJiDg95G4nQL7mQVWI6GwRcfsZAcsKkJvxgxEjzFUgfHoSQ9Qq7KNwqHwuB13MA4a1q/DmBrHgPcmjiGoh//EwC5nGPEmS4RcfkVKOhJf+WOgoxJclFz3kgn//dBA+ya1GhurNn8zb//9NNutNuhz31f////9vt///z+IdAEAAAK4LQIAKobHItEIYCGAExBwe8jcToF9zIKrEdDYIuP2MgOWFSE34wYiR5iqQPj0JIeoVdlG4VD4XA67mAcNa1fhzA1jwHuTRxDUQ//iYBczjHiTJcIuPyKlHQkv/LHQUYkuSi57yQT//uggfZNajQ3Vmz+Zt//+mm3Wm3Q576v////+32///5/EOgAAADVghQAAAAA//uQZAUAB1WI0PZugAAAAAoQwAAAEk3nRd2qAAAAACiDgAAAAAAABCqEEQRLCgwpBGMlJkIz8jKhGvj4k6jzRnqasNKIeoh5gI7BJaC1A1AoNBjJgbyApVS4IDlZgDU5WUAxEKDNmmALHzZp0Fkz1FMTmGFl1FMEyodIavcCAUHDWrKAIA4aa2oCgILEBupZgHvAhEBcZ6joQBxS76AgccrFlczBvKLC0QI2cBoCFvfTDAo7eoOQInqDPBtvrDEZBNYN5xwNwxQRfw8ZQ5wQVLvO8OYU+mHvFLlDh05Mdg7BT6YrRPpCBznMB2r//xKJjyyOh+cImr2/4doscwD6neZjuZR4AgAABYAAAABy1xcdQtxYBYYZdifkU
gbrault / noderedmultiplex.json
Last active August 2, 2016 12:12
multiplexing messages between nodered server and client ui (node-red ui) see first comment for usage
[{"id":"a280b0ca.203e2","type":"ui_template","z":"78b2e9d1.c8c848","tab":"635f39f2.c5f958","name":"","group":"","order":1,"format":"<pre>--{{msg.payload}}--{{msg.sender}}--</pre><br>\nv1:{{v1}}<br>\nv2:{{v2}}<br>\nv3:{{v3}}<br>\n<script>\n(function(scope) {\n scope.v1=\"\";\n scope.v2=\"\";\n scope.v3=\"\";\n scope.$watch('msg.sender', function(newValue, oldValue) {\n if((this.msg===undefined)||(this.msg===null)){console.log(\"msg not defined\");return;}\n switch(this.msg.sender.substr(0,1)){\n case \"1\":\n this.v1=this.msg.payload;\n break;\n case \"2\":\n this.v2=this.msg.payload;\n break;\n case \"3\":\n this.v3=this.msg.payload;\n break;\n default:\n console.log(\"not existing case:\"+this.msg.sender);\n }\n }.bind(scope));\n})(scope);\n</script>","storeOutMessages":true,"fwdInMessages":true,"x":695,"y":204,"wires":[[]]},{
gbrault / httpsnodered.txt
Last active August 23, 2023 09:21
https setting node-red
- go to .node-red directory
- create a public directory: mkdir public
- go to public: cd public
- Create a certificate
openssl genrsa -out privatekey.pem 1024
openssl req -new -key privatekey.pem -out private-csr.pem
openssl x509 -req -days 365 -in private-csr.pem -signkey privatekey.pem -out certificate.pem
- cd ..
gbrault / Horizontal marimekko
Last active November 5, 2016 10:38
Original work from
Transfomed work (see excel file marimekko_template - Horizontal Final):
look clearly and simply post for usage
- Totals (rows, cols) and Competitors suppressed from initial schema
- Rows becomes Columns (Horizontal Marimekko)
- Cell A1 of "Colors" sheet is the thresold % to hide names
- names displayed instead of values
gbrault / node-red-dashboard.txt
Created November 10, 2016 09:55
How to extend node red dashboard: development setup
1. Make sure you have removed all global instances of node-red and dashboard on the developement machine
2. In a shell session (shell_1), create a directory to install node-red
3. cd this dir (node-red)
4. npm init
5. npm i node-red
6. cd node_modules/node-red
7. npm start
8. stop => the .node-red directory in <user> default directory should then be created
9. In a new shell (shell_2): cd <user>/.node-red/node_modules
10. git clone
Node-Red is a great piece of work but lake three key features:
* A file browser and editor
* A remote console
* An SQL manager for Sqlite
To extend Node-RED, three piece of software of interest
* ShellInABox: [see]( a very nice https Linux console
* CloudCmd: [see]( a file and editor browser with a console as well (but less conformant than ShellInAbox)
* nrsqljs: [see]( an SQL manager to browse and edit database tables for sqlite
gbrault / shrinksqlite3.js
Created November 15, 2016 16:21
How to shrink sqlite3.node verbose output for big tables
var sqlite3=require('sqlite3');
var pgu={
db: {},
res: {},
all: function (topic,bind=[]){
this.db.all(topic, bind, function(err, row) {
if (err) { console.log(err,msg); return null;}
else {
gbrault / cloudcmd.json
Last active November 20, 2016 17:37
start cloudcmd as a daemon with node-red
"id": "1e5321cd.1e8eee",
"type": "debug",
"z": "165dee9e.7db461",
"name": "",
"active": false,
"console": "false",
"complete": "true",
"x": 567.5,