Skip to content

Instantly share code, notes, and snippets.

View mistical2008's full-sized avatar

Evgeniy Talko mistical2008

  • Russia
View GitHub Profile
import React from "react";
import { Link } from "react-router-dom";
export function createResource(getPromise) {
let cache = {};
let inflight = {};
let errors = {};
function load(key) {
inflight[key] = getPromise(key)
@mistical2008
mistical2008 / scroll-restoration.tsx
Created December 9, 2021 13:41 — forked from kentcdodds/scroll-restoration.tsx
scroll-restoration.tsx
import * as React from 'react'
import {useLocation} from 'react-router-dom'
import {useTransition} from '@remix-run/react'
import {useBeforeUnload} from 'remix'
import {useSSRLayoutEffect} from './misc'
let firstRender = true
let positions: {[key: string]: number} = {}
const SESSION_STORAGE_KEY = 'kody_scroll_positions'
@mistical2008
mistical2008 / cell.tsx
Created December 9, 2021 13:42 — forked from kentcdodds/cell.tsx
A real-world example of the prop getters pattern
function Cell({
value,
row: {values: user},
column: {id: propertyName},
}: {
value: string
row: {values: User}
column: {id: string}
}) {
@mistical2008
mistical2008 / session.server.ts
Created December 9, 2021 13:42 — forked from kentcdodds/session.server.ts
Authentication in Remix applications
import * as bcrypt from "bcrypt";
import { createCookieSessionStorage, redirect } from "remix";
import { db } from "./db.server";
export type LoginForm = {
username: string;
password: string;
};
@mistical2008
mistical2008 / cachified.ts
Created December 9, 2021 13:43 — forked from kentcdodds/cachified.ts
Turn any function into a cachified one. With forceFresh support and value checking (for when the data type changes). This uses redis, but you could change it to use whatever you want.
type CacheMetadata = {
createdTime: number
maxAge: number | null
expires: number | null
}
function shouldRefresh(metadata: CacheMetadata) {
if (metadata.maxAge) {
return Date.now() > metadata.createdTime + metadata.maxAge
}
@mistical2008
mistical2008 / .__init.md
Created February 19, 2022 10:18 — forked from rickyalmeidadev/.__init.md
vite + react + @swc/jest
yarn create vite
@mistical2008
mistical2008 / .eslintignore
Created February 21, 2022 10:01 — forked from RyanHirsch/.eslintignore
Typescript + Jest + ESLint + Tailwind
.next
__generated__
@mistical2008
mistical2008 / .eslintrc.js
Created February 21, 2022 10:14 — forked from Tim-W-James/.eslintrc.js
TypeScript w/ FP: ESLint
module.exports = {
parser: "@typescript-eslint/parser",
parserOptions: {
project: "./tsconfig.json",
ecmaVersion: 2018,
sourceType: "module",
},
extends: [
"typed-fp",
"plugin:sonarjs/recommended",
@mistical2008
mistical2008 / init-ts-package.sh
Created February 21, 2022 10:17 — forked from mcasimir/init-ts-package.sh
init-ts-package.sh
#!/usr/bin/env bash
generate_file() {
if [ ! -f "$1" ]; then
echo "$2" > "$1"
fi
}
# ---
# package.json
@mistical2008
mistical2008 / install.md
Created March 12, 2022 18:56 — forked from AndersonIncorp/install.md
Install any linux distro on VPS with low RAM, locked ISO boot

Overview

Scenario

  • Your VPS provider doesn't support ISO mount
  • Your VPS has low RAM and cannot load whole ISO image
  • Your current /boot is to small to contain ISO file

Workaround

  • Boot low memory ISO (CorePure64.iso ~ 14MB)
  • Create new partition ~1GB / size of your ISO
  • dd your ISO into that partition