Skip to content

Instantly share code, notes, and snippets.

View sand97's full-sized avatar

Bruce Guenkam sand97

View GitHub Profile
@sand97
sand97 / _app.js
Last active September 27, 2022 10:12
Example of Nextjs Splash screen _app.js
function MyApp({ Component, pageProps }) {
// Hide splash screen shen we are server side
useEffect(() => {
if (typeof window !== 'undefined') {
const loader = document.getElementById('globalLoader');
if (loader)
loader.style.display = 'none';
}
}, []);
@sand97
sand97 / _document.js
Last active July 11, 2022 07:45
Example of Nextjs Splash screen _document.js
import React from 'react'
import Document, {Html, Head, Main, NextScript} from 'next/document'
import loader from "../src/loader";
class MyDocument extends Document {
render() {
return (
<Html>
<Head/>
<head>
@sand97
sand97 / loader.js
Last active July 11, 2022 08:15
Example of css export for Nextjs splash screen
export default `
body{
display: block;
}
#globalLoader{
position: fixed;
z-index: 1700;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
@sand97
sand97 / .env
Created January 20, 2022 13:37
NestJS env file
SERVER_PORT=3000
DB_PASSWORD=my-custom-password
DB_USERNAME=first-project-user
DB_DATABASE_NAME=first-project-db
POSTGRES_HOST=postgres
POSTGRES_PORT=5432
PORT=3000
MODE=DEV
#For prisma. Make sure that de pgsql service name, the db name, user
@sand97
sand97 / nest_docker_compose.yml
Created January 20, 2022 13:36
Nest docker_compose
version: '3.7'
services:
main:
container_name: main
build:
context: .
target: development
volumes:
- .:/usr/src/app
@sand97
sand97 / Dockerfile
Last active January 20, 2022 13:35
NestJS DockerFile
FROM node:12.13-alpine As development
WORKDIR /usr/src/app
COPY package*.json ./
RUN npm install
COPY . .
@sand97
sand97 / url.js
Last active January 10, 2022 16:47
state inside urls
import {useRouter} from "next/router";
//...
const router = useRouter();
const {router_steep} = router.query
const steep = (isNaN(+router_steep) || +router_steep < 0) ? 0
: +router_steep;
@sand97
sand97 / state_up.js
Last active January 10, 2022 16:49
Handle state up example
//inside the parent of carousel Dialog
const [dialogOpen, setDialogOpen] = useState<number>(0);
//inside a carousel Dialog
const [steep, setSteep] = useState<number>(0);
@sand97
sand97 / usestate.js
Created January 10, 2022 16:08
useState example
//...
const [steep, setSteep] = useState<number>(0);
//...
@sand97
sand97 / use_effect_refirect.js
Created January 7, 2022 08:40
Next redirection on client side
//...
const {name} = router.query;
React.useEffect(() => {
router.replace(`/products/${name}`);
})
//...