Skip to content

Instantly share code, notes, and snippets.

// Turn all HTML <a> elements into client side router links, no special framework-specific <Link> component necessary!
// Example using the Next.js App Router.
import { useRouter } from 'next/navigation';
import { useEffect } from 'react';
function useLinkHandler() {
let router = useRouter();
useEffect(() => {
let onClick = e => {
@gapurov
gapurov / migrateProps.ts
Created February 24, 2023 14:32
Functionality to migrate props
const transformObj = (obj, predicate) => {
return Object.keys(obj).reduce((acc, key) => {
if (predicate(obj[key], key)) {
acc[key] = obj[key];
}
return acc;
}, {});
};
type Topic = Record<string, string | number | boolean>;
@gapurov
gapurov / .__init.md
Created June 9, 2022 20:23 — forked from rickyalmeidadev/.__init.md
vite + react + @swc/jest
yarn create vite
@gapurov
gapurov / README.md
Created June 7, 2022 15:37 — forked from itsMapleLeaf/README.md
Typed remix helpers

Typed helpers for low-boilerplate type inference with Remix data.

  • I suffix them with *Typed so I don't accidentally import the core remix helpers.
  • This doesn't support regular Response objects to prevent accidentally using them with the typed helpers.
@gapurov
gapurov / pbcopy.txt
Created February 3, 2022 14:27
pbcopz
pbcopy < ~/.ssh/id_rsa.pub
# or
cat ~/.ssh/id_rsa.pub | pbcopy
@gapurov
gapurov / convert-font.sh
Created August 20, 2021 15:24
OTF to WOFF,WOFF2,TTF convertion cli
#!/usr/bin/env bash
# usage for multiple files
# for file in *.otf; do ./convert-font.sh "$file" .; done
set -e
SOURCE=$1
DESTINATION=$2
FILENAME=$(basename "${SOURCE%.otf}")
@gapurov
gapurov / createCrudHooks.js
Created April 3, 2021 18:58 — forked from tannerlinsley/createCrudHooks.js
A naive, but efficient starter to generate crud hooks for React Query
export default function createCrudHooks({
baseKey,
indexFn,
singleFn,
createFn,
updateFn,
deleteFn,
}) {
const useIndex = (config) => useQuery([baseKey], indexFn, config)
const useSingle = (id, config) =>
@gapurov
gapurov / readme.md
Created February 9, 2021 15:52 — forked from brauliodiez/readme.md
lodash/fp set and flow

lodash/fp - set / flow

In this gist we are going to learn about basic goodies that we get from the library lodash/fp (fp stands for functional programming, great for ensuring immutability).We'll learn just by doing (step by step guided sample + codepens).

We'll cover lodash set and flow functions

Steps

  • We'll use codepen as our playground, navigate to this page:
ssh-keygen
-t ed25519 - for greatest security (bits are a fixed size and -b flag will be ignored)
-t rsa - for greatest portability (key needs to be greater than 4096 bits)
-t ecdsa - faster than RSA or DSA (bits can only be 256, 284, or 521)
-t dsa - DEEMED INSECURE - DSA limted to 1024 bit key as specified by FIPS 186-2, No longer allowed by default in OpenSSH 7.0+
-t rsa1 - DEEMED INSECURE - has weaknesses and shouldn't be used (used in protocol 1)
-b 4096 bit size
-a 500 rounds (should be no smaller than 64, result in slower passphrase verification and increased resistance to brute-force password cracking)
-C "First.Last@somewhere.com" comment..
// this is a big array of 76 items I need to split into groups of 10
const hugeArray = Array.from({ length: 76 }, (_, i) => i);
function chunkify(array, chunkSize = 10) {
// make a new array
const chunks = Array.from(
// give it however many slots are needed - in our case 8
// 1-7 with 10 items, and 8th slot will have 6
{ length: Math.ceil(array.length / chunkSize) },
// this is a map function that will fill up our slots