TIL #9: ownerDocument.defaultView
First published on
on html, javascript, typescript

Despite considering my self a seasoned programmer and being developing for over 15 years, I’m surprised I didn’t know about the ownerDocument.defaultView property.

I basically returns the window object (or null) associated with a specific DOM node. It could be used to safely attach an event listener to a window object from a component that is rendered outside the main window where the application was initially rendered (think portals).

function ThemeProvider({ children }) {
  const [theme, setTheme] = useState("light");
  const ref = useRef(null);

  useEffect(() => {
    const win = ref.current?.ownerDocument.defaultView || window;

    const toggle = (e) => {
      if (e.metaKey && e.key === "d") {
        e.preventDefault();
        setTheme((t) => (t === "dark" ? "light" : "dark"));
      }
    };

    win.addEventListener("keydown", toggle);

    return () => win.removeEventListener("keydown", toggle);
  }, []);

  return (
    <div ref={ref} className={theme}>
      {children}
    </div>
  );
}

From the same article, also learned about useId and cache 😛

Reference: https://shud.in/thoughts/build-bulletproof-react-components, great article btw! 💯


Blender shortcuts
First published on
on css, html

I was reviewing a page that I have in Notion about Three.js, with bookmarks, links to articles, utilities, tools, repositories, etc, and found a good one about Blender shortcuts, some of them I didn’t know about (I mean, I’m just getting started in Blender anyways) like the Snap shortcuts or the Clear transform, and I wanted to share it here:

http://hollisbrown.github.io/blendershortcuts

TIL #8: The Fresnel Effect
First published on
on threejs, glsl, webgl, effects

I’m watching some of the missing lessons on shaders that I have in the Three.js journey course, and today I learned about the Fresnel effect in Three.js. It is used to create a more realistic rendering of materials by simulating how light interacts with surfaces at different angles.

The Fresnel effect causes surfaces to reflect more light at glancing angles, which can enhance the realism of materials like water, glass, and metals.

It can be used for effects like:

  • Glass/Water: Simulating realistic reflections on transparent surfaces.
  • Ghostly/Energy Effects: Creating an inner or outer glow around objects that emphasizes their silhouette.
  • Highlighting Objects: Serving as a low-cost alternative to outline effects for interactive items

Here is a simplified implementation from the Three.js journey course, to create an holographic effect:

// Vertex shader.
varying vec3 vPosition;
varying vec3 vNormal;

void main() {
  vec4 modelPosition = modelMatrix * vec4(position, 1.0);
  vec4 modelNormal = modelMatrix * vec4(normal, 0.0);

  gl_Position = projectionMatrix * viewMatrix * modelPosition;

  vPosition = modelPosition.xyz;
  vNormal = modelNormal.xyz;
}
// Fragment shader.
varying vec3 vPosition;
varying vec3 vNormal;

void main() {
  vec3 normal = normalize(vNormal);

  if(!gl_FrontFacing) {
    normal = -normal;
  }

  // Fresnel effect
  vec3 viewDirection = normalize(vPosition - cameraPosition);
  float fresnel = dot(viewDirection, normal) + 1.0;
  fresnel = pow(fresnel, 2.0);

  // Final output
  gl_FragColor = vec4(vec3(0.0, 1.0, 1.0), fresnel);
}

Quoting Matt Shumer
First published on
on quotes

It’s so capable that I sometimes don’t know what to do with myself while it’s running. That’s a weird problem to have.
Matt Shumer, on My GPT-5.3-Codex Review


TIL #7: SVG Filters
First published on
on css, html, svg, effects, filters

SVG filters allow you to create complex visual effects directly within your SVG graphics using a variety of filter primitives. You can apply effects like blurring, color manipulation, and even custom distortions to your SVG elements.

SVG Filters

<p class="ripple-text">SVG Filters</p>

<svg style="position: absolute; width: 0px; height: 0px; pointer-events: none;">
  <filter id="water-ripple">
    <feTurbulence
      type="fractalNoise"
      baseFrequency="0.05"
      numOctaves="2"
      result="ripple"
    >
      <animate
        attributeName="baseFrequency"
        dur="10s"
        values="0.02;0.05;0.02"
        repeatCount="indefinite"
      ></animate>
    </feTurbulence>
    <feDisplacementMap
      in="SourceGraphic"
      in2="ripple"
      scale="5"
    ></feDisplacementMap>
  </filter>
</svg>
.ripple-text {
  font-size: clamp(2rem, 4vw, 3rem);
  font-weight: bold;
  text-align: center;
  filter: url(#water-ripple);
}

Using 100vw is now scrollbar-aware (in Chrome 145+, under the right conditions)
First published on
on css, html

From Chrome 145 onwards, 100vw will automatically subtract the size of the (vertical) scrollbar from it if you have forced the html element to always show a vertical scrollbar (using overflow[-y]: scroll) or if you reserve space for it (using scrollbar-gutter: stable).

Via https://www.bram.us/2026/01/15/100vw-horizontal-overflow-no-more/


On Artificial Intelligence and technological limitation
First published on
on quotes

We invented AI to write pretty poems and draw cute pictures, so I have more time to take care of my laundry. It should be the other way around, right?

Julian Hespenheide (Excerpt from an answer of an interview to Julian Hespenheide by Tim Rodenbröker)


Technological limitation
First published on
on quotes

This might sound funny at first, but technological limitation to me is anti-consumerist at best: Do companies hold back their inventions to turn more profit each cycle? How many billion people out there have the most advanced technology on them just for scrolling through Instagram and sending funny emojis on WhatsApp? Those devices are technically unlimited in every sense, yet no one takes the time to use them to any of their respective extents.

Julian Hespenheide (Excerpt from an answer of an interview to Julian Hespenheide by Tim Rodenbröker)


TIL #6: SVG Favicons
First published on
on css, html, svg, icons
<svg xmlns="http://w3.org/2000/svg" viewBox="0 0 100 100">
  <text y=".9em" font-size="90">👾</text>
</svg>

Reference:

More description SVG favicons and favicons maintain general:


TIL #5: :source % command in vim
First published on
on cli, command, vim, nvim

The command :source % in Vim reloads the Vim configuration file (such as ~/.vimrc) into the current session, updating any changes you’ve made to it. The :source command executes the VimScript commands contained in a file, and % is a shortcut that represents the name of the file currently open in the buffer.

:source %