Skip to content

Instantly share code, notes, and snippets.

View arbaz52's full-sized avatar
💭
Developing

Arbaz Ajaz arbaz52

💭
Developing
View GitHub Profile
const recursive = (input: string[][]): string[][] => {
if (input.length === 0) return [];
if (input.length === 1) return input[0].map((i) => [i]);
const arr = input[0];
const perm = recursive(input.slice(1));
const result = arr.map((a) => perm.map((p) => [a, ...p])).flat(1);
return result;
};
@arbaz52
arbaz52 / ct-741.md
Created January 20, 2022 09:33
CT-741

CT-741

The goal of this document is to help answer the following:

  • How to calculate cost of using Vonage's video API?
  • How do we access/store/maintain required data/information?

This document assumes we are being billed based on PPM (Participant-based Pricing Model).

What is PPM?

@arbaz52
arbaz52 / dynamic-rename-key.ts
Created January 3, 2022 05:23
Rename key inside an interface
export type RenameKey<I, K extends keyof I, N extends PropertyKey> = Omit<
I,
K
> &
{
[P in N]: I[K];
};
@arbaz52
arbaz52 / react-ps.md
Last active December 22, 2021 11:02
Project Structure for React

react-ps

react-ps is an a proposed React.js application's project structure. The document is currently under developement but will be available soon for inspiration.

Component

A component is a react component responsible for the visuals following the file/folder structure. Please note NewsLetter is the name of the component

.
@arbaz52
arbaz52 / setup-react-storybook.md
Created December 21, 2021 07:23
Setup Storybook for React project using alias imports

Storybook

Storybook streamlines the UI development, testing and documentation.

Setup Storybook

In order to setup storybook in an already existing react app, we will follow the following steps.

  • Use the storybook CLI to install it in a single command. Run the following command inside your existing project's root directory:
@arbaz52
arbaz52 / tsModifiers.ts
Created September 12, 2021 20:16
Typescript Custom Type Modifiers
export type ModifyKey<I, K extends keyof I, V> = Omit<I, K> &
{ [K in keyof I]: V };
export type PickAndModifyKey<I, K extends keyof I, V> = ModifyKey<
Pick<I, K>,
K,
V
>;
// key should be an interface/object
@arbaz52
arbaz52 / usage.selective-context-consumer.tsx
Created July 22, 2021 08:07
Usage: Selective Context Consumer Library
import {
FC,
memo,
useRef,
useEffect,
useReducer,
useCallback,
createContext,
} from "react";
import { SelectiveContextConsumer } from "selective-context-consumer";
const SYMBOLS = {
"I": 1,
"V": 5,
"X": 10,
"L": 50,
"C": 100,
"D": 500,
"M": 1000
}
    u i o
    j k l
      +
ctrl/alt/shift

alt + i/k/j/l move up/down/left/right on character (+ shift to select/highlight)
alt + u/o move to start/end of the current line (+ shift to select/highlight)
alt + ctrl + j/l move start of current/left word | end of current/right word (+ shift to select/highlight)
@arbaz52
arbaz52 / keybindings.json
Created May 8, 2021 15:33
VS Code - Key bindings for movement if you hate using arrow keys.
[
/*
u i o
j k l
+
ctrl/alt/shift
alt + i/k/j/l move up/down/left/right on character (+ shift to select/highlight)
alt + u/o move to start/end of the current line (+ shift to select/highlight)