Posts

Use the Google Custom Search JSON API to retrieve images

 To use the Google Custom Search JSON API to retrieve images, you need two things : ✅ 1. Google API Key 🔧 Steps: Go to the Google Cloud Console. Create a new project (or select an existing one). In the left sidebar, go to APIs & Services > Credentials . Click "Create credentials" > "API key" . Copy the API Key shown — you'll use this in your code. ✅ 2. Custom Search Engine ID (cx) 🔧 Steps: Go to the  Custom Search Engine (CSE) page. Click "Get Started" . Enter a domain to search (e.g., www.google.com or leave it as *.com to search the whole web). Click "Create" . After it's created, go to the Control Panel . Under "Search engine ID" , you'll see your cx value — copy this . 🛠 Enable Image Search: In the Custom Search Engine settings (Control Panel): Go to "Basics" > Sites to search → make sure it’s set to “Search the entire web” . Go to ...

Laravel Best Practices: Building Robust and Maintainable Applications

Image
Laravel is one of the most popular PHP frameworks due to its elegance, simplicity, and developer-friendly syntax. But to fully harness Laravel’s power, developers must adhere to certain best practices that ensure their applications are secure, maintainable, and scalable. In this article, we’ll explore typical best practices for Laravel , drawing examples from a real-world scenario—an admin system handling borrow requests. 1. Use Service Classes for Business Logic Why? Keeping your controllers thin and offloading business logic to service classes promotes separation of concerns and cleaner code. public function approveRequestAction($borrowId): JsonResponse { $this->borrowService->approve($borrowId); return response()->json(['message' => 'Request approved']); } 2. Exception Handling Graceful error handling provides better developer and user experience. Use try-catch blocks and Laravel’s built-in exceptions like ModelNotFoundException . try { $th...

Choosing stack for application

choosing backend  https://chatgpt.com/share/68353f1d-29c8-8001-8a30-ac02b2eee22c choosing frontend https://chatgpt.com/share/6835406f-b434-8001-8e34-f3267a6e6f4b

Learn React

 Great choice! React is a powerful and popular library for building web interfaces. Here's a step-by-step guide to begin learning React effectively: ### **1. Prerequisites** Before jumping into React, make sure you’re comfortable with: * **HTML/CSS** * **JavaScript fundamentals** (variables, functions, objects, arrays, ES6+ features like arrow functions, destructuring, promises, etc.) * **DOM manipulation basics** * **Git & command line (optional but helpful)** If you're rusty on these, take a few days to brush up on: * [MDN Web Docs](https://developer.mozilla.org/) * [JavaScript.info](https://javascript.info/) --- ### **2. Learn React Basics** Start with the official React docs: * [React Official Tutorial](https://react.dev/learn)   * It’s interactive, beginner-friendly, and constantly updated. Key topics to cover: * What is React? * Components (function components) * JSX * Props and State * Event handling * Conditional rendering * Lists and keys --- ### **3. Build Simple...

Solving 'rm -rf Cannot Remove Directory: Directory Not Empty' in Linux

Image
  hasindu@hasindu-inspiron:/media/hasindu/Disk_D/Y3S2/DS/Labs$ rm -rf Socket_Programming_Lab rm: cannot remove 'Socket_Programming_Lab/chatserver/.metadata/.plugins/org.eclipse.m2e.logback': Directory not empty hasindu@hasindu-inspiron:/media/hasindu/Disk_D/Y3S2/DS/Labs$ sudo rm -rf Socket_Programming_Lab rm: cannot remove 'Socket_Programming_Lab/chatserver/.metadata/.plugins/org.eclipse.m2e.logback': Directory not empty hasindu@hasindu-inspiron:/media/hasindu/Disk_D/Y3S2/DS/Labs$ lsof +D Socket_Programming_Lab COMMAND    PID    USER   FD   TYPE DEVICE SIZE/OFF    NODE NAME nautilus  9316 hasindu   30r   DIR    8,1        0 1122807 Socket_Programming_Lab nautilus  9316 hasindu   36r   DIR    8,1        0 1122808 Socket_Programming_Lab/chatserver nautilus  9316 hasindu   38r   DIR    8,1...

Study React 18 features

 https://youtu.be/sjgA23G-TXU?si=xvLfUlzkNFWC3b50 full video for full stack https://youtu.be/ZxKM3DCV2kE?si=a1RIDL-NRGtVgfBk

RBAC for DS UBER app

 https://chatgpt.com/c/67ecfa5a-7d1c-8012-831d-436f0d0e4627 Usage of context for auth AuthContext