Skip to content

Instantly share code, notes, and snippets.

View rawnly's full-sized avatar
🧨
fixing my printer

Federico rawnly

🧨
fixing my printer
View GitHub Profile
import { useCalendar } from '@h6s/calendar';
import { useMachine } from '@xstate/react';
import { Button as AriaButton } from 'ariakit/button';
import clsx from 'clsx';
import { isSunday, isSameDay, addMonths, isFuture, isPast, setDate } from 'date-fns';
import format from 'date-fns/format';
import isWithinInterval from 'date-fns/isWithinInterval';
import { FC, useCallback, useMemo } from 'react';
import Select from '@components/forms/components/Select';
type IO<T, Input = never> = Input extends never ? () => T : (input: Input) => T;
export type InputType = 'text' | 'number' | 'password' | 'email' | 'date' | 'time' | 'datetime-local' | 'month' | 'week' | 'url' | 'search' | 'tel' | 'color';
export type BaseInput<Shape extends object, Metadata = Record<string, any>> = {
placeholder?: string;
required?: string | boolean;
disabled?: string | boolean;
readonly?: string | boolean;
autofocus?: string | boolean;
{
"PolymorphicFunctionComponent": {
"prefix": "fncpp",
"description": "React Function Component (Polymorphic)",
"body": [
"import React from \"react\";",
"",
"interface PolymorphicProps<C extends React.ElementType> {",
"\tas?: C",
"}",
@rawnly
rawnly / html-link-to-remix.ts
Created June 8, 2022 18:41
HTML Links to Remix like format.
import { of, mergeMap, timer, concat } from 'rxjs'
import { useObservableState } from 'observable-hooks'
import { PropsWithChildren } from 'react'
// or whatever component you'd like to use
import { Button } from 'ariakit/button'
interface AutoResetButtonProps {
confirmText: string
timeout?: number
export class Numbers {
#data: number[];
#max = 0;
addNumber(num: number) {
this.#max = Math.max(num, this.#max);
this.#data.push(num);
}
getAll(): number[] {
import * as RD from '@devexperts/remote-data-ts';
import * as E from 'fp-ts/Either';
import { flow, Lazy, pipe } from 'fp-ts/lib/function';
import * as T from 'fp-ts/Task';
import * as TE from 'fp-ts/TaskEither';
import Task = T.Task;
import Either = E.Either;
import TaskEither = TE.TaskEither;
import RemoteData = RD.RemoteData;

Example Usage

Warn! Text encoding for urls has not been implemented.

package main

import "fmt"

type Parrams struct {
@rawnly
rawnly / HTTPError.ts
Created March 27, 2022 16:50
An easy way to handle multiple request methods in NextJS Api
import type { NextApiResponse } from 'next/types'
export default class HTTPError extends Error {
status: number
_tag: 'HTTPError' = 'HTTPError' as const
constructor( status: number, message: string ) {
super( message )
this.status = status
}
// for custom model validation (inspired by ZOD)
type StringType = {
_type: 'STRING'
}
type DateType = {
_type: 'DATE'
}