Skip to content

Instantly share code, notes, and snippets.

Avatar
😺

Fatih Solhan fatihsolhan

😺
View GitHub Profile
@fatihsolhan
fatihsolhan / promise-based-memoization.ts
Last active Apr 12, 2022
Promise based memoization with a given cache size behaving as an LRU cache with an expiry time
View promise-based-memoization.ts
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;
View FilteredRelationship.tsx
/** @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 {
View FilteredRelationshipSelect.tsx
/** @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 Jan 14, 2022
Module file for auto importing material design icons in Nuxt.js
View material-design-icons.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`,