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
/** | |
* Pre-loads an image on the browser retrying in case of error. | |
* @param {String} src - Remote url | |
* @param {Number} [retries=3] - How many times to re-try in case of error | |
* @param {Number} [delay=300] - Amount of milliseconds to wait prior retrying in case of error. | |
* @return Promise.<HTMLElement> - Resolves the created image | |
* @throws {Error} - Once exhausted all `retries`, the last error thrown by the dom element | |
*/ | |
export function preloadImage (src, { retries = 3, delay = 300 } = {}) { |
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 { explainSync as _explainSync, explain as _explain } from 'jsdoc-api' | |
import path from 'path' | |
import fs from 'fs' | |
import os from 'os' | |
const tmpDirHasLeadingUnderscore = () => /\/_/.test(os.tmpdir()) | |
/** | |
* Quick fix for jsdoc-api issue#19 | |
* |
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
// As part of an technical screening interview I was requested to create the following function | |
/** | |
* Finds whether given `a` matches pattern `b` | |
* | |
* Pattern constrains: | |
* 1 <= length(a), length(b) <= 9e4 | |
* '?' : Matches any single character. | |
* '*' : Matches any sequence of characters (including the empty sequence). | |
* |
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
/** | |
* | |
* @parameter: {String} t - Given word | |
* @return: {Boolean} whether given word (`t`) is or not a palindrome. | |
* | |
* @see: https://en.wikipedia.org/wiki/Palindrome | |
*/ | |
function isPalindrome (t) { | |
if (typeof t !== 'string' || t.length === 0) { |
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
/** | |
* As part of a technical screening interview I was requested to create a function | |
* able to calculate the total score of a game after all of the given rounds were completed | |
* following the criteria below: | |
* | |
* The function receives an array of strings restricted to the following operation: | |
* Integer: Directly represents the number of points scored this round. | |
* +: The points scored this round are the sum of the last two valid round's points. | |
* D: The points scored this round are double the last valid round's points. | |
* C: The last valid round's points were invalid and should not be counted towards the total score or any future operations. |
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
/** | |
* As part of a technical screening interview I was requested to create a function | |
* able to perform a binary search. | |
* | |
* @param {Number[]} arr - A sorted array | |
* @param {Number} k - Number to find | |
* @return {Number} index position where k was found in the array | |
* | |
* @see: https://en.wikipedia.org/wiki/Binary_search_algorithm | |
*/ |
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
/** | |
* As part of a technical on-site screening-interview I was requested to create a function | |
* able to find two numbers in array `arr` that added together would equal given number `k`. | |
* | |
* I initially did an approach equal to run the function below with the option `reduceIterations=false`. | |
* | |
* My interviewer asked if I had a better approach: honestly, not only I had a headache but also I was already screened | |
* remotely and was not expecting more coding review: especially on the spot. I don't know, first time interviewing | |
* in the US... The thing is, he suggested using a 'table hash' (first time I heard the term) to reduce iteration. At | |
* the beginning I did not understand him (probably due to my technical language barer) but then I realized he wanted |
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
#!/usr/bin/env bash | |
SRC_URI=<source-connection-uri> | |
SRC_DB=<source-database-name> | |
DST_URI=<destination-connection-uri> | |
DST_DB=<destination-database-name> | |
FLOW=1000 | |
mongodump --archive --uri $SRC_URI --db $SRC_DB | mongorestore --archive --uri $DST_URI --db $DST_DB --numInsertionWorkersPerCollection=$FLOW |
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
perl -n -e'/(\d+) events processed!/ && print $1' |
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
#!/bin/bash | |
# prints remote github-url | |
function ghr () { | |
GITHUB_REMOTE=$(git config --get remote.origin.url) | |
if [ $? -eq 1 ]; then | |
echo "either not a github repo or remote not found 😙" | |
return 1 | |
fi | |
OlderNewer