Skip to content

Instantly share code, notes, and snippets.

View peaBerberian's full-sized avatar

Paul Berberian peaBerberian

View GitHub Profile
#!/usr/bin/env node
import * as fs from 'fs';
import * as path from 'path';
import { fileURLToPath } from 'url';
const VERSION_REGXP =
/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/;
const URL_REGXP = /^[a-zA-Z]+:\/\//;
// ================================ HTML-LOGGER ================================
//
// This code will display a semi-opaque div HTMLElement on the top of the screen
// containing log produced through `console` methods (and optionally logging
// requests).
//
// You can configure it by updating the variables below.
/**
* To set to `true` to also show HTTP(S) requests made through either the
const base64abc = [
"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M",
"N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z",
"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m",
"n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z",
"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "+", "/",
];
/**
* Convert an array of bytes into a base64 string.
@peaBerberian
peaBerberian / websocket_client.js
Last active April 22, 2022 08:28
Log client/server for local debugging on embedded devices
// Note: if not on localhost, don't forget to add something like:
// `<meta http-equiv="Content-Security-Policy" content="connect-src 'self' ws: wss:">`
// to the HTML page to allow websocket connections to external websites
// SERVER_URL of the server (relative to the client).
// Localhost by default
const SERVER_URL = "ws://127.0.0.1";
// Port on which the server is listening.
// If going through ngrok, you can set it to `null`
/*
// This constant can also be computed with the following algorithm:
const base64abc = [],
A = "A".charCodeAt(0),
a = "a".charCodeAt(0),
n = "0".charCodeAt(0);
for (let i = 0; i < 26; ++i) {
base64abc.push(String.fromCharCode(A + i));
}
for (let i = 0; i < 26; ++i) {
{
const cLog = console.log;
const cWarn = console.warn;
const cError = console.error;
const cInfo = console.info;
const cDebug = console.debug;
function addTSToArgumentList(argList) {
const ret = [performance.now()];
for (let i = 0; i < argList.length; i++) {
@peaBerberian
peaBerberian / initial_seek_after_segment_push.html
Created January 8, 2021 14:52
Initial seek after media segment pushed
<!DOCTYPE html>
<!--
This file allows to quickly test if starting a content at a position different
from `0` after the media segments have been pushed works.
To do that:
1. You might want to update the variables at the top of the script (default
values should be alright but maybe the content is not available anymore).
@peaBerberian
peaBerberian / initial_seek_after_loaded_metadata.html
Created January 8, 2021 14:48
Initial seek after loaded metadata
<!DOCTYPE html>
<!--
This file allows to quickly test if starting a content at a position different
from `0` works.
More precizely, it tests that seeking as soon as the loadedmetadata event is
received works on the current platform.
To do that:
function be4toi(bytes, offset) {
return ((bytes[offset + 0] * 0x1000000) +
(bytes[offset + 1] * 0x0010000) +
(bytes[offset + 2] * 0x0000100) +
(bytes[offset + 3]));
}
function be8toi(bytes, offset) {
return (((bytes[offset + 0] * 0x1000000) +
(bytes[offset + 1] * 0x0010000) +
(bytes[offset + 2] * 0x0000100) +
/**
* Pretty print a TimeRanges Object, to see the current content of it in a
* one-liner string.
*
* @example
* This function is called by giving it directly the TimeRanges, such as:
* ```js
* prettyPrintBuffered(document.getElementsByTagName("video")[0].buffered);
* ```
*