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 / 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)
@maxgfr
maxgfr / sitcky.html
Created February 17, 2022 20:16
Sticky footer using flexbox
<body>
<div class="content">
content
</div>
<footer class="footer"></footer>
</body>
@maxgfr
maxgfr / context.tsx
Last active February 17, 2022 11:35
Generic context react
import { ContextType, Result } from "./types";
import React, { Context, createContext } from "react";
export const Context =
createContext<ContextType<Result> | null>(null);
return (
<Context.Provider
value={{
result: {} as Result
@maxgfr
maxgfr / explicit.ts
Last active February 17, 2022 10:27
Type guard and type conversion in typescript
// https://www.typescriptlang.org/play?#code/C4TwDgpgBAglC8UDeBYAUFTUwCcD2YAjAFxQDOwOAlgHYDm6W2+YATKRdfY1rgQMwdKtBmgC+6dKEhQAQgigB5ALZVgAHhgAaKAHI+bXQD5JaadADCClWs079LfsdPmoADXUAVKBAAewCBoAEzJYKAAfOQioCyMFbz8A4NC4AH4w0gT-QJCo9PlSCwBuUwBjPBoKKCoyC1IPWIUkKB5MAxIoACIQPE6tVuYCdi6AdwgyAAs+9Ak0dHLK4GqyWXr1WTjEZoH20m7e-oxeRz2yAEMAGwBXYGnxMoqqmpg1mE3kFqO2lg79u6YDMNOmNJv9jgJTpcbncxEA
type A = {
prop1: string
prop2: string
prop3: string
}
type B = Omit<A, 'prop2'>