Skip to content

Instantly share code, notes, and snippets.

View zeyadsleem's full-sized avatar
🎯
Focusing

zeyad sleem zeyadsleem

🎯
Focusing
View GitHub Profile
@zeyadsleem
zeyadsleem / 00-README-NEXT-SPA.md
Created October 12, 2024 22:16 — forked from gaearon/00-README-NEXT-SPA.md
Next.js SPA example with dynamic client-only routing and static hosting

Next.js client-only SPA example

Made this example to show how to use Next.js router for a 100% SPA (no JS server) app.

You use Next.js router like normally, but don't define getStaticProps and such. Instead you do client-only fetching with swr, react-query, or similar methods.

You can generate HTML fallback for the page if there's something meaningful to show before you "know" the params. (Remember, HTML is static, so it can't respond to dynamic query. But it can be different per route.)

Don't like Next? Here's how to do the same in Gatsby.

@zeyadsleem
zeyadsleem / 100-doors.py
Created March 17, 2024 12:45
100 doors problem with python
# There are 100 doors in a row that are all initially closed.
#
# You make 100 passes by the doors.
#
# The first time through, you visit every door and toggle its state (if the door is closed, you open it; if it is open, you close it).
#
# The second time, you only visit every 2nd door (door #2, #4, #6, …), and toggle it.
#
# The third time, you visit every 3rd door (door #3, #6, #9, …).
#