Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View brenopolanski's full-sized avatar
🦙
Llama Llama

Breno Polanski brenopolanski

🦙
Llama Llama
View GitHub Profile
@mjbalcueva
mjbalcueva / password-input.tsx
Last active April 22, 2024 21:53
shadcn ui custom password input
"use client"
import { forwardRef, useState } from "react"
import { EyeIcon, EyeOffIcon } from "lucide-react"
import { Button } from "@/components/ui/button"
import { Input, InputProps } from "@/components/ui/input"
import { cn } from "@/lib/utils"
const PasswordInput = forwardRef<HTMLInputElement, InputProps>(
({ className, ...props }, ref) => {
@Sqvall
Sqvall / file-upload.tsx
Last active June 11, 2023 05:35
File Upload with Chakra UI and react-hook-form
import { ReactNode, useRef } from 'react'
import { Button, FormControl, FormErrorMessage, FormLabel, Icon, InputGroup } from '@chakra-ui/react'
import { useForm, UseFormRegisterReturn } from 'react-hook-form'
import { FiFile } from 'react-icons/fi'
type FileUploadProps = {
register: UseFormRegisterReturn
accept?: string
multiple?: boolean
children?: ReactNode
@brenopolanski
brenopolanski / README.md
Created January 11, 2021 12:34
DPKG error while installation bcmwl-kernel-source on ubuntu 20.04
@alieslamifard
alieslamifard / withPrivateRoute.jsx
Last active May 31, 2023 20:10
Private route HOC for Next.js
import React from 'react';
import Router from 'next/router';
const login = '/login?redirected=true'; // Define your login route address.
/**
* Check user authentication and authorization
* It depends on you and your auth service provider.
* @returns {{auth: null}}
*/
@gaearon
gaearon / uselayouteffect-ssr.md
Last active April 15, 2024 10:06
useLayoutEffect and server rendering

If you use server rendering, keep in mind that neither useLayoutEffect nor useEffect can run until the JavaScript is downloaded.

You might see a warning if you try to useLayoutEffect on the server. Here's two common ways to fix it.

Option 1: Convert to useEffect

If this effect isn't important for first render (i.e. if the UI still looks valid before it runs), then useEffect instead.

function MyComponent() {
@morajabi
morajabi / useRect.js
Created February 18, 2019 14:35
useRect — getBoundingClientRect() React Hook with resize handler
import { useLayoutEffect, useCallback, useState } from 'react'
export const useRect = (ref) => {
const [rect, setRect] = useState(getRect(ref ? ref.current : null))
const handleResize = useCallback(() => {
if (!ref.current) {
return
}
@trevorgreenleaf
trevorgreenleaf / px-rem-tw.csv
Last active April 1, 2024 15:42
PX to REM'S to TAILWIND CSS
PX REM TW
4 0.25 1
8 0.5 2
16 1 4
32 2 8
48 3 12
64 4 16
80 5 20
96 6 24
112 7 28
@ibrahimtuzlak0295
ibrahimtuzlak0295 / xampp-virtualhost.md
Last active May 24, 2023 16:21
Create virtual host in XAMPP, Ubuntu 16.04/18.04/20.04/22.04

I’ll go step-by-step on how to create a virtual host in the XAMPP environment. As we know, the default http://localhost points to /opt/lampp/htdocs as the root directory. The desired result is to be able to visit http://examplevhost.local, with the root directory being /opt/lampp/htdocs/examplevhost.

Note: The steps below are done on Ubuntu 16.04, but they should also work on most other Linux distributions (Debian, Mint, Arch).

Note: I’ll assume that XAMPP is installed in /opt/lampp/. If it’s different on your setup, please read carefully and adjust accordingly.

Enable virtual hosts in apache configuration file

Note: This should be done only once per XAMPP installation. If you want to add another virtual host later you can skip to the next step.

@soulmachine
soulmachine / jwt-expiration.md
Last active April 9, 2024 04:12
How to deal with JWT expiration?

First of all, please note that token expiration and revoking are two different things.

  1. Expiration only happens for web apps, not for native mobile apps, because native apps never expire.
  2. Revoking only happens when (1) uses click the logout button on the website or native Apps;(2) users reset their passwords; (3) users revoke their tokens explicitly in the administration panel.

1. How to hadle JWT expiration

A JWT token that never expires is dangerous if the token is stolen then someone can always access the user's data.

Quoted from JWT RFC:

@joshbuchea
joshbuchea / semantic-commit-messages.md
Last active April 23, 2024 11:19
Semantic Commit Messages

Semantic Commit Messages

See how a minor change to your commit message style can make you a better programmer.

Format: <type>(<scope>): <subject>

<scope> is optional

Example