Skip to content

Instantly share code, notes, and snippets.

View Utopiah's full-sized avatar

Fabien Benetou Utopiah

View GitHub Profile
@Utopiah
Utopiah / whiteboard.tmpl
Created March 12, 2021 16:34
Whiteboard PmWiki template
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>$WikiTitle | {$Group} / {$Title} $ActionTitle</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
<meta name="monetization" content="$ilp.gatehub.net/360717042">
// sensor via https://wiki.postmarketos.org/wiki/PINE64_PinePhone_(pine64-pinephone)#Sensors
const x_path = "/sys/bus/iio/devices/iio:device3/in_accel_x_raw"
const y_path = "/sys/bus/iio/devices/iio:device3/in_accel_y_raw"
const z_path = "/sys/bus/iio/devices/iio:device3/in_accel_z_raw"
var fs = require("fs");
var express = require('express');
var app = express();
// could be WSS but fast enough on LAN as-is
import {loadAssetsFromURLs, getAvatarFromName, getFirstElementFromHash, objects3DFromPartialName} from './utils';
var emojiPrefix = 'emoji-'
var nafPrefix = 'naf-'
function emojiRadarScript(){
var refreshEmojis = setInterval( updateEmojis, 500 )
}
function updateEmojis(){
A-Frame Version: https://github.com/MozillaReality/aframe
three Version: https://github.com/MozillaReality/three.js
WebVR Polyfill Version: ^0.10.10
core:schema:warn Default value `null` does not match type `string` in component `media-loader`
core:schema:warn Default value `null` does not match type `string` in component `media-loader`
core:schema:warn Default value `null` does not match type `string` in component `media-loader`
core:schema:warn Default value `undefined` does not match type `string` in component `media-image`
core:schema:warn Default value `null` does not match type `string` in component `camera-focus-button`
ErrorEvent {
type: 'error',
if (typeof Puck === "undefined") throw "Load http://www.puck-js.com/puck.js first"
Puck.write("var data;\nThingy.onMPU(r=>data=r);\n");
// making latest MPU data accessible on device, namely gyo + accel + ...
var data = {x:0, y:0, z:0}
var threshold = 25
var speed = 1
var pos = document.querySelector("#avatar-rig").object3D.position;
var rotationCam = document.querySelector("#avatar-pov-node").object3D.rotation;
const bearer = 'Bearer ...' // get it for your own gateway in Settings -> Developers > Create local auth
// or directly via http://gateway.local/oauth/authorize?response_type=code&client_id=local-token&scope=/things:readwrite&state=asdf
const myThing = 'zb-00001234' // get it by visiting http://gateway.local/things and opening a Thing
// UUID will be at the end of theURL
if (bearer.length + myThing.length < 25) throw 'you need to setup those values, see comments'
// utils
function loadAssetsFromURLs(URLs){
@Utopiah
Utopiah / gateway_thing_pannel.kwinrule
Created October 31, 2020 09:04
gateway_thing_pannel.kwinrule
[Gateway pannel]
Description=Gateway pannel
above=true
aboverule=2
clientmachine=localhost
clientmachinematch=0
fullscreen=false
fullscreenrule=2
minimize=false
minimizerule=2
# to be executed on the device itself
# note that ~/xochitl-data is a symlink to avoid long path
quickNotesLayersToWiki(){ cd xochitl-data; curl -d "?n=PIMVRdata.ReMarkableQuicknotes&text=$(grep name UUID/*json | sed 's/.*: "\(.*\)"/%0a* \1/' | tr '\n' ' ')&action=edit&post=1&author=reMarkable2Ttest&authpw=edit_pw_to_change" https://fabien.benetou.fr/PIMVRdata/ReMarkableQuicknotes; cd -; }
# note that you must replace UUID and edit_pw by the UUID of your quicknote document (you can use hashFromTitle() for that) and your PmWiki password respectively.
qrCodeLink () { qrencode http://`ip a | grep wlan0$ | sed "s/.* \(.*\)\/.*/\1/"`:3000/data/$1.pdf -o qr_ip.xpm -t XPM && convert qr_ip.xpm qr_ip.pdf && addPdfWithMetadata qr_ip.pdf; }
hashFromTitle () { cd ~/.local/share/remarkable/xochitl/ && grep -l -i $1 *metadata | sed 's/.metadata//'; }
addPdfWithMetadata(){
cp $1 ~/xochitl-data && echo "{'parent':'','type':'DocumentType','visibleName':'$1'}" | sed s/\'/\"/g > ~/xochitl-data/`echo $1 | sed "s/.pdf//"`.met
//in crontab as @reboot node ~/Prototypes/blink_node_webserver/redlight.js
const express = require('express')
var Gpio = require('onoff').Gpio; //include onoff to interact with the GPIO
var YELLOW = new Gpio(4, 'out'); //use GPIO pin 4, and specify that it is output
var RED = new Gpio(21, 'out'); //use GPIO pin 4, and specify that it is output
var GREEN = new Gpio(26, 'out'); //use GPIO pin 4, and specify that it is output
var blinkInterval
onst express = require('express')
var Gpio = require('onoff').Gpio; //include onoff to interact with the GPIO
var LED = new Gpio(21, 'out'); //use GPIO pin 4, and specify that it is output
var blinkInterval
function blinkLED() { //function to start blinking
if (LED.readSync() === 0) { //check the pin state, if the state is 0 (or off)
LED.writeSync(1); //set pin state to 1 (turn LED on)
} else {