Skip to content

Instantly share code, notes, and snippets.

View khalidx's full-sized avatar
💭
Engineering for the ☁️

Khalid Zoabi khalidx

💭
Engineering for the ☁️
View GitHub Profile
@khalidx
khalidx / co-founder-matching.md
Created May 17, 2024 19:30
A template to use when meeting with a potential co-founder.

This is a general guideline for your first meeting with a potential co-founder.

Just replace any {variable} with information about you, your guest, or your startup.

Co-Founder Matching Template

Intro Call

Co-Founder Matching Call with {Guest} on {Date}

@khalidx
khalidx / nextjs-nested-matcher.md
Last active April 22, 2024 18:36
Match nested page routes in Next.js middleware.

Description

Next.js doesn't seem to protect routes that use getServerSideProps().

How can you protect endpoints like:

/_next/data/*/*/something.json

Is this a bug? You can get 50% of the way there with middleware, but the middleware doesn't run on /_next/data/ unless you configure it to.

@khalidx
khalidx / npm-script-globstar.md
Last active April 22, 2024 20:12
Fixing the issue with globstar paths (**/*) not working when running an npm script.

🚧 Issue Description

If you've ever run a script like npm run test from your package.json:

{
  "scripts": {
    "test": "node --test src/**/*.test.js"
  }
}
@khalidx
khalidx / new-golang-cli.md
Created November 29, 2023 07:05
Creating a new Go CLI application.

Replace <FirstName>, <LastName>, and <Email> with your information.

mkdir ./cli/ && cd ./cli/
go install github.com/spf13/cobra-cli@latest
cobra-cli init --author "<FirstName> <LastName> <Email>" --license MIT --viper
go mod tidy
@khalidx
khalidx / startup-success.md
Last active February 6, 2024 11:48
A distilled summary of Sam Altman's "How to Succeed with a Startup".

Sam Altman - How to Succeed with a Startup

Watch the full Y Combinator talk on YouTube from Aug 29, 2018 here: https://youtu.be/0lJKucu6HJc

Summary

  1. Build a product so good, people spontaneously tell their friends about it.
  2. Build a product that is easy to explain in a few words.
  3. Identify a market that is going to grow every year.
  4. A real trend is one where the early adopters use it obsessively.
@khalidx
khalidx / node-typescript-esm.md
Last active November 14, 2024 08:26
A Node + TypeScript + ts-node + ESM experience that works.

The experience of using Node.JS with TypeScript, ts-node, and ESM is horrible.

There are countless guides of how to integrate them, but none of them seem to work.

Here's what worked for me.

Just add the following files and run npm run dev. You'll be good to go!

package.json

@khalidx
khalidx / fix-mac-chrome-no-clicks.md
Last active October 31, 2023 21:03
A (possible) fix for not being able to click around a webpage in Chrome on macOS.

Issue Description

After upgrading my MacBook Air M1 to macOS Sonoma 14.0 (not sure if it is related to this issue), I noticed that I often cannot click anything inside a webpage in Chrome, even though I can scroll the page.

Also, sometimes the navigation buttons don't work either.

Resolution Steps

It appears that this fix may have resolved the issue. The inspiration for this fix came from the following Apple community discussion thread:

@khalidx
khalidx / bash-reusable.md
Created October 2, 2023 22:12
Reusable bash functions.

Include the code below in any bash script!

This is a good way to start a bash script:

#!/usr/bin/env bash
set -eou pipefail

These are some useful generic reusable bash functions.

@khalidx
khalidx / validate-package-json.md
Last active October 2, 2023 09:08
Validate fields from a package.json file.

You could use this code to, for example, validate fields from a package.json file for use in a Node.js CLI application.

It gives you a packageInfo object that has some useful fields that you could use (in a help or usage message, for example):

  • packageInfo.version, so that you can display the CLI version
  • packageInfo.bin, so that you can display the name of the CLI command
  • packageInfo.repository, so that you can display a URL to the repo for the CLI

Make sure your tsconfig.json includes "resolveJsonModule": true.

@khalidx
khalidx / redis-configuration.md
Created September 25, 2023 05:29
Redis configuration settings.

Here are some configuration settings for setting up Redis.

This should go in your docker-compose.yaml:

redis:
    image: redis/redis-stack-server:7.2.0-v2
    restart: always
    volumes:
 - redis-data:/data