Skip to content

Instantly share code, notes, and snippets.

View cvan's full-sized avatar
🚌
🌊

Christopher Van Wiemeersch cvan

🚌
🌊
View GitHub Profile
//(function () {
// const
playerEl = document.getElementById('movie_player');
if (!playerEl) {
return;
}
// const
YOUTUBE_QUALITY_SIZES = [4320, 2880, 2160, 1440, 1080, 720, 480, 360, 240, 144];
// const
@cvan
cvan / youtube-force-quality.md
Last active December 18, 2023 15:25
Force video quality with YouTube (notes for Firefox Reality)

Forcing a better default playback quality of YouTube videos

If a user is browsing videos on YouTube.com from a web browser on a higher-end device (e.g., VR headsets), the user has to manually override the playback quality of a video through the playback-controls bar at the bottom of the video: Settings > Quality.


Forcing a different playback quality of a YouTube video

  1. Load a YouTube video. Example: https://www.youtube.com/watch?v=ELU-43DMNT4
  2. Then paste some of this code in the DevTools' Console.
  3. You'll notice the quality changes to the highest available for the video.
@cvan
cvan / firefox-reality-screenshot-burst.sh
Created March 19, 2019 08:43
capture a sequence of screenshots while Firefox Reality launches
# Stop FxR.
adb shell am force-stop org.mozilla.vrbrowser
# Launch FxR.
adb shell am start -a android.intent.action.VIEW -n org.mozilla.vrbrowser/org.mozilla.vrbrowser.VRBrowserActivity
# Capture a bunch of screenshots so we can be sure that we get the frame we want.
for i in `seq 1 20`; do (adb exec-out screencap -p > /opt/mozillareality/fxr-screen-saves/screenshots/$(date +%F_%T)_$(LC_CTYPE=C tr -dc A-Za-z0-9_\!\@\#\$\%\^\&\*\(\)-+= < /dev/urandom | head -c 32 | xargs).png); done
@cvan
cvan / WebGameDebugInfo.js
Created February 20, 2019 18:57
a helpful function for retrieving debug details for a user's capabilities, libraries used, and perf stats for WebGL in a WebVR / WebXR web page
function WebGameDebugInfo () {
let canvas;
const stats = {};
const info = {
supports: {
webxr: 'hasNativeWebXRImplementation' in window ? window.hasNativeWebXRImplementation : !!navigator.xr,
webvr: 'hasNativeWebVRImplementation' in window ? window.hasNativeWebVRImplementation : !!navigator.vr
},
libs: {
aframe: null,
@cvan
cvan / nice-title-case.js
Created February 12, 2019 00:37
title-case a string into a title (containing mixed uppercased, lettercased, acronyms, initialisations)
const isAcronym = require('is-acronym');
getTitleCase = str => {
str = str || '';
return str.charAt(0).toUpperCase() + (str.substr(1) || '').toLowerCase();
};
wordsToNotCapitalise = [
'a',
'an',
const isTouchSupported = 'ontouchstart' in window;
const events = {
start: isTouchSupported ? 'touchstart' : 'mousedown',
move: isTouchSupported ? 'touchmove' : 'mousemove',
end: isTouchSupported ? 'touchend' : 'mouseup'
};
window.addEventListener(events.start, () => {
// Handle `touchstart`/`mousedown`.
});
@cvan
cvan / convert-batch-hex-to-rgb.js
Created November 14, 2018 09:57
convert hex colours to `rgb(…)`
function hexToRgb(hex) {
const shorthandRegex = /^#?([a-f\d])([a-f\d])([a-f\d])$/i;
hex = hex.replace(shorthandRegex, (m, r, g, b) => {
return r + r + g + g + b + b;
});
const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
const rgbObj = result ? {
r: parseInt(result[1], 16),
g: parseInt(result[2], 16),
b: parseInt(result[3], 16)
--------- beginning of system
11-07 20:32:56.578 1192 1520 D ActivityManager: cleanUpApplicationRecord -- 1827
11-07 20:32:56.598 1192 1203 D ConnectivityService: ConnectivityService NetworkRequestInfo binderDied(NetworkRequest [ LISTEN id=4, [ Transports: WIFI Capabilities: NOT_RESTRICTED&TRUSTED&NOT_VPN&FOREGROUND] ], android.os.BinderProxy@a9084fb)
11-07 20:32:56.632 1192 1212 I DisplayManagerService: Display device removed: DisplayDeviceInfo{"com.oculus.android_panel_app.AndroidPanelLayer-#main": uniqueId="virtual:com.oculus.vrshell,10021,com.oculus.android_panel_app.AndroidPanelLayer-#main,0", 770 x 145, modeId 2, defaultModeId 2, supportedModes [{id=2, width=770, height=145, fps=60.0}], colorMode 0, supportedColorModes [0], HdrCapabilities null, density 160, 160.0 x 160.0 dpi, appVsyncOff 0, presDeadline 16666666, touch NONE, rotation 0, type VIRTUAL, state ON, owner com.oculus.vrshell (uid 10021), FLAG_PRIVATE, FLAG_NEVER_BLANK, FLAG_OWN_CONTENT_ONLY}
11-07 20:32:56.637 1192 1212 I DisplayManag
@cvan
cvan / page-dimensions.html
Created July 19, 2018 01:48
get HTML document page dimensions with JavaScript
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title></title>
<style>
body { font-size: 3rem; padding: 3rem; }
p { margin: 1rem 0; }
.measure { position: absolute; top: 0; left: 0; right: 0; }
</style>