Skip to content

Instantly share code, notes, and snippets.

View krinoid's full-sized avatar
🛰️

krinoid krinoid

🛰️
View GitHub Profile
@ilkou
ilkou / shadcn-ui react-select.jsx
Created March 26, 2024 13:54
react-select with shadcn/ui
/* ----------- simple-select.js ----------- */
import * as React from 'react';
import Select from 'react-select';
import type { Props } from 'react-select';
import { defaultClassNames, defaultStyles } from './helper';
import {
ClearIndicator,
DropdownIndicator,
MultiValueRemove,
Option
@mjbalcueva
mjbalcueva / password-input.tsx
Last active November 16, 2024 11:15
shadcn ui custom password input
'use client'
import * as React from 'react'
import { EyeIcon, EyeOffIcon } from 'lucide-react'
import { Button } from '@/components/ui/button'
import { Input, type InputProps } from '@/components/ui/input'
import { cn } from '@/lib/utils'
const PasswordInput = React.forwardRef<HTMLInputElement, InputProps>(({ className, ...props }, ref) => {
@booya2nd
booya2nd / mock-esmodule.js
Last active September 28, 2023 12:50
mockESModule workaround for JEST 29.x
import * as path from 'path';
import * as url from 'url';
function forEachDeep(obj, cb, options = { depth: 6 }) {
(function walk(value, property = undefined, parent = null, objPath = []) {
return value && typeof value === 'object' && objPath.length <= options.depth
? Object.entries(value).forEach(([key, val]) =>
walk(val, key, value, [...objPath, key])
)
: cb([property, value], parent, objPath);
@sindresorhus
sindresorhus / esm-package.md
Last active November 17, 2024 22:07
Pure ESM package

Pure ESM package

The package that linked you here is now pure ESM. It cannot be require()'d from CommonJS.

This means you have the following choices:

  1. Use ESM yourself. (preferred)
    Use import foo from 'foo' instead of const foo = require('foo') to import the package. You also need to put "type": "module" in your package.json and more. Follow the below guide.
  2. If the package is used in an async context, you could use await import(…) from CommonJS instead of require(…).
  3. Stay on the existing version of the package until you can move to ESM.
@brentjanderson
brentjanderson / Procfile
Last active May 23, 2024 19:33
Running RedwoodJS on Heroku
release: yarn rw prisma migrate deploy
web: bin/start-nginx node index.js
🚶‍♂️ 230km ██████▌░░░░░░░░░░░░░
🏂 191km █████▍░░░░░░░░░░░░░░
‍🏃‍♂️ 184km █████▏░░░░░░░░░░░░░░
🚴‍♂️ 62km █▊░░░░░░░░░░░░░░░░░░
🥾 19km ▍░░░░░░░░░░░░░░░░░░░
684km total
@ruizb
ruizb / advanced-example.md
Last active September 26, 2023 20:21
Reader monad example using fp-ts

The following section is not part of monet.js documentation, but I think it's worth showing how we can compose readers using fp-ts.

Reader composition

Let's say we have the following piece of code:

interface Dependencies {
  logger: { log: (message: string) => void }
 env: 'development' | 'production'
@mfellner
mfellner / graphql.ts
Created July 8, 2019 20:42
Using Apollo Server in Next.js 9 with API route in pages/api/graphql.ts
import { ApolloServer, gql } from 'apollo-server-micro';
const typeDefs = gql`
type Query {
sayHello: String
}
`;
const resolvers = {
Query: {
import React, { Suspense, useState } from "react";
import { unstable_createResource as createResource } from "react-cache";
import {
Combobox,
ComboboxInput,
ComboboxList,
ComboboxOption
} from "./Combobox2.js";
function App({ tabIndex, navigate }) {