Skip to content

Instantly share code, notes, and snippets.

View cvan's full-sized avatar
🚌
🌊

Christopher Van cvan

🚌
🌊
View GitHub Profile
@cvan
cvan / reusable-svgs-symbol-ref-by-id.md
Created April 19, 2023 02:36
reuse SVG multiple times on same web page

View DEMO

demo of rendering templated SVGs by defining the shape once

Creating SVG templated elements

Why? Less code is sent down the wire to the user ("the client," the browser). This means faster page load times since it's less code. As a principle, a smaller and flatter DOM structure is going to perform better in the browser. In general, the larger the DOM node tree, the slower, manipulations to the structure will be more expensive by the browser's layout system.

@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 / strip-html-comments.js
Created July 21, 2020 23:24
strip html comments javascript
function stripHtmlComments(html) {
// Remove HTML comments (useful for removing developer-facing comments from production HTML markup).
return html.replace(/<!--[\s\S]*?(?:-->)/g, '');
}
@cvan
cvan / synthesiseEvents.js
Last active November 3, 2023 21:24
sythensise key events and mouse events
var allowedEvents = {
'KeyboardEvent': [
'input',
'keydown',
'keypress',
'keyup'
],
'MouseEvent': [
'click',
'contextmenu',
@cvan
cvan / made-with-nextjs.md
Last active October 30, 2023 09:51
next.js production examples - sites in the wild open with open-source code
@cvan
cvan / css-debug.css
Last active October 27, 2023 03:03
css debug hierarchy of nodes
* {
outline: 2px dotted red;
}
* * {
outline: 2px dotted green;
}
* * * {
outline: 2px dotted orange;
}
* * * * {
@cvan
cvan / help.js
Last active October 23, 2023 04:10
[Node.js] get Operating-System Platform (Windows, macOS, Linux) and Architecture (x32, x64, etc.) (without any third-party npm dependencies)
const os = require('os');
// See docs: https://nodejs.org/api/os.html
const usage = {};
usage[`require('os').type()`] = {
value: os.type(),
otherValues: [
'Linux', 'Darwin', 'Windows_NT'
],
@cvan
cvan / adb-shell.txt
Created September 21, 2017 21:15
Attempting to launch Oculus Browser with Chrome for Android's Intents
# Command:
adb shell am start -n "com.oculus.vrshell/.MainActivity" -d apk://com.oculus.browser -e uri https://aframe.io/aframe/examples/showcase/spheres-and-fog/
# Output:
09-22 03:59:12.368 3820 20762 I ActivityManager: START u0 {act=null typ=null flg=0x10000000 cmp=ComponentInfo{com.oculus.vrshell/com.oculus.vrshell.MainActivity}} from uid 2000 on display 0
09-22 03:59:12.375 3820 20762 W ActivityManager: GearVR not ready: not allowed to start VR Activity. activity=ComponentInfo{com.oculus.vrshell/com.oculus.vrshell.MainActivity} intent=Intent { dat=apk://com.oculus.browser flg=0x10800000 cmp=com.oculus.vrshell/.MainActivity launchParam=MultiScreenLaunchParams { mDisplayId=0 mBaseDisplayId=0 mFlags=0 } (has extras) } isVrActivity=true
09-22 03:59:13.024 10937 10959 V VRSVC : (LogEvent.java:206) yTqX [onLaunchCancelled reason=hmt pIntent=Intent { dat=apk://com.oculus.browser flg=0x10800000 cmp=com.oculus.vrshell/.MainActivity launchParam=MultiScreenLaunchParams { mDisplayId=0 mBaseDisplayId=0 mFlags=0
@cvan
cvan / limd-build-macos.sh
Last active October 10, 2023 03:16 — forked from nikias/limd-build-macos.sh
Build libimobiledevice stack for macOS with ease
#!/bin/bash
# If you like this script and my work on libimobiledevice, please
# consider becoming a patron at https://patreon.com/nikias - Thanks <3
REV=1.0.12
if test -x "`which tput`"; then
ncolors=`tput colors`
if test -n "$ncolors" && test $ncolors -ge 8; then
@cvan
cvan / actions_debugging.md
Created April 13, 2023 19:16
debug show print reveal github secrets in github actions workflows jobs