Skip to content

Instantly share code, notes, and snippets.

View fatihsolhan's full-sized avatar
:shipit:

Fatih Solhan fatihsolhan

:shipit:
View GitHub Profile
@fatihsolhan
fatihsolhan / promise-based-memoization.ts
Last active April 12, 2022 21:51
Promise based memoization with a given cache size behaving as an LRU cache with an expiry time
const LRUCache = (size: number) => {
const storage = new Map();
const get = (key: string) => {
const value = storage.get(key);
if (value) {
storage.delete(key);
storage.set(key, value);
}
return value;
/** @jsxRuntime classic */
/** @jsx jsx */
import { Fragment, ReactNode, useState } from 'react';
import { Button } from '@keystone-ui/button';
import { Inline, jsx, Stack, useTheme } from '@keystone-ui/core';
import { FieldContainer, FieldLabel, FieldLegend } from '@keystone-ui/fields';
import { DrawerController } from '@keystone-ui/modals';
import {
/** @jsxRuntime classic */
/** @jsx jsx */
import 'intersection-observer';
import { RefObject, useEffect, useMemo, useState, createContext, useContext, useRef } from 'react';
import { jsx } from '@keystone-ui/core';
import { MultiSelect, Select, selectComponents } from '@keystone-ui/fields';
import { validate as validateUUID } from 'uuid';
import { IdFieldConfig, ListMeta } from '@keystone-6/core/types';
@fatihsolhan
fatihsolhan / material-design-icons.js
Last active January 14, 2022 23:23
Module file for auto importing material design icons in Nuxt.js
import { resolve } from 'path'
const icons = ['Phone', 'Alarm']
export default function () {
this.nuxt.hook('components:dirs', (dirs) => {
dirs.push({
path: resolve('node_modules/vue-material-design-icons'),
prefix: 'MaterialIcon',
pattern: `**/@(${icons.join('|')}).vue`,