DeveloperBreeze

Find the code you need

Search through tutorials, code snippets, and development resources

Tutorial

ما هو حقن التبعيات (Dependency Injection)؟

بهذه الطريقة، يصبح كل كائن أقل اعتماداً على التفاصيل الداخلية، وأكثر مرونة وقابلاً للاختبار.

عندما تعتمد الكائنات على إنشاء التبعيات داخلياً، فإن النظام يصبح مترابطاً بشكل كبير. حقن التبعيات يفصل عملية الإنشاء عن الاستخدام، مما يقلل الترابط ويجعل البنية أكثر تنظيماً.

Dec 01, 2025
Read More
Tutorial

How to Stop SSH From Timing Out

This ensures your SSH client pings the server regularly.

That’s it. With these changes, your SSH session will stay alive and won’t drop after just a minute.

Aug 21, 2025
Read More
Tutorial

How to Translate URLs in React (2025 Guide)

Update App.js:

import React from 'react';
import { useTranslation } from 'react-i18next';
import { BrowserRouter, Routes, Route, useNavigate } from 'react-router-dom';
import { routes } from './routes';
import './i18n';

const LanguageSwitcher = () => {
  const { i18n } = useTranslation();
  const navigate = useNavigate();

  const switchLang = (lang) => {
    const currentPath = window.location.pathname;
    const currentPage = currentPath.split('/')[1];

    i18n.changeLanguage(lang).then(() => {
      // Re-map path using new language
      const t = i18n.getFixedT(lang);
      const mappedRoutes = {
        en: { accueil: 'home', 'a-propos': 'about-us' },
        fr: { home: 'accueil', 'about-us': 'a-propos' },
      };

      const newPath = `/${mappedRoutes[lang][currentPage] || ''}`;
      navigate(newPath);
    });
  };

  return (
    <div className="lang-switch">
      <button onClick={() => switchLang('en')}>EN</button>
      <button onClick={() => switchLang('fr')}>FR</button>
    </div>
  );
};

const App = () => {
  const { t } = useTranslation();

  return (
    <BrowserRouter>
      <LanguageSwitcher />
      <Routes>
        {routes(t).map((route, idx) => (
          <Route key={idx} path={route.path} element={route.element} />
        ))}
      </Routes>
    </BrowserRouter>
  );
};

export default App;

May 04, 2025
Read More
Tutorial

Globalization in React (2025 Trends & Best Practices)

  • GDPR requires local-language privacy policies
  • China's Cybersecurity Law needs local hosting + Mandarin support
  • Saudi localization laws mandate Arabic for all government services

Your React app must support legal localization where applicable.

May 04, 2025
Read More
Tutorial

Implementing Internationalization (i18n) in a Large React Application (2025 Guide)

  • Translate your app without performance loss
  • Format dates, numbers, currencies natively
  • Scale your translations across large React apps
  • Add RTL (right-to-left) support for Arabic or Hebrew
  • Integrate with translation platforms like Locize or Crowdin
  • Explore SSR-ready i18n setups (e.g., with Next.js)
  • Use useContext for localized theme changes (e.g., cultural preferences)

May 04, 2025
Read More
Tutorial

Building Micro-Frontends with Webpack Module Federation (2025 Guide)

As web applications grow larger and teams become more distributed, the traditional monolithic frontend architecture becomes harder to scale. Enter micro-frontends — the 2025-ready solution that brings backend microservices thinking to the frontend world.

Micro-frontends allow different teams to work independently on isolated UI components, which are then stitched together at runtime. This enables:

May 04, 2025
Read More
Tutorial

State Management Beyond Redux: Using Zustand for Scalable React Apps

   import React from 'react';
   import useStore from './store';

   function Counter() {
     const { count, increase, decrease } = useStore();
     return (
       <div>
         <h1>{count}</h1>
         <button onClick={increase}>Increase</button>
         <button onClick={decrease}>Decrease</button>
       </div>
     );
   }

   export default Counter;

With these steps, you've set up a basic state management system using Zustand without the need for additional boilerplate or context providers.

May 03, 2025
Read More
Tutorial

Mastering React Rendering Performance with Memoization and Context

   const value = useMemo(() => ({ user, setUser }), [user]);
   const increment = useCallback(() => setCount(c => c + 1), []);

May 03, 2025
Read More
Tutorial

How to Disable MySQL Password Validation on Ubuntu 25.04

Run the following command in the MySQL prompt:

UNINSTALL COMPONENT 'file://component_validate_password';

May 01, 2025
Read More
Tutorial

How to Move the MySQL Data Directory to a New Location on Ubuntu 25.04

Edit AppArmor profile for MySQL:

sudo nano /etc/apparmor.d/usr.sbin.mysqld

May 01, 2025
Read More
Tutorial

How to Install PHP, MySQL, and phpMyAdmin on Ubuntu 25.04 (LAMP Stack Setup Guide)

Install the MySQL server package:

sudo apt install mysql-server

May 01, 2025
Read More
Tutorial

How to Fix NVIDIA Driver Issues on Ubuntu (Dell Vostro 3521)

Run:

sudo ubuntu-drivers devices

Apr 14, 2025
Read More
Tutorial

Avoiding Memory Leaks in C++ Without Smart Pointers

Let’s build a small ScopedPointer class.

template <typename T>
class ScopedPointer {
private:
    T* ptr;

public:
    explicit ScopedPointer(T* p = nullptr) : ptr(p) {}

    ~ScopedPointer() {
        delete ptr;
    }

    T& operator*() const { return *ptr; }
    T* operator->() const { return ptr; }
    T* get() const { return ptr; }

    void reset(T* p = nullptr) {
        if (ptr != p) {
            delete ptr;
            ptr = p;
        }
    }

    // Prevent copy
    ScopedPointer(const ScopedPointer&) = delete;
    ScopedPointer& operator=(const ScopedPointer&) = delete;
};

Apr 11, 2025
Read More
Tutorial

Deep Copy in C++: How to Avoid Shallow Copy Pitfalls

In C++11 and newer, also consider:

  • Move Constructor
  • Move Assignment Operator

Apr 11, 2025
Read More
Tutorial

Protect Your Forms Like a Pro: Anti-Spam Techniques That Actually Work

  • Easy for most users
  • Stops most bots
  • Sometimes annoying
  • No user interaction
  • Uses a score (0–1) to decide if the user is a bot

Apr 04, 2025
Read More
Tutorial

Build a Custom Rate Limiter in Node.js with Redis

Create a .env file:

REDIS_URL=redis://localhost:6379

Apr 04, 2025
Read More
Tutorial

Arduino Basics: A Step-by-Step Tutorial

  • Connect the longer leg (anode) of the LED to digital pin 13.
  • Connect the shorter leg (cathode) to one end of the 220Ω resistor.
  • Connect the other end of the resistor to the Arduino’s GND pin.

Feb 12, 2025
Read More
Tutorial
javascript

Building a Real-Time Object Detection Web App with TensorFlow.js and p5.js

Create a new file called sketch.js in your project folder. We’ll use p5.js to access the webcam and display the video on a canvas:

let video;
let detector;
let detections = [];

function setup() {
  // Create the canvas to match the video dimensions
  createCanvas(640, 480);
  // Capture video from the webcam
  video = createCapture(VIDEO);
  video.size(640, 480);
  video.hide();

  // Load the pre-trained COCO-SSD model
  cocoSsd.load().then(model => {
    detector = model;
    console.log("Model Loaded!");
    // Begin detecting objects every frame
    detectObjects();
  });
}

function detectObjects() {
  detector.detect(video.elt).then(results => {
    detections = results;
    // Continue detection in a loop
    detectObjects();
  });
}

function draw() {
  // Draw the video
  image(video, 0, 0);

  // Draw detection boxes and labels if available
  if (detections) {
    for (let i = 0; i < detections.length; i++) {
      let object = detections[i];
      stroke(0, 255, 0);
      strokeWeight(2);
      noFill();
      rect(object.bbox[0], object.bbox[1], object.bbox[2], object.bbox[3]);
      noStroke();
      fill(0, 255, 0);
      textSize(16);
      text(object.class, object.bbox[0] + 4, object.bbox[1] + 16);
    }
  }
}

Feb 12, 2025
Read More
Tutorial

Building a Cross-Platform Desktop App with Tauri and Svelte: A Step-by-Step Tutorial

npm install -g @tauri-apps/cli

We’ll start by creating a new Svelte project. You can use a template via degit:

Feb 12, 2025
Read More
Tutorial

Implementing a Domain-Specific Language (DSL) with LLVM and C++

Implementation: Lexer.cpp

#include "DSL/Lexer.h"
#include <cctype>
#include <cstdlib>

Lexer::Lexer(const std::string& input) : input(input) {}

char Lexer::currentChar() {
    if (pos < input.size()) {
        return input[pos];
    }
    return '\0';
}

void Lexer::advance() {
    pos++;
}

void Lexer::skipWhitespace() {
    while (std::isspace(currentChar())) {
        advance();
    }
}

Token Lexer::number() {
    size_t start = pos;
    while (std::isdigit(currentChar()) || currentChar() == '.') {
        advance();
    }
    std::string numStr = input.substr(start, pos - start);
    double value = std::strtod(numStr.c_str(), nullptr);
    return { TokenType::Number, numStr, value };
}

Token Lexer::getNextToken() {
    skipWhitespace();

    char current = currentChar();

    if (current == '\0') {
        return { TokenType::EndOfFile, "", 0 };
    }
    if (std::isdigit(current) || current == '.') {
        return number();
    }

    Token token;
    token.text = std::string(1, current);
    token.value = 0;
    switch (current) {
        case '+': token.type = TokenType::Plus; break;
        case '-': token.type = TokenType::Minus; break;
        case '*': token.type = TokenType::Asterisk; break;
        case '/': token.type = TokenType::Slash; break;
        case '(': token.type = TokenType::LParen; break;
        case ')': token.type = TokenType::RParen; break;
        default: token.type = TokenType::Invalid; break;
    }
    advance();
    return token;
}

Feb 12, 2025
Read More