Skip to content

Instantly share code, notes, and snippets.

View jomifepe's full-sized avatar
:shipit:

José Pereira jomifepe

:shipit:
View GitHub Profile
@jomifepe
jomifepe / _document.tsx
Last active June 7, 2022 14:02
document
/* eslint-disable max-len */
import Document, {
DocumentContext,
DocumentInitialProps,
Head,
Html,
Main,
NextScript,
} from 'next/document';
import React from 'react';
@jomifepe
jomifepe / useLocaleUpdates.ts
Last active June 8, 2022 10:17
useLocaleUpdates
import { useEffect, useState } from 'react';
import cookie from 'cookie';
import { useRouter } from 'next/router';
import { useTranslation } from 'react-i18next';
import usePrevious from './usePrevious';
import { LocaleDirection } from 'models/types';
import { getLocaleFromUrl, setLocaleCookie, updateLocale } from 'utils/locales';
import { COOKIE_LOCALE_KEY } from 'constants/cookies';
import { DEFAULT_LOCALE, LOCALES } from 'constants/locales';
/**
@jomifepe
jomifepe / convertInterfacesToTypes.ts
Last active October 23, 2024 13:52
Converts interfaces to types
import { parseArgs } from "https://deno.land/std@0.224.0/cli/parse_args.ts";
import { join } from "https://deno.land/std@0.224.0/path/mod.ts";
const { debug } = parseArgs(Deno.args, { boolean: ["debug"], default: { "debug": false } });
const interfaceRegex = /interface\s+(\w+)(\s+extends\s+([\w, ]+))?\s*{([^}]*)}/g;
let convertedFiles = 0
function isIncludedDir(filePath: string) {
return ["configs", "packages", "scripts"].find((dir) => filePath.startsWith(Deno.realPathSync(dir)))
}