Skip to content

Instantly share code, notes, and snippets.

View linj121's full-sized avatar
:shipit:
Focusing

Josh linj121

:shipit:
Focusing
View GitHub Profile
// Author: Josh Comeau
// https://courses.joshwcomeau.com/css-for-js
// Replace “.the-sticky-child” for a CSS selector
// that matches the sticky-position element:
const selector = '.the-sticky-child';
function findCulprits(elem) {
if (!elem) {
throw new Error(
// Author: Josh Comeau
// https://courses.joshwcomeau.com/css-for-js/
// Helps developers finding the parent element that break the fixed position
// Replace “.the-fixed-child” for a CSS selector
// that matches the fixed-position element:
const selector = '.the-fixed-child';
@linj121
linj121 / model.py
Last active February 25, 2024 23:38
Floyd Cycle Detection
class FloydCycleModel:
def __init__(self, cycleLength: int, fasterSpeed: int, slowerSpeed: int) -> None:
self.CycleLength = cycleLength
self.FasterSpeed = fasterSpeed
self.SlowerSpeed = slowerSpeed
def calcIterations(self, n: int) -> int:
return n * self.CycleLength / (self.FasterSpeed - self.SlowerSpeed)
def argmin(self) -> int: