Instantly share code, notes, and snippets.

πŸ’­
🐝 Bzz!

Christopher Robert Van Wiemeersch cvan

View GitHub Profile
@cvan
cvan / WebGameDebugInfo.js
Created Feb 20, 2019
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
View WebGameDebugInfo.js
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 Feb 12, 2019
title-case a string into a title (containing mixed uppercased, lettercased, acronyms, initialisations)
View nice-title-case.js
const isAcronym = require('is-acronym');
getTitleCase = str => {
str = str || '';
return str.charAt(0).toUpperCase() + (str.substr(1) || '').toLowerCase();
};
wordsToNotCapitalise = [
'a',
'an',
View click-events.js
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 Nov 14, 2018
convert hex colours to `rgb(…)`
View convert-batch-hex-to-rgb.js
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)
View logcat.fxr.lang.txt
--------- 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 Jul 19, 2018
get HTML document page dimensions with JavaScript
View page-dimensions.html
<!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>
@cvan
cvan / open-web-apps-electron-qbrt.md
Last active May 25, 2018
The Evolution of XULRunner, Open Web Apps, Gecko WebRuntime, qbrt, Headless Firefox
View open-web-apps-electron-qbrt.md

Backstory

First, there was XULRunner. In 2007, this was turned into an experimental product called Mozilla Prism. (Also popular at the time was Fluid for Mac OS X.) In 2011, Mozilla launched an initiative targeting Firefox for desktop, Chrome/etc. for desktop, Firefox for Android, and Firefox OS, in that order. Evolved from the same codebase and team as the Firefox Add-ons program, there was an "app store" for HTML5, cross-platform, cross-browser web applications, Open Web Apps, called the Firefox Marketplace.

Open Web Apps

Developers could build HTML5 apps targeting desktop, tablet, and mobile devices. These chromeless, cross-platform web applications were called Open Web Apps (OWAs

View random.js
_getRandomEnvironment = environments => {
const randomEnvironmentIndex = () => Math.floor(Math.random() * environments.length);
let newEnvironmentIndex = randomEnvironmentIndex();
if (this.state && this.state.hasOwnProperty('environmentIndex') && environments.length > 1) {
while (newEnvironmentIndex === this.state.environmentIndex) {
newEnvironmentIndex = randomEnvironmentIndex();
}
}
return newEnvironmentIndex;
};
View ghost_footer.html