- 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
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();Extract structures from PHP arrays, kind of like an advanced pluck.
The provided xtract function takes a $source (usually an array) and a $target, which is the structure to transform the $source into:
mixed xtract( mixed $source, mixed $target )This has first been published as an article on dev.to.
From time to time, I have the need to temporarily store the results of a method call in Vue templates. This is particularly common inside loops, where we cannot easily use computed properties.
Basically what we'd want to avoid is this:
<!-- List.vue -->Implementation of the Node module resolution algorithm (aka require.resolve()) in PHP.
Depends on league/flysystem and illuminate/support.
use League\Flysystem\Filesystem;
use League\Flysystem\Adapter\Local;| 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} | |
| */ |
This post was inspired by having to pass around ReactPHP's event loop all day.
😑 Are you tired of managing loads of use (...) constructs because you need some local variable inside a deeply nested closure?
🤯 Use the following tiny function abusing Closure::bind() to bend variable scope to your will!
function run_scoped(Closure $callback, $init = [])A container component reacting to breakpoints on its own width or height, powered by ResizeObserver and scoped slots.
It is similar to things like vue-resize in that you can use it to observe a component's size. However the ResponsiveContainer will not emit any events, its whole point is to work as declaratively as possible, taking a predefined set of breakpoints you can access in your component.
| /** | |
| * Mock an object with a proxy, overriding methods and properties | |
| * | |
| * @param {object} object An object to mock | |
| * @param {object} implementations The properties/methods to virtually "merge" into the mocked object | |
| */ | |
| function moxy(object, implementations) { | |
| return new Proxy(object, { | |
| get(target, key, receiver) { | |
| if (key in implementations) { |