| Function | Shortcut |
|---|---|
| New Tab | ⌘ + T |
| Close Tab or Window | ⌘ + W (same as many mac apps) |
| Go to Tab | ⌘ + Number Key (ie: ⌘2 is 2nd tab) |
| Go to Split Pane by Direction | ⌘ + Option + Arrow Key |
| Cycle iTerm Windows | ⌘ + backtick (true of all mac apps and works with desktops/mission control) |
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
| function getType(obj) { | |
| const lowerCaseTheFirstLetter = (str) => str[0].toLowerCase() + str.slice(1); | |
| const type = typeof obj; | |
| if (type !== 'object') { | |
| return type; | |
| } | |
| return lowerCaseTheFirstLetter( | |
| Object.prototype.toString.call(obj).replace(/^\[object (\S+)\]$/, '$1') | |
| ); |
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
| (() => { | |
| "use strict"; | |
| const fileElem = document.querySelector("article input[type='file']"); | |
| const rootElem = document.querySelector("article #file-dissection"); | |
| fileElem?.addEventListener("change", handleFileChange); | |
| async function handleFileChange() { | |
| if (!fileElem.files?.length) return; |
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
| /** | |
| * Computes the modulus of two numbers, ensuring a non-negative result. | |
| * | |
| * @param {number} a - The dividend. | |
| * @param {number} b - The divisor. | |
| * @returns {number} The modulus, always non-negative. | |
| */ | |
| function mod(a, b) { | |
| if (b === 0) { | |
| throw new Error("Divisor must not be zero."); |
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
| let seats = [ | |
| [1, 1, 0, 1, 0], | |
| [0, 1, 1, 1, 0], | |
| [1, 0, 1, 0, 0], | |
| ]; | |
| function reserveFirstAvailableSeat(seats) { | |
| rows: for (let i = 0; i < seats.length; i++) { | |
| columns: for (let j = 0; j < seats[i].length; j++) { | |
| if (seats[i][j] === 0) { |
CentOS, Ubuntu, Slackware, etc. Whatever Linux-based OS it is, you can create a bootable USB for it by using a Mac.
Download it, copy it, whatever it takes to prepare that Linux-based OS .iso file
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
| function countFairPairs(nums, lower, upper) { | |
| let n = nums.length; | |
| let count = 0; | |
| nums.sort((a, b) => a - b) | |
| for (let i = 0; i < n; i++) { | |
| let lowerIndex = lowerBound(nums, lower - nums[i], i + 1, n - 1); | |
| let upperIndex = upperBound(nums, upper - nums[i], i + 1, n - 1); | |
| count += upperIndex - lowerIndex; | |
| } |
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
| import { useSyncExternalStore } from "react"; | |
| // For more on the useSyncExternalStore hook, see https://react.dev/reference/react/useSyncExternalStore | |
| // The code is almost identical to the source code of zustand, without types and some features stripped out. | |
| // Check the links to see the references in the source code. | |
| // The links are referencing the v5 of the library. If you plan on reading the source code yourself v5 is the best way to start. | |
| // The current v4 version contains lot of deprecated code and extra stuff that makes it hard to reason about if you're new to this. | |
| // https://github.com/pmndrs/zustand/blob/fe47d3e6c6671dbfb9856fda52cb5a3a855d97a6/src/vanilla.ts#L57-L94 | |
| function createStore(createState) { |
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
| class DDeque { | |
| constructor(items = []) { | |
| this.items = items; | |
| this.front = 0; | |
| this.rear = items.length - 1; | |
| this.size = items.length; | |
| } | |
| pushFront(item) { | |
| if (this.isEmpty()) { |
NewerOlder