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
/** | |
* Mini template engine. Parses variables (w/o dot notation) and does not delete undefined variable expressions. | |
* @param {string} expr - String expression with {{variables}} to interpolate. | |
* @param {RegExp} [regex] - Custom regex to match variables. By default it matches double curly braces `{{variables}}`. | |
* @returns {(data:Object|string[]) => void} - A function that accepts an object or an array as argument to interpolate the template variables. | |
* @example | |
* const templateObj = parseTemplate('{{a}} {{b.c}}'); | |
* template({a: 'hello', b: {c:'world'}}); // "hello world" | |
* | |
* const templateArr = parseTemplate('{{}} {{}}'); |
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
#!/usr/bin/env sh | |
# This loads nvm | |
export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")" | |
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" | |
# Bypass if a merge is happening | |
function skipIfMerging() { | |
local isMerge="$(git rev-parse -q --verify MERGE_HEAD)" | |
# If isMerge is a hash, a merge is ongoing |
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
const callbacks = []; | |
const fpsInterval = 1000 / 60; | |
let time = performance.now(); | |
function requestAnimationFrameLoop() { | |
const now = performance.now(); | |
const delta = now - time; | |
if (delta >= fpsInterval) { | |
// Adjust next execution time in case this loop took longer to execute | |
time = now - (delta % fpsInterval); |
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
@ECHO OFF | |
IF "%~1"=="" GOTO Continue | |
IF "%~1"=="-h" GOTO Continue | |
IF "%~2"=="" GOTO No2ndParam | |
IF NOT EXIST %1 GOTO NoWinDir1 | |
IF NOT EXIST %2 GOTO NoWinDir2 | |
PUSHD %1 |