In newer versions of Node.js you can register your own loader and resolvers.
This is an example of automatically transpiling .ts files.
Usage:
> node --import ./ts-loader.mjs ./my-app.ts
| type LengthOfString<T extends string, S extends string[] = []> = T extends `${string}${infer R}` ? LengthOfString<R, [...S, string]> : S['length']; | |
| type HasLengthOfEight<T extends string> = LengthOfString<T> extends 8 ? T : never; | |
| type Digit = '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9'; | |
| type IsNumeric<T extends string, S = T> = T extends Digit ? S : T extends `${Digit}${infer R}` ? IsNumeric<R, S> : never; | |
| type StartsWithNonZeroDigit<T extends string> = T extends `${Exclude<Digit, '0'>}${string}` ? T : never; | |
| type CVRNummer<T extends string> = IsNumeric<T> & HasLengthOfEight<T> & StartsWithNonZeroDigit<T>; |
| /** | |
| * @typedef {object} Header - JOSE Header https://datatracker.ietf.org/doc/html/rfc7519#section-5 | |
| * @property {string} typ - Type https://datatracker.ietf.org/doc/html/rfc7519#section-5.1 | |
| * @property {string} alg - Algorithm https://datatracker.ietf.org/doc/html/rfc7515#section-4.1.1 | |
| */ | |
| /** | |
| * @param {string} char - a string containing a single character | |
| */ | |
| const toURIComponent = (char) => '%' + ('00' + char.charCodeAt(0).toString(16)).slice(-2); |
| # Simple Node.js version manager | |
| # | |
| # Usage example: | |
| # $ use-node 16 | |
| # | |
| # The strategy is to identify the Homebrew version, e.g. 'node@16', and the prepend the path to its binaries to $PATH. | |
| # Caveat: This only supports selecting a major version, as that's the level of granularity that Homebrew provides. | |
| use-node() { | |
| if [[ "$1" == "$(node --version | sed 's/v\([0-9]*\).*/\1/')" ]]; then | |
| return 0; |
| def cpr = '0101374000' | |
| def match = (cpr =~ /^\d{4}(\d{\d}2})(\d)\d{3}$/)[0] | |
| def year = match[1] as Integer | |
| def x = match[2] as Integer | |
| switch (x) { | |
| case 0..3: year += 1900; break; | |
| case [4, 9]: year += year <= 36 ? 2000 : 1900; break; |
In config/app.php in the 'providers' section, replace Illuminate\Translation\TranslationServiceProvider::class with App\Translation\TranslationServiceProvider::class
| window.addEventListener('load', function() { | |
| if (!document.location.href.startsWith('https://app.clubhouse.io/')) { return; } | |
| function isDropdownNode(node) { | |
| return node.nodeType === Node.ELEMENT_NODE && node.classList.contains('dropdown'); | |
| } | |
| document.addEventListener('DOMNodeInserted', function(event) { | |
| var insertedNode = event.target; |
| <?php | |
| namespace App\Providers; | |
| use App\Auth\CompositeGuard; | |
| use Illuminate\Auth\TokenGuard; | |
| use Illuminate\Foundation\Application; | |
| use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider; | |
| use MiladRahimi\LaraJwt\Guards\Jwt as JwtGuard; |
| <?php | |
| namespace App\Console; | |
| use Illuminate\Console\Application as Artisan; | |
| use Illuminate\Console\Command; | |
| use Illuminate\Foundation\Console\Kernel as ConsoleKernel; | |
| use ReflectionClass; | |
| use Symfony\Component\Finder\Finder; |
| # Assumes you have installed individual major versions with Homebrew, like node@8, | |
| # this command allows you to switch by calling e.g. `use-node 8`, or to get the | |
| # current latest version (`brew install node`) if you don't pass an argument. | |
| # Notice: Since it modifies the env, this will only work for the current session. | |
| # I.e. other terminal windows will have the default Node version, unless they’re also changed. | |
| use-node() { | |
| wanted=$([ "$1" == "" ] && echo "node" || echo "node@$1") | |
| prefix=$(brew --prefix $wanted 2> /dev/null) | |
| if [ "$prefix" != "" ]; then | |
| PATH="$(echo $PATH | tr ':' '\n' | grep -v ${prefix%@*} | tr '\n' ':')" |