Skip to content

Instantly share code, notes, and snippets.

Avatar

Andreas Rozek rozek

View GitHub Profile
@rozek
rozek / README.md
Last active Oct 19, 2021
Basic HTTP Authorization
View README.md

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
ISD Extension BrowserName
View index.js
//----------------------------------------------------------------------------//
// 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 Jan 14, 2020
Bangle.js: just a simple TiltWatcher example
View Bangle_watchTilt.js
//------------------------------------------------------------------------------
//-- TiltWatcher --
//------------------------------------------------------------------------------
(function () {
let _Sensitivity = 1; // factor to amplify or damp acceleration
const TakerList = [];
/**** setWatchFor ****/
@rozek
rozek / Bangle_TiltWatcher.js
Created Jan 14, 2020
Bangle.js: associates a point on the screen with the current device tilt
View Bangle_TiltWatcher.js
//------------------------------------------------------------------------------
//-- TiltWatcher --
//------------------------------------------------------------------------------
(function () {
let _Sensitivity = 1; // factor to amplify or damp acceleration
const TakerList = [];
/**** setWatchFor ****/
@rozek
rozek / Bangle_watchButtons.js
Last active Jan 14, 2020
Bangle.js: a simple ButtonWatcher example
View Bangle_watchButtons.js
//------------------------------------------------------------------------------
//-- 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 Jan 14, 2020
Bangle.js: watches buttons and invokes methods on state transitions
View Bangle_ButtonWatcher
//------------------------------------------------------------------------------
//-- 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 Jan 14, 2020
Bangle.js: draws a previously transferred LenaImg file
View Bangle_drawLenaImg.js
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_listClocks.js
Created Jan 13, 2020
Bangle.js: prints a list of all installed clocks
View Bangle_listClocks.js
const Storage = require('Storage');
let ClockList = [];
let FileList = Storage.list();
for (let i = 0, l = FileList.length; i < l; i++) {
let FileName = FileList[i];
if (FileName[0] === '+') {
try {
let AppType = Storage.readJSON(FileName)['type'];
if (AppType === 'clock') {
ClockList.push(FileName.slice(1));
@rozek
rozek / Bangle_getStdClock.js
Last active Jan 13, 2020
Bangle.js: retrieves the currently configured standard clock
View Bangle_getStdClock.js
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');
@rozek
rozek / Bangle_uninstallHelWrld.js
Last active Jan 13, 2020
Bangle.js: uninstalls the "HelWrld" App
View Bangle_uninstallHelWrld.js
const Storage = require('Storage');
let AppName = 'HelWrld';
(function () {
try {
let FileList = Storage.readJSON(AppName);['files'].split(',');
for (let i = 0, l = FileList.length; i < l; i++) {
Storage.erase(FileList[i]);
}
return;