Skip to content

Instantly share code, notes, and snippets.

View OmkarK45's full-sized avatar
💫
Trust the process

Omkar Kulkarni OmkarK45

💫
Trust the process
View GitHub Profile
@OmkarK45
OmkarK45 / App.js
Created April 11, 2021 15:54
This will show fancy progress bar on top of your apps :D
/*Here's how to use it*/
import FancyRoute from "./components/Route/Route"
export default function App(){
return (
<Router>
<FancyRoute path="/" component={Home}/>
</Router>
)
@OmkarK45
OmkarK45 / index.jsx
Created May 16, 2021 18:43
Fixed issue
export default function Home() {
return (
<div>
<div className="relative items-center justify-center">
<h1 className="p-4 text-2xl font-bold text-center text-gray-400 bg-gray-800">
Choose Your Next Adventure
</h1>
All
<div className="container items-center mx-auto my-auto lg:flex">
<div className="mx-8 my-12 bg-white rounded-lg shadow-md lg:m-4 hover:shadow-lg hover:bg-gray-100">
@OmkarK45
OmkarK45 / Component.tsx
Created August 14, 2021 14:53
Chakra UI
<Container maxW={'3xl'}>
<Stack
as={Box}
textAlign={'center'}
spacing={{ base: 8, md: 14 }}
py={{ base: 20, md: 36 }}>
<Heading
fontWeight={600}
fontSize={{ base: '2xl', sm: '4xl', md: '6xl' }}
lineHeight={'110%'}>
@OmkarK45
OmkarK45 / Feed.tsx
Created September 7, 2021 18:32
Infinite scrolling component
import { gql, useQuery } from '@apollo/client'
import InfiniteScroll from 'react-infinite-scroll-component'
import { FeedQuery, FeedQueryVariables } from './__generated__/index.generated'
const FEED_QUERY = gql`
query FeedQuery($first: Int, $after: ID) {
feed(first: $first, after: $after) {
edges {
cursor
import { Tab } from '@headlessui/react'
import clsx from 'clsx'
import React from 'react'
import { IconType } from 'react-icons/lib'
// Gist this
interface Navigation {
name: string
icon: IconType | React.ElementType
component: React.ReactNode
import { createContext, useContext, useEffect, useState } from 'react'
import { getUser, logout } from 'services/axios'
/**
* getUser() -> Helper function to fetch user information. (basically an axios call)
* logout() -> Helper function to logout users
*/
const AuthContext = createContext()
import clsx from 'clsx'
import React, { useCallback, useEffect } from 'react'
import { useDropzone } from 'react-dropzone'
import { useFormContext } from 'react-hook-form'
import { HiOutlinePhotograph } from 'react-icons/hi'
import { Alert } from '../Alert'
interface FileInputProps
extends React.DetailedHTMLProps<
React.InputHTMLAttributes<HTMLInputElement>,
@OmkarK45
OmkarK45 / db.ts
Created November 8, 2021 13:25
Connection to MongoDB
import mongoose from 'mongoose'
import log from '../utils/logger'
/**
* @description - This function creates connection to the database with given options.
* Resolves to connection with DB or Failure with an error message
* */
export const makeConnection = async () => {
await mongoose
.connect(
@OmkarK45
OmkarK45 / ValidationMiddleware.ts
Created November 8, 2021 13:27
Validate Incoming Body Against a yup schema
import { NextFunction, Request, Response } from 'express'
import { BaseSchema } from 'yup'
import { MixedSchema } from 'yup/lib/mixed'
/**
* This middleware checks the req.body against an yup schema provided in it
* @example
* ```
* validate(incomingRequestBody, incomingBodySchema)
*
@OmkarK45
OmkarK45 / AuthController.ts
Created November 8, 2021 13:29
Auth handler that handles new signups on the platform
export const signUpHandler: RequestHandler<{}, {}, SignUpBody> = async (
req,
res
) => {
const { firstName, lastName, email, password } = req.body
const isAlreadyRegistered = await User.findOne({
email,
})
if (isAlreadyRegistered) {