Skip to content

Instantly share code, notes, and snippets.

View maxgfr's full-sized avatar
🎯
Focusing

Maxime Golfier maxgfr

🎯
Focusing
View GitHub Profile
@maxgfr
maxgfr / MultiSingletonHelper.ts
Created June 30, 2023 10:46
A Singleton with multiple instance which returns the good instance
class MultiSingletonHelper {
private static readonly instances: MultiSingletonHelper[] = [];
private readonly param1: string;
private readonly param2?: string;
private constructor(param1: string, param2?: string) {
this.param1 = param1;
this.param2 = param2;
@maxgfr
maxgfr / .eslintrc.js
Last active June 21, 2023 15:09
React Typescript Storybook Prettier TestingLibrary Cypress eslint config
module.exports = {
root: true,
extends: [
'eslint:recommended',
'plugin:react/recommended',
'plugin:react-hooks/recommended',
'plugin:react/jsx-runtime',
'plugin:storybook/recommended',
'plugin:import/recommended',
'plugin:jsx-a11y/recommended',
@maxgfr
maxgfr / update_upgrade_ubuntu.md
Last active June 29, 2023 11:24
Ultimate Command For A System Update and Maintenance Command for Ubuntu/Linux

Update and upgrade an ubuntu

sudo apt update && sudo apt upgrade && sudo apt full-upgrade && sudo apt dist-upgrade && sudo apt-get check && sudo apt -f install && sudo apt -y clean && sudo apt -y autoclean && sudo apt autoremove && sudo dpkg --configure -a && sudo apt --fix-broken install && sudo do-release-upgrade
@maxgfr
maxgfr / merge_pdf.md
Created May 28, 2023 09:57
Mege pdf by using cli

Merge pdf together

By using qpdf

qpdf --empty --pages *.pdf -- out.pdf
@maxgfr
maxgfr / zod_env.ts
Created April 18, 2023 13:30
Example of env file with zod validation (S/O to Matt Pocok : https://www.youtube.com/watch?v=q1im-hMlKhM)
import { z } from "zod";
const envVariables = z.object({
DATABASE_URL: z.string(),
CUSTOM_STUFF: z.string(),
});
export const ENV = envVariables.parse(process.env);
declare global {
@maxgfr
maxgfr / prompts.md
Last active March 31, 2023 11:04
Prompt ChatGPT

Prompts that could be useful

  1. Identify the 20% of [topic or skill] that will yield 80% of the desired results and provide a focused learning plan to master it.
  2. Explain [topic or skill] in the simplest terms possible as if teaching it to a complete beginner. Identify gaps in my understanding and suggest resources to fill them.
  3. Create a study plan that mixes different topics or skills within [subject area] to help me develop a more robust understanding and facilitate connections between them.
  4. Design a spaced repetition schedule for me to effectively review [topic or skill] over time, ensuring better retention and recall.
  5. Help me create mental models or analogies to better understand and remember key concepts in [topic or skill]."
  6. Suggest various learning resources (e.g., videos, books, podcasts, interactive exercises) for [topic or skill] that cater to different learning styles.
  7. Provide me with a series of challenging questions or problems related to [topic or skill] to test my understan
export async function createUser() {
const {user, error} = await api.createUser();
if(error) {
throw new UserError({
name: "CREATE_USER_ERROR",
message: "Failed to create user",
cause: error
})
@maxgfr
maxgfr / watchman_error.md
Last active December 2, 2022 20:17
Watchman error on react native

Watchman error

If you have an error with watchman, you can reset it by running this command

watchman watch-del-all
watchman shutdown-server
@maxgfr
maxgfr / name_decorator.ts
Created October 6, 2022 13:08
Name decorator
export const nameKey = Symbol("name");
/**
* To perserve class name though mangling.
* @example
* @name('Customer')
* class Customer {}
* @param className
*/
export function name(className: string): ClassDecorator {
@maxgfr
maxgfr / getDirname.js
Last active April 26, 2022 15:37
__dirname for es module
import { fileURLToPath } from 'url';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
console.log(__dirname)