- V: Selection tool
- A: Direct Selection tool (more fine-grained selection)
- Command + U: Smart Guides snapping on/off
- Command + G: group selected objects
- Command + Shift + G: ungroup selected objects
- Tab: show/hide panels and other UI elements
- Command + Shift + /: search all menu items (this works in all native Mac apps)
- Command + `: cycle through tabs
- Command + Option + P > Edit Artboards: resize drawing canvas. Drag to required size then hit Escape
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
document.addEventListener('click', function (e) { | |
for (let target = e.target; target && target != this; target = target.parentNode) { | |
if (target.matches('.foo')) { | |
// ⋯ | |
e.preventDefault(); | |
break; | |
} else if (target.matches('.bar')) { | |
// ⋯ | |
e.preventDefault(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Fetch JSON data | |
fetch('https://jsonplaceholder.typicode.com/todos/').then(response => { | |
// Success | |
if (response.ok) | |
return response.json(); // Returns to then() | |
// Error | |
return Promise.reject(response); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
window.scrollTo({ | |
top: document.getElementById('foo').offsetTop, | |
left: 0, | |
behavior: 'smooth' | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Loop array | |
const foo = ["ane", "twa", "three"]; | |
foo.forEach(item => console.log(item)); | |
// Loop DOM elements | |
document.querySelectorAll('.foo').forEach(el => { | |
el.classList.add('bar'); // Add class, for example | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
https://measurethat.net/Benchmarks/ShowResult/170533 | |
Test name | Executions per second | |
----------------------------------------------- | |
getElementById | 9,737,553 ops/sec | |
getElementsByName | 6,090,861 ops/sec | |
querySelector | 5,577,396 ops/sec | |
getElementsByTagName | 4,900,635 ops/sec | |
getElementsByClassName | 4,736,003 ops/sec |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<title>Highlight element</title> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
<meta name="description" content="Find and highlight string" /> | |
<style type="text/css"> | |
html { | |
font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Oxygen, Ubuntu, Cantarell, Open Sans, Helvetica Neue; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Source: https://github.com/cferdinandi/reef/commit/20e47e2b6e797e5201da1d8b2e7fb02504a25c6f#diff-26a6046c932328aabcf6b2db468298d6958105007730a04f6e1b942d7d916f07R43-R50 | |
function getType(obj) { | |
return Object.prototype.toString.call(obj).slice(8, -1).toLowerCase(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.foo { | |
--color0: 214, 51, 132; /* --bd-pink-rgb */ | |
--color1: 255, 255, 255; /* --bs-white-rgb */ | |
--color2: 13, 110, 253; /* --bs-primary-rgb */ | |
--color3: 255, 228, 132; /* --bd-accent-rgb */ | |
--color4: 112.520718, 44.062154, 249.437846; /* --bd-violet-rgb */ | |
background-image: linear-gradient( | |
180deg, | |
rgba(var(--color1), 0.01), | |
rgba(var(--color1), 1) 85% |
- Command + L: go to the current song
- I use this when I’m listening to something and searching for something else, and then want to get back to the currently playing song in the context in which I started playing it (e.g. from an album or playlist)
- Command + F: search
- Similar to Command + L or Command + K in Spotify
- Command + Option + F: find in playlist
- Similar to Spotify’s Filter function
- Command + [: go back (à la Safari)
- Doesn’t work universally, or at least not like it does in Safari or Spotify