Skip to content

Instantly share code, notes, and snippets.

View iamuchejude's full-sized avatar
🎯
Focusing

Jude iamuchejude

🎯
Focusing
  • nebenan.de
  • Berlin, Germany
  • 01:36 (UTC +02:00)
  • X @iamuchejude
View GitHub Profile
type Prettify<T> = {
[K in keyof T]: T[K];
} & {};
type A = {
a: 1;
b: 2;
}
type C = {
@iamuchejude
iamuchejude / run-tasks.ts
Created September 15, 2021 22:29
solution
import { TaskDict, TaskResultDict } from "./types";
const isPromise = (obj: any) => typeof obj?.then === "function";
const runTasks = async (tasks: TaskDict): Promise<TaskResultDict> => {
let results: TaskResultDict = {};
const executeTask = async (taskId: string): Promise<any> => {
const { dependencies, task: fn } = tasks[taskId];
@iamuchejude
iamuchejude / index.md
Created November 29, 2020 04:53 — forked from bvaughn/index.md
Interaction tracing with React

Interaction tracing with React

React recently introduced an experimental profiler API. After discussing this API with several teams at Facebook, one common piece of feedback was that the performance information would be more useful if it could be associated with the events that caused the application to render (e.g. button click, XHR response). Tracing these events (or "interactions") would enable more powerful tooling to be built around the timing information, capable of answering questions like "What caused this really slow commit?" or "How long does it typically take for this interaction to update the DOM?".

With version 16.4.3, React added experimental support for this tracing by way of a new NPM package, scheduler. However the public API for this package is not yet finalized and will likely change with upcoming minor releases, so it should be used with caution.

This Gist provides some high-level docum

@iamuchejude
iamuchejude / index.js
Created October 31, 2019 07:19
JavaScript implementation of Pig Latin encoding
function encodeString(str) {
str = str.toLowerCase();
const vowels = ["a", "e", "i", "o", "u"];
const re = /[aeiouy]/gi;
if (vowels.includes(str[0])) {
return str + "ay";
}
@iamuchejude
iamuchejude / Keybase
Created September 12, 2019 09:16
keybase.md
### Keybase proof
I hereby claim:
* I am iamuchejude on github.
* I am iamuchejude (https://keybase.io/iamuchejude) on keybase.
* I have a public key ASCbnIfLkOl-qeWc3vdOtPpPMcLtmOoTLRG9gc1Q1G9BTAo
To claim this, I am signing this object:
@iamuchejude
iamuchejude / postgres-cheatsheet.md
Created August 3, 2019 11:48 — forked from Kartones/postgres-cheatsheet.md
PostgreSQL command line cheatsheet

PSQL

Magic words:

psql -U postgres

Some interesting flags (to see all, use -h or --help depending on your psql version):

  • -E: will describe the underlaying queries of the \ commands (cool for learning!)
  • -l: psql will list all databases and then exit (useful if the user you connect with doesn't has a default database, like at AWS RDS)
@iamuchejude
iamuchejude / postgres-cheatsheet.md
Created August 3, 2019 11:48 — forked from Kartones/postgres-cheatsheet.md
PostgreSQL command line cheatsheet

PSQL

Magic words:

psql -U postgres

Some interesting flags (to see all, use -h or --help depending on your psql version):

  • -E: will describe the underlaying queries of the \ commands (cool for learning!)
  • -l: psql will list all databases and then exit (useful if the user you connect with doesn't has a default database, like at AWS RDS)
@iamuchejude
iamuchejude / index.js
Last active July 11, 2019 16:42
Chaser Code Test
/**
*
* @param {array} arrayOfObjects array of objects (name and ranking)
* @returns {array} array of objects, ordered by ranking
*/
const orderByRanking = arrayOfObjects => {
if (!Array.isArray(arrayOfObjects)) {
throw new TypeError("Array expected");
}
@iamuchejude
iamuchejude / index.js
Created February 21, 2019 05:04
Check if number is a valid square of a number
const isValidSquare = num =>
num === Math.sqrt(num) * Math.sqrt(num) && num % Math.trunc(Math.sqrt(num)) === 0
@iamuchejude
iamuchejude / index.js
Created February 21, 2019 00:07
Lonely integer created by iamuchejude - https://repl.it/@iamuchejude/Lonely-integer
const lonelyInteger = nums =>
nums.reduce((lonely, num) =>
nums.indexOf(num) !== nums.lastIndexOf(num) ? lonely = num : lonely, null);