Skip to content

Instantly share code, notes, and snippets.

View rozek's full-sized avatar

Andreas Rozek rozek

View GitHub Profile
@rozek
rozek / README.md
Last active October 19, 2021 07:14
Basic HTTP Authorization

This flow provides "basic HTTP Authorization" for HTTP endpoints which are intended for certain users only.

This flow is part of a set of node-red-authorization-examples but also published here for easier lookup

Prerequisites

This example requires the following Node-RED extension:

@rozek
rozek / index.js
Last active May 23, 2020 03:56
ISD Extension BrowserName
//----------------------------------------------------------------------------//
// ISD.BrowserName //
//----------------------------------------------------------------------------//
// based on: https://github.com/keithws/browser-report
var UserAgent = {
Value: window.navigator.userAgent,
contains: function contains(ValueToSearchFor) {
return (this.Value.indexOf(ValueToSearchFor) >= 0);
},
lacks: function lacks(ValueToSearchFor) {
@rozek
rozek / Bangle_watchTilt.js
Created January 14, 2020 20:06
Bangle.js: just a simple TiltWatcher example
//------------------------------------------------------------------------------
//-- TiltWatcher --
//------------------------------------------------------------------------------
(function () {
let _Sensitivity = 1; // factor to amplify or damp acceleration
const TakerList = [];
/**** setWatchFor ****/
@rozek
rozek / Bangle_TiltWatcher.js
Created January 14, 2020 19:53
Bangle.js: associates a point on the screen with the current device tilt
//------------------------------------------------------------------------------
//-- TiltWatcher --
//------------------------------------------------------------------------------
(function () {
let _Sensitivity = 1; // factor to amplify or damp acceleration
const TakerList = [];
/**** setWatchFor ****/
@rozek
rozek / Bangle_watchButtons.js
Last active January 14, 2020 19:50
Bangle.js: a simple ButtonWatcher example
//------------------------------------------------------------------------------
//-- ButtonWatcher --
//------------------------------------------------------------------------------
(function () {
let _AutoRepeatDelay = 800; // start auto repeat after 800ms
let _AutoRepeatInterval = 200; // send "ButtonPressed" every 200ms
const ButtonList = [BTN1, BTN2, BTN3, BTN4, BTN5];
const TakerList = [[], [], [], [], []];
@rozek
rozek / Bangle_ButtonWatcher
Last active January 14, 2020 19:47
Bangle.js: watches buttons and invokes methods on state transitions
//------------------------------------------------------------------------------
//-- ButtonWatcher --
//------------------------------------------------------------------------------
(function () {
let _AutoRepeatDelay = 800; // start auto repeat after 800ms
let _AutoRepeatInterval = 200; // send "ButtonPressed" every 200ms
const ButtonList = [BTN1, BTN2, BTN3, BTN4, BTN5];
const TakerList = [[], [], [], [], []];
@rozek
rozek / Bangle_drawLenaImg.js
Created January 14, 2020 06:25
Bangle.js: draws a previously transferred LenaImg file
const Storage = require('Storage');
Bangle.setLCDMode();
g.clear();
let ImageFile = Storage.open('LenaImg','r');
for (let y = 0; y < 240; y++) {
let LineData = ImageFile.readLine();
g.drawImage({
width:240, height:1, bpp:16, transparent:0,
buffer:E.toArrayBuffer(atob(LineData))
@rozek
rozek / Bangle_listFiles.js
Last active January 14, 2020 05:51
Bangle.js: lists all files on the internal file system
const Storage = require('Storage');
print('compacting internal Storage...');
Storage.compact();
print('internal Storage report:');
print('-',Storage.getFree(),'bytes free');
print('- list of stored files');
let FileList = Storage.list();
for (let i = 0, l = FileList.length; i < l; i++) {
print(' -',FileList[i].replace(/[\x00-\x1F\x7F-\x9F]/g, function (Match) {
@rozek
rozek / Bangle_listLogicalFiles
Last active January 14, 2020 05:51
Bangle.js: list all "logical" files on the internal file system
const Storage = require('Storage');
print('compacting internal Storage...');
Storage.compact();
print('internal Storage report:');
print('-',Storage.getFree(),'bytes free');
print('- list of stored files');
let FileList = Storage.list();
let segmentedFileSet = Object.create(null);
@rozek
rozek / Bangle_getStdClock.js
Last active January 13, 2020 11:52
Bangle.js: retrieves the currently configured standard clock
const Storage = require('Storage');
let StdClock;
try {
StdClock = Storage.readJSON('@setting')['clock'];
} catch (Signal) { /* nop */ }
if (StdClock) {
print('currently configured standard clock: "' + StdClock.slice(1) + '"');
} else {
print('no standard clock configured');