Skip to content

Instantly share code, notes, and snippets.

View MuhammadQuran17's full-sized avatar

Muhammad Umar MuhammadQuran17

  • DanAds
View GitHub Profile
@MuhammadQuran17
MuhammadQuran17 / repository_strategy_xmsi.md
Last active November 1, 2025 18:23
Repository and Strategy Patterns

Author: GPT-4o

In Laravel, Service Pattern and Repository Pattern are two common design patterns used to structure the business logic and data layer. Each pattern has its purpose and responsibilities, and they can even complement each other.

1. Service Pattern

The Service Pattern is used to encapsulate business logic, making it reusable and independent of the controller or other layers. This is where you place the "what needs to be done" logic, such as calculations, complex workflows, or coordination of multiple repositories or APIs.

Key Characteristics:

  • Focuses on business logic.
  • Keeps controllers thin by moving complex logic out.
@MuhammadQuran17
MuhammadQuran17 / debounce_xmsi.md
Created January 1, 2025 15:06
debounce for API limits

Debounce

Author: GPT-4o

Lodash's debounce function is used to limit how often a function is executed over time, even if it's called frequently. It's particularly helpful when you want to avoid unnecessarily calling a function multiple times in quick succession. This is especially useful for improving performance and user experience.

Example Scenario: Searching While Typing

Imagine you have a search bar where users type a query, and for each keystroke, a search request is sent to a server. If a user types "hello," five separate requests would be sent: one for "h," another for "he," then "hel," "hell," and "hello." This can overload the server and create lag.

Author: Gemini

Think of it like this:

Imagine building a Lego car. You have all the different bricks and pieces put together to form the car. Serialization is like taking that Lego car apart and putting all the bricks into a box. You can then ship that box to someone else, and they can use the instructions (the serialization format) to rebuild the exact same car from the bricks.

Common uses of serialization

Saving objects to files: You can serialize objects and save them to files on your hard drive, allowing you to load them back into your program later. Sending objects over a network: Serialization is essential for sending objects between different computers or applications, such as in web services or distributed systems.

@MuhammadQuran17
MuhammadQuran17 / vue.md
Last active December 3, 2025 05:15
Vue cheatsheet
@MuhammadQuran17
MuhammadQuran17 / Php_xmsi.md
Last active February 27, 2026 07:15
Code sheat

Update php in VPS

sudo apt install -y \
php8.3 \
php8.3-cli \
php8.3-common \
php8.3-mysql \
php8.3-xml \
@MuhammadQuran17
MuhammadQuran17 / docker.md
Last active March 13, 2026 10:15
Docker helper

Importants

You can't COPY a file from outside the build context. So if you are 
trying to COPY /opt/venv/lib/python3.7/site-packages/xxx/resources/abc.py into your docker image, and 
that is not in your build context, it will fail. Full stop.

docker inspect coolify-proxy -f '{{ json .Config }}' | jq

Entrypoint

@MuhammadQuran17
MuhammadQuran17 / git.md
Last active December 24, 2025 14:09
Git helper

Git clone private repository

  1. Create a grained PAT in github. Notice that grained PAT, can not see repos where you are not the owner, i.e. colloborator.
  2. Add Rules for your grained PAT. Permissions: Commit statuses, Contents, Pull requests and Metadata as Read to be able to Clone repositories. And the same Permissions need to the Read and Write to be able to push changes.
  3. git config --global user.name "Your Name"
  4. git config --global user.email "your.email@example.com"
  5. git config --list
  6. git clone https://(USERNAME):(TOKEN)@github.com/OWNER/REPO.git

Undo merged Merge request

@MuhammadQuran17
MuhammadQuran17 / intellijHelper.md
Last active October 29, 2025 13:07
Intellij IDEA helper

Index stuck forever

  1. Remove files inside of this folder C:\Users\muham\AppData\Local\JetBrains\PhpStorm2024.2\caches
  2. You can use PowerShell CLI for this (if you in PhpStormXXXX): Remove-Item .\caches\* -Recurse -Force
  3. Remove .idea folder
  4. Alternative is using File/InvalidateCaches button, but if it stuck, you should end task in taskManager and do 1,2 steps

ALL neccessary info here

@MuhammadQuran17
MuhammadQuran17 / Versioning.md
Last active February 21, 2025 06:46
Packages Versioning in composer.json, PHP

There is a difference between ~ and ^ in Composer, though it might not be immediately obvious in some cases. Let me clarify:

Key Difference Between ~ and ^:

  • ~ (tilde): Allows updates for the last digit specified.
  • ^ (caret): Allows updates for all minor versions within the same major version.

In your example, ~7.3 vs. ^7.3:

  • ~7.3: