Skip to content

Instantly share code, notes, and snippets.

View alexnodejs's full-sized avatar
🎯
Focusing

Alexander Vasileyko alexnodejs

🎯
Focusing
View GitHub Profile
@beaucharman
beaucharman / debounce.js
Last active February 25, 2022 20:35
An ES6 implementation of the debounce function. "Debouncing enforces that a function not be called again until a certain amount of time has passed without it being called. As in 'execute this function only if 100 milliseconds have passed without it being called.'" - CSS-Tricks (https://css-tricks.com/the-difference-between-throttling-and-debounc…
function debounce(callback, wait, immediate = false) {
let timeout = null
return function() {
const callNow = immediate && !timeout
const next = () => callback.apply(this, arguments)
clearTimeout(timeout)
timeout = setTimeout(next, wait)
@xNekOIx
xNekOIx / iOSAutoLayoutDebug
Last active July 7, 2020 17:45
iOS AutoLayout debug
po [[UIWindow keyWindow] _autolayoutTrace] // prints layouts ambiguity
po [UIViewController _printHierarchy] // prints view controllers hierarchy
po [view constraintsAffectingLayoutForAxis:0] // horizontal
po [view constraintsAffectingLayoutForAxis:1] // vertical
[view hasAmbiguousLayout] // BOOL
[view exerciseAmbiguityInLayout] // visualizing ambiguity
UIViewAlertForUnsatisfiableConstraints // symbolic breakpoint
UIConstraintBasedLayoutDebugging // symbolic breakpoint