Skip to content

Instantly share code, notes, and snippets.

View felixjb's full-sized avatar
:octocat:

Felix J. Batista felixjb

:octocat:
  • Amsterdam, North Holland, Netherlands
View GitHub Profile

Keybase proof

I hereby claim:

  • I am felixjb on github.
  • I am felixjb (https://keybase.io/felixjb) on keybase.
  • I have a public key ASBQnXCqpZacjshAJNVYvtBIscfDhMHn36MkwOri4Y-cWQo

To claim this, I am signing this object:

@felixjb
felixjb / vscode-testing.code-snippets
Created June 2, 2023 10:26
A snippet collection for VSCode containing common hooks and functions of JavaScript testing frameworks
{
// Place your global snippets here. Each snippet is defined under a snippet name and has a scope, prefix, body and
// description. Add comma separated ids of the languages where the snippet is applicable in the scope field. If scope
// is left empty or omitted, the snippet gets applied to all languages. The prefix is what is
// used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders.
// Placeholders with the same ids are connected.
// Example:
// "Print to console": {
// "scope": "javascript,typescript",
@felixjb
felixjb / retry.ts
Last active December 8, 2023 13:18
async retry function that accepts a callback and execution options as parameters
/**
* Waits for a number of milliseconds.
* @param timeInMilliseconds the time to wait in milliseconds
*/
export const wait = async (timeInMilliseconds: number): Promise<void> =>
new Promise((resolve) => setTimeout(resolve, timeInMilliseconds));
/**
* Retries an async callback function a number of times with a delay between retries.
* @template T - The type of the result of the callback.
@felixjb
felixjb / javascript-tricks.js
Created January 9, 2024 14:40
A collection of helpful tricks on JavaScript
// Create a Map from an Array
const array = [
{ key: "name", value: "Tom" },
{ key: "country", value: "Chile" },
];
// Return an array of tuples (array with two values, the key and the value)
const map = new Map(array.map((item) => [item.key, object.value]));
// ️👇️ {'name' => 'Tom', 'country' => 'Chile'}