Skip to content

Instantly share code, notes, and snippets.


FcgDam fcgdam

  • Lisbon, Portugal
View GitHub Profile
fcgdam / main.js
Created Aug 12, 2020
Simple Ethereum Ether transaction for Ganache
View main.js
const Web3 = require('web3');
const provider = new Web3.providers.HttpProvider("http://localhost:7545");
const web3 = new Web3(provider);
.then(() => console.log('web3 is connected'))
.catch(e => console.log('Wow. Something went wrong'));
( async() => {
fcgdam / flow.js
Created Jun 5, 2020
DSM501a IIR LPF - Infinite Response Low Pass filter
View flow.js
[{"id":"fa93e49d.59c9d","type":"function","z":"44ba6b13.5c4d64","name":"IIR Low Pass Filter","func":"// IIR LPF factors\n f_a0 = 0.0010227586546542474; // Input factors\n f_a1 = 0.002045517309308495;\n f_a2 = 0.0010227586546542474;\n \n f_b1 = -1.9066459797557103; // Output factors\n f_b2 = 0.9107370143743273;\n\n// PPM 1.0 input variables\nvar i0_c10 = msg.payload.cPM10;\nvar i1_c10 = context.get('i1_c10') || 0;\nvar i2_c10 = context.get('i2_c10') || 0;\n\n// PPM 1.0 output variables\nvar o0_c10 = context.get('o0_c10') || 0;\nvar o1_c10 = context.get('o1_c10') || 0;\n\n\n// Calculate the IIR\nvar lpf = i0_c10 * f_a0 + \n i1_c10 * f_a1 + \n i2_c10 * f_a2 - // We add the negative output factors\n o0_c10 * f_b1 - \n o1_c10 * f_b2;\n \n// Memorize the variables\ncontext.set( 'i2_c10' , i1_c10 );\ncontext.set( 'i1_c10' , i0_c10 );\n\ncontext.set( 'o1_c10' , o0_c10 );\ncontext.set( 'o0_c10' , lpf );\n\n// PPM 2.5 input variables\nvar
fcgdam / cc-test.js
Created Nov 8, 2019
Simple Client Credentials test with node-openid-client
View cc-test.js
const OpenIdClient = require("openid-client");
const identityUrl = "";
const clientId = "user1";
const clientSecret = "password";
async function GetAccessToken() {
var issuer = await;
fcgdam / PostgresMiddleware.js
Created Aug 13, 2019 — forked from DJviolin/PostgresMiddleware.js
Node.js Postgres Redis query caching with variable expiration
View PostgresMiddleware.js
* PostgresMiddleware.js
* Handles postgres queries and caching to redis
* see README for usage
var pg = require('pg'),
crypto = require('crypto'),
fcgdam / flow.js
Created Jul 25, 2019
Node-Red flow for PowerMeter
View flow.js
[{"id":"c69b35de.5b1288","type":"tab","label":"Power Meter Dash","disabled":false,"info":"Power Meter DashBoard"},{"id":"11b29614.713a5a","type":"mqtt in","z":"c69b35de.5b1288","name":"PM Telemetry","topic":"iot/device/ESP8266_PowerMeter/telemetry","qos":"2","datatype":"auto","broker":"2a552b3c.de8d2c","x":140,"y":60,"wires":[["4f01e095.a6b468"]]},{"id":"4f01e095.a6b468","type":"json","z":"c69b35de.5b1288","name":"To JSON","property":"payload","action":"","pretty":false,"x":350,"y":60,"wires":[["3afc46aa.19ff9a","b4966155.90ad9","4e1496c4.95576","2cdca24.0a446de","3c7e559f.3df0ea","db4513ed.467ef8"]]},{"id":"3afc46aa.19ff9a","type":"function","z":"c69b35de.5b1288","name":"Voltage (V)","func":"msg.payload = Number(msg.payload.V);\nreturn msg;","outputs":1,"noerr":0,"x":570,"y":60,"wires":[["c2e720c3.2121d","f13ac150.bfe46"]]},{"id":"b4966155.90ad9","type":"function","z":"c69b35de.5b1288","name":"Current (I)","func":"msg.payload = Number(msg.payload.I);\nreturn msg;","outputs":1,"noerr":0,"x":570,"y":120,"wires
fcgdam / gist:bb67f8c4154f0068c02172662eed0cab
Created Nov 24, 2018
Node-Red Crypto-js configuration
View gist:bb67f8c4154f0068c02172662eed0cab
functionGlobalContext: {
// os:require('os'),
// octalbonescript:require('octalbonescript'),
// jfive:require("johnny-five"),
// j5board:require("johnny-five").Board({repl:false})
fcgdam /
Last active Nov 24, 2018 — forked from alexBeuth/
Arch Linux installation


I recommend first to use a Virtual Box machine with EFI support enabled to test everything before doing it on a real machine.

Arch installation on a HP ENVY 13 inch laptop (ah0006np part number: 16GB Ram, 512GB SSD)

OBJECTIVE: Install Arch Linux with encrypted boot, root and swap filesystems and boot from UEFI, completly dumping Windows on the process. No dual boot. Windows, if necessary will be run on a Virtual Machine and re-use the Windows key that came with the laptop.

The configuration will be LVM on LUKS. Also a major difference from other tutorials is that the boot partition is also encrypted, and not a standard partition.

fcgdam / template.js
Created May 10, 2018
Node-Red Status indicator Template code
View template.js
.dot {
height: 25px;
width: 25px;
background-color: #bbb;
border-radius: 50%;
display: inline-block;
float: right;
You can’t perform that action at this time.