Skip to content

Instantly share code, notes, and snippets.

View ryands17's full-sized avatar
:electron:
In love with TS & Rust

Ryan Dsouza ryands17

:electron:
In love with TS & Rust
View GitHub Profile
@ryands17
ryands17 / useForm.ts
Created March 5, 2023 19:03 — forked from danieljpgo/useForm.ts
react-hook-form + zod
import {
useForm as useHookForm,
UseFormProps as useHookFormProps,
} from "react-hook-form";
import { zodResolver } from "@hookform/resolvers/zod";
import { TypeOf, ZodSchema } from "zod";
interface UseFormProps<Z extends ZodSchema>
extends Exclude<useHookFormProps<TypeOf<Z>>, "resolver"> {
schema: Z;
@ryands17
ryands17 / tut.md
Last active September 13, 2021 19:39 — forked from ikouchiha47/tut.md
Implementing a peer to peer chat prototype in nodejs.

prologue

Why another tutorial? Because there are other tutorials which write a server - client or maybe a client client where they have only two clients, maybe by hardcoding ips.

<rant>
  What annoys me more is, that there are 100's of same tutroials on the internet, 
 that just works for a given scenario, but guess what, I don't fucking care what works
// Future versions of Hyper may add additional config options,
// which will not automatically be merged into this file.
// See https://hyper.is#cfg for all currently supported options.
module.exports = {
config: {
// choose either `'stable'` for receiving highly polished,
// or `'canary'` for less polished but more frequent updates
updateChannel: 'stable',
const memoize = fn => (...args) => {
fn.cache = fn.cache || {}
return fn.cache[args] ? fn.cache[args] : (fn.cache[args] = fn.apply(this,args))
}
const memoizedFunction = memoize(funtionToMemoize)
memoizedFunction(args)
const compose = (...fns) => x => fns.reduceRight((y, f) => f(y), x)