Skip to content

Instantly share code, notes, and snippets.

View fcgdam's full-sized avatar

FcgDam fcgdam

  • Lisbon, Portugal
View GitHub Profile
@fcgdam
fcgdam / template.js
Created May 10, 2018 15:40
Node-Red Status indicator Template code
<style>
.dot {
height: 25px;
width: 25px;
background-color: #bbb;
border-radius: 50%;
display: inline-block;
float: right;
}
</style>
@fcgdam
fcgdam / arch_installation.md
Last active November 24, 2018 19:20 — forked from alexBeuth/arch_installation.md
Arch Linux installation

WARNING: WORK IN PROGRESS, USE THESE STEPS WITH CAUTION. IT WILL CLEAR ALL DISK DATA!!

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
fcgdam / gist:bb67f8c4154f0068c02172662eed0cab
Created November 24, 2018 19:25
Node-Red Crypto-js configuration
functionGlobalContext: {
// os:require('os'),
// octalbonescript:require('octalbonescript'),
// jfive:require("johnny-five"),
// j5board:require("johnny-five").Board({repl:false})
gcm:require('node-gcm'),
cryptojs:require('crypto-js')
},
@fcgdam
fcgdam / PostgresMiddleware.js
Created August 13, 2019 13:00
Node.js Postgres Redis query caching with variable expiration
/**
* PostgresMiddleware.js
*
* Handles postgres queries and caching to redis
* see README for usage
*
*/
var pg = require('pg'),
crypto = require('crypto'),
@fcgdam
fcgdam / cc-test.js
Created November 8, 2019 11:12
Simple Client Credentials test with node-openid-client
const OpenIdClient = require("openid-client");
const identityUrl = "http://127.0.0.1:3000/";
const clientId = "user1";
const clientSecret = "password";
async function GetAccessToken() {
var issuer = await OpenIdClient.Issuer.discover(identityUrl);
@fcgdam
fcgdam / flow.js
Created June 5, 2020 10:53
DSM501a IIR LPF - Infinite Response Low Pass filter
[{"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
fcgdam / main.js
Created August 12, 2020 12:10
Simple Ethereum Ether transaction for Ganache
const Web3 = require('web3');
const provider = new Web3.providers.HttpProvider("http://localhost:7545");
const web3 = new Web3(provider);
/*web3.eth.net.isListening()
.then(() => console.log('web3 is connected'))
.catch(e => console.log('Wow. Something went wrong'));
*/
( async() => {
@fcgdam
fcgdam / lorawan.h
Created February 3, 2021 14:04
Zephyr RTOS Lorawan with Downlink capability
/*
* Copyright (c) 2020 Manivannan Sadhasivam <mani@kernel.org>
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef ZEPHYR_INCLUDE_LORAWAN_LORAWAN_H_
#define ZEPHYR_INCLUDE_LORAWAN_LORAWAN_H_
/**
@fcgdam
fcgdam / lorawan.c
Created February 3, 2021 14:05
Zephyr RTOS Lorawan with Downlink capability
/*
* Copyright (c) 2020 Manivannan Sadhasivam <mani@kernel.org>
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <init.h>
#include <errno.h>
#include <lorawan/lorawan.h>
#include <zephyr.h>
@fcgdam
fcgdam / main.c
Created February 3, 2021 14:08
Zephyr RTOS Lorawan with Downlink capability
...
....
....
....
void Lorawan_Downlink( uint8_t *Buffer, uint8_t BufferSize, uint8_t Port, uint16_t RSSI, uint16_t SNR ) {
printk("Downlink data received: \n");
for(int i=0; i < BufferSize; i++ )
printk("%02X ", Buffer[i]);