Skip to content

Instantly share code, notes, and snippets.

View pom421's full-sized avatar
🦊
Yes, What's happening?

Pierre-Olivier Mauguet pom421

🦊
Yes, What's happening?
View GitHub Profile
/*https://dev.to/gajus/my-favorite-css-hack-32g3*/
* { background-color: rgba(255,0,0,.2); }
* * { background-color: rgba(0,255,0,.2); }
* * * { background-color: rgba(0,0,255,.2); }
* * * * { background-color: rgba(255,0,255,.2); }
* * * * * { background-color: rgba(0,255,255,.2); }
* * * * * * { background-color: rgba(255,255,0,.2); }
* * * * * * * { background-color: rgba(255,0,0,.2); }
* * * * * * * * { background-color: rgba(0,255,0,.2); }
function undefined() {
// problem solved
}
From: https://dmitripavlutin.com/7-tips-to-handle-undefined-in-javascript/
#js #undefinedNullHell
@pom421
pom421 / ESLint + Prettier + VSCode.md
Last active December 19, 2020 18:03
Get instant VSCode configured with ESLint, Prettier following AirBnB ESLint's rules
# Create a user named ozon, for example
create user ozon with encrypted password 'ozon';
# Create a database (see LC_CTYPE and LC_COLLATE if needed)
create database ozon with owner ozon encoding 'UTF8';
@pom421
pom421 / auth.js
Created May 22, 2020 10:32
Hook for replacement of HOC for authentication
//https://codesandbox.io/s/quirky-hermann-1xzju?file=/src/App.js
import React, { useState, useEffect } from "react";
import "./styles.css";
const useAuth = Component => {
const [isAuthed, setAuth] = useState(false);
useEffect(() => {
setTimeout(() => {
setAuth(true);
@pom421
pom421 / form-next-ts-rhf-zod-demo.tsx
Last active December 22, 2023 16:28
Form with React Hook form and zod rules (Next.js page example)
// try it : https://codesandbox.io/s/sample-next-ts-rhf-zod-9ieev
import React from "react";
import { useForm } from "react-hook-form";
import { zodResolver } from "@hookform/resolvers/zod";
import { z } from "zod";
import type { FieldError } from "react-hook-form";
// JSON.stringify(error) will not work, because of circulare structure. So we need this helper.
@pom421
pom421 / Next + TS + ESLint + Prettier + VSCode.md
Last active February 28, 2022 13:03
Step by step project with ESLint, TS, Prettier, Jest

Create a Next.js TS project

mkdir new-project && yarn create next-app --typescript

For an already Next project

touch tsconfig.json
@pom421
pom421 / JS + Next + ESLint + Prettier + VSCode.md
Last active March 8, 2023 23:41
JS + Next + ESLint + Prettier + VSCode

Quick procedure to have ESLint + Prettier + automatic VSCode lint in a Next JS app.

Next.js

yarn create next-app

Next.js comes with an ESlint.

@pom421
pom421 / App.tsx
Last active November 22, 2022 23:53
Custom SWRConfig
import { SWRConfig } from "swr";
import { fetcher } from "@services/apiClient";
// Your fetcher need to throw error with an statusCode.
const MyApp = () => {
return (
<SWRConfig
value={{
@pom421
pom421 / README.md
Last active November 23, 2022 21:03
Make that saving file in VS code triggers the return in Vim normal mode

Nota bene

You have to install the multi-command extension in VS Code, because VS Code doesn't handle internally to trigger multiple commands.