This file contains 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
<?php | |
/** | |
* Parse a filesize to its number of bytes | |
* | |
* @param string|int|float $input | |
* @param int $base | |
* @return int | |
* | |
* @see https://github.com/patrickkettner/filesize-parser, the original JavaScript implementation of this function |
This file contains 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
/** | |
* Convert a bitmask to an array of its individual bits | |
* | |
* @param {number} bitmask The bitmask to dissect | |
* @return {number[]} | |
* | |
* @example | |
* assert.equal(bitmaskToArray(0b101), [0b100, 0b001]) | |
*/ | |
export function bitmaskToArray(bitmask) { |
This file contains 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 { useEffect, useState } from 'react' | |
/** | |
* React hook which provides the size of the terminal, based on https://usehooks.com/useWindowSize/ | |
* Great for usage with Ink (https://npmjs.com/package/ink) | |
*/ | |
export function useTerminalSize() { | |
const [terminalSize, setTerminalSize] = useState([ | |
process.stdout.columns, | |
process.stdout.rows |
This is a Sass mixin to handle a 3-way dark mode. It relies on a data-theme
attribute on your <html>
element with a value of light
or dark
. If data-theme
is absent (i.e. it's neither light
nor dark
), the system's preferred mode is used.
body {
// matches data-theme="light" or data-theme="auto" with system instructing light mode
@include light {
background: white;
color: black;
This file contains 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
// This userscript redirects you to the English version of a website if it's denoted in the source code. | |
// Insert any URLs of websites below (after @match), for example https://developer.mozilla.org/* or https://www.php.net/* | |
// Use multiple @match clauses to enable the script on several domains. | |
// ==UserScript== | |
// @name Redirect to English | |
// @namespace http://tampermonkey.net/ | |
// @version 1.0 | |
// @description Redirect websites to their English version | |
// @author Florian Reuschel <florian@loilo.de> |
This file contains 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
<?php | |
function walk_dom(DOMNode $domNode, callable $callback): void | |
{ | |
foreach ($domNode->childNodes as $node) { | |
$callback($node); | |
if ($node->hasChildNodes()) { | |
walk_dom($node, $callback); | |
} |
This file contains 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
<?php | |
// In your AppServiceProvider's boot() method, put this: | |
Blade::directive('buffer', function () { | |
return '<?php ob_start(); ?>'; | |
}); | |
Blade::directive('endbuffer', function (string $name) { | |
if ($name === '') { | |
return '<?php ob_end_clean(); ?>'; |
This file contains 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
export default function on(target, event, listener) { | |
let targetObject, boundListener | |
return { | |
mounted() { | |
// Allow functions for client-only targets | |
targetObject = typeof target === 'function' ? target() : target | |
if (typeof listener === 'string') { | |
// If a string is passed as a listener, use a method with that name |