- Download script
- Install mqtt-wrapper
pip install mqtt-wrapper - Open OBS Studio
- In OBS Studio add a script (Tools -> Scripts)
- Configure script parameters (my base channel is homeassistant and my sensor name is obs, creating the path homeassistant/sensor/obs)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function sha256(str) { | |
| // Примечание: 'n >>> 0' используется для преобразования числа в 32-битное беззнаковое целое | |
| const K = [ | |
| 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5, | |
| 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174, | |
| 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da, | |
| 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967, | |
| 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const splitString = (str, num = 72) => str.split(new RegExp(`(?<=^(?:.{${num}})*)`,'g')); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Database from 'better-sqlite3'; | |
| import { createDatabaseClient } from './proxy.ts'; | |
| // 1) Create an in-memory DB and your table(s). | |
| const db = new Database(':memory:'); | |
| db.exec(` | |
| CREATE TABLE users ( | |
| id TEXT PRIMARY KEY, | |
| data JSON | |
| ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function debounce(fn, ms, obj){ | |
| return Object.assign( function fx(...args){ | |
| const now = Date.now(); | |
| if(now - fx.lastCall > ms){ | |
| fx.lastCall = now; | |
| return fx.fn.call(fx.obj,...args); | |
| } | |
| if(fx.timeout) clearTimeout(fx.timeout); | |
| fx.timeout = setTimeout(()=>fx(...args), fx.lastCall + ms - now); | |
| }, { fn, obj, lastCall: 0, timeout: null }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** @format */ | |
| const path = require('path'); | |
| const fs = require('fs'); | |
| const https = require('https'); | |
| const http = require('http'); | |
| const cheerio = require('cheerio'); | |
| const os = require('os'); | |
| // Configuration |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // for modern browsers | |
| const svgToDataUrl = svg => `data:image/svg+xml;utf8,${svg.replace(/[#%]/g,s=>'%'+s.charCodeAt(0))}`; | |
| // for old browsers | |
| const svgToDataUrl = svg => `data:image/svg+xml;utf8,${svg.replace(/[<>#%{}"\s]/g,s=>'%'+s.charCodeAt(0))}`; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Debug mode | |
| const DEBUG = true; | |
| const log = (...args) => { | |
| if (DEBUG) console.log(...args); | |
| } | |
| // regular expression to parse numbers | |
| const rxNumberStr = '[+-]?(?:(?:[0-9]+\\.[0-9]+)|(?:\\.[0-9]+)|(?:[0-9]+))(?:[eE][+-]?[0-9]+)?'; | |
| // regular expression to parse next lemma from d attribute of <path> | |
| const rxDLemmaStr = `[MmLlHhVvCcSsQqTtAaZz]|${rxNumberStr}`; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // calculate week number for date | |
| function calcWN(y, m, d) { | |
| let J = gc2jd(y, m, d); | |
| let d4 = (J + 31741 - J % 7) % 146097 % 36524 % 1461; | |
| let L = 0 | d4 / 1460; | |
| let d1 = (d4 - L) % 365 + L; | |
| return (0 | d1 / 7) + 1; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Find all elements with openned ShadowRoots | |
| * | |
| * @param {Node} e - An element that we should search for ShadowRoots within. | |
| * @returns {Array<Element>} Array of Elements that holds ShadowRoot | |
| */ | |
| const findRoots = (e = document.documentElement) => | |
| [e,...e.querySelectorAll('*')] | |
| .filter(e => e.shadowRoot) | |
| .flatMap(e => [e, ...findRoots(e.shadowRoot)]); |
NewerOlder
