Skip to content

Instantly share code, notes, and snippets.

@jahend
jahend / principe.md
Created September 21, 2024 10:54
[UNIT TEST]

RedFlag GreenFlag Refactor

Déclaration Execution Verification

const Child = ({ name, onUpdate }: any) => {
const [optimisticName, setOptimisticName] = useOptimistic(name);
const [message, submitAction, isPending] = useActionState(
async(_: unknown, formData: FormData) => {
try {
setOptimisticName(formData.get("name") as string);
await updateName(formata.get("name") as string);
onUpdate();
@jahend
jahend / 00_variable.dart
Last active August 16, 2023 22:55
[Dart :: basics]
void main(){
int age = 17;
double prix = 19.99;
String nom = "Driss";
bool estMajeur = true;
print("Bonjour, je m'appelle $nom et j'ai $age ans");
if(estMajeur){
print("Je suis majeur !");
} else {
if([10,100,101,145,3,112,113].includes(X) === true){}
if(typeof val !== 'undefined'){}
@jahend
jahend / 00_useful_classes.md
Last active April 8, 2023 14:32
[CSS :: Tailwind / Tailwindcss] #css #tailwind #tailwindcss

text-2xl text-gray-100 flex flex-col gap-12 flex / flex-col / gap-12 ====== space-y-12

text-teal-700 text-opacity-50

@jahend
jahend / 0_package.json
Last active February 4, 2023 16:29
[Node :: basic app]
{
"name":"name of app",
"version": " 1.0.0",
"description": "some explicit description",
"main": "index.js",
"author": "Marko",
"private": true,
"devDependencies": {
"typescript": "^4.9.4"
}
@jahend
jahend / simple_form_formik.jsx
Created October 29, 2022 20:14
[React :: Formik] easy form with yup validation https://www.youtube.com/watch?v=oPteQFUK42w
import Head from "next/head";
import formImage from "../public/form.png";
import Image from "next/image";
import { useFormik } from "formik";
import * as Yup from "yup";
import { useRouter } from "next/router";
import { motion as m } from "framer-motion";
export default function Home() {
const router = useRouter();
@jahend
jahend / 0_config_firebase.js
Last active February 21, 2023 10:13
[React :: Firebase]
// src/config/firebase.js
// Import the functions you need from the SDKs you need
import { initializeApp } from "firebase/app";
import { getAnalytics } from "firebase/analytics";
// TODO: Add SDKs for Firebase products that you want to use
// https://firebase.google.com/docs/web/setup#available-libraries
// Your web app's Firebase configuration
@jahend
jahend / list.sh
Created March 27, 2022 12:23
[Regex] Plug n play
# Remove commas & space
res = str.replace(/[, ]+/g, " ").trim();
@jahend
jahend / app.js
Last active August 3, 2021 19:57
[Supertest :: Api testing]
let usersRouter = require('./routes/users');
let app = express();
app.use(logger('dev'));
app.use(express.json());
app.use(express.urlencoded({ extended: false }));
app.use(cookieParser());
app.use(express.static(path.join(__dirname, 'public')));