- Prerequisites:
- You need a running macOS system.
- I assume you're familiar with using the terminal.
- All the examples below refer to installing macOS High Sierra, you may need to adjust them to your needs if you want to install another macOS version.
- Download macOS High Sierra from the AppStore.
- The macOS installer will start after the download finiashes. We don't need it, so we can close it.
- We need an empty image where we'll put the installer. Let's create one using the macOS DiskUtil CLI:
hdiutil create -o /tmp/HighSierra -size 8G -layout SPUD -fs HFS+J -type SPARSE
import revHash from 'rev-hash' | |
import { readFileSync, statSync } from 'fs' | |
import { resolve } from 'path' | |
/** | |
* Calculate the rev hash for a file | |
* | |
* @param {string} file The path to the file to hash | |
* @returns {string} | |
*/ |
/** | |
* Find nodes via XPath | |
* | |
* @param {string} query | |
* @param {Node} root | |
* @returns {Node[]} | |
*/ | |
export function xpath(query, root = document) { | |
let iterator = document.evaluate(query, document) |
The zipTree
function exported from this module takes a file tree object and creates a zip object from it using JSZip (which you need to install first via npm install jszip
):
// A tree is just a collection of file names mapped to their contents
let data = {
// Use a string for text content
'file.txt': '...file content...',
A simple & classic debounce function. You provide a callable and specify a $wait
timer and get a callable (closure) back.
The closure takes the same arguments as the provided callable, but will only be executed $wait
seconds after being invoked. Invoking the closure again before $wait
seconds have passed will refresh the execution delay to the full $wait
seconds again.
This can be useful for example for detecting if a socket hasn't received data in, let's say, 10 seconds:
$loop = React\EventLoop\Factory::create();
import { createFilter } from '@rollup/pluginutils' | |
import got from 'got' | |
import MagicString from 'magic-string' | |
import path from 'node:path' | |
import revisionHash from 'rev-hash' | |
function escapeRegex(string) { | |
return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&') | |
} |
To the extent possible under law,
Florian Reuschel
A sorting function that takes an array of samples. All sortable items which occur in the samples will be arranged in the order they occur there, all other items will be appended to the end in their original order or sorted with an optional provided comparision algorithm.
This can be useful when the items to sort are not completely known, but there are some well-known ones that should come first:
const pages = [ 'About', 'Products', 'Home', 'Contact', 'Carreer' ]
// No idea what pages exist, but if "Home" and "About" exist, they should come first
// useElementBreakpoints is a Vue 3 composable that matches an element's width (or height) against a set of predefined breakpoints | |
// It needs @vueuse/core to be installed and uses an equivalent breakpoints input as well as an equivalent returned API | |
import { computed, Ref } from 'vue' | |
import { useElementSize, MaybeElementRef } from '@vueuse/core' | |
export type Breakpoints<K extends string = string> = Record<K, number> | |
export type ElementBreakpointsOptions = { dimension: 'width' | 'height' } | |
/** |