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

Add these lines:

ClientAliveInterval 60
ClientAliveCountMax 3

Aug 21, 2025
Read More
Tutorial

How to Translate URLs in React (2025 Guide)

When building a multilingual React application, translating the visible content is just part of the job. To make your app SEO-friendly and user-centric, you also need to:

  • Translate URLs/slugs (e.g., /about-us/fr/a-propos)
  • Maintain SEO with hreflang for each language
  • Improve UX by aligning URLs with user language
  • Ensure route accessibility via browser language or manual switching

May 04, 2025
Read More
Tutorial

Globalization in React (2025 Trends & Best Practices)

In 2025, React globalization goes beyond just i18n (internationalization). It includes:

  • Text translation (i18n)
  • Locale-aware formatting (dates, numbers, currencies)
  • Cultural UX adaptations (e.g., RTL layouts, color symbolism)
  • Language switching + SEO compatibility
  • Region-based content rendering (e.g., laws, units, timezones)

May 04, 2025
Read More
Tutorial

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

With i18next and react-i18next, you can:

  • Translate your app without performance loss
  • Format dates, numbers, currencies natively
  • Scale your translations across large React apps

May 04, 2025
Read More
Tutorial

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

Create a webpack.config.js:

const HtmlWebpackPlugin = require('html-webpack-plugin');
const ModuleFederationPlugin = require('webpack').container.ModuleFederationPlugin;
const path = require('path');

module.exports = {
  mode: 'development',
  devServer: {
    port: 8081,
  },
  entry: './src/main.js',
  output: {
    publicPath: 'http://localhost:8081/',
  },
  plugins: [
    new ModuleFederationPlugin({
      name: 'analytics_app',
      filename: 'remoteEntry.js',
      exposes: {
        './Analytics': './src/components/Analytics.vue',
      },
      shared: require('./package.json').dependencies,
    }),
    new HtmlWebpackPlugin({ template: './public/index.html' }),
  ],
};

May 04, 2025
Read More
Tutorial

State Management Beyond Redux: Using Zustand for Scalable React Apps

import create from 'zustand';
import { persist } from 'zustand/middleware';

const useStore = create(persist(
  (set) => ({
    count: 0,
    increase: () => set((state) => ({ count: state.count + 1 })),
  }),
  {
    name: 'counter-storage',
  }
));

Zustand allows you to select specific parts of the state to prevent unnecessary re-renders:

May 03, 2025
Read More
Tutorial

Mastering React Rendering Performance with Memoization and Context

import React, { useState, useCallback } from 'react';

function Counter() {
  const [count, setCount] = useState(0);

  const increment = useCallback(() => setCount(c => c + 1), []);
  const decrement = useCallback(() => setCount(c => c - 1), []);

  return (
    <div>
      <button onClick={increment}>+</button>
      <span>{count}</span>
      <button onClick={decrement}>-</button>
    </div>
  );
}

By wrapping increment and decrement with useCallback, their references remain stable across renders, preventing unnecessary re-renders in child components that receive these functions as props.([GeeksforGeeks][2])

May 03, 2025
Read More
Tutorial

How to Disable MySQL Password Validation on Ubuntu 25.04

SHOW VARIABLES LIKE 'validate_password%';

If disabled, this will return an empty result set.

May 01, 2025
Read More
Tutorial

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

Then reload AppArmor:

sudo apparmor_parser -r /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 phpMyAdmin along with necessary PHP extensions:

sudo apt install phpmyadmin php-mbstring php-zip php-gd php-json php-curl

May 01, 2025
Read More
Tutorial

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

prime-run glxinfo | grep "OpenGL renderer"

You should see:

Apr 14, 2025
Read More
Tutorial

Avoiding Memory Leaks in C++ Without Smart Pointers

#include "ScopedPointer.h"

void loadData() {
    ScopedArray<char> buffer(new char[1024]);

    if (someCondition()) {
        return; // no memory leak!
    }

    // buffer is auto-deleted when going out of scope
}

Some legacy APIs require raw pointers. You can still use get():

Apr 11, 2025
Read More
Tutorial

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

A deep copy duplicates the actual data pointed to, not just the pointer.

class Deep {
public:
    int* data;

    Deep(int val) {
        data = new int(val);
    }

    // Copy constructor for deep copy
    Deep(const Deep& other) {
        data = new int(*other.data);
    }

    // Assignment operator for deep copy
    Deep& operator=(const Deep& other) {
        if (this != &other) {
            delete data;
            data = new int(*other.data);
        }
        return *this;
    }

    ~Deep() {
        delete data;
    }
};

Apr 11, 2025
Read More
Tutorial

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

document.querySelector('form').dataset.start = Date.now();

Then send that timestamp with the form, and on the server:

Apr 04, 2025
Read More
Tutorial

Build a Custom Rate Limiter in Node.js with Redis

Use Postman or curl:

curl http://localhost:3000

Apr 04, 2025
Read More
Tutorial

Arduino Basics: A Step-by-Step Tutorial

  • Definition: Represent two states: HIGH (ON) and LOW (OFF).
  • Usage: Turning LEDs on/off, reading button states.
  • Definition: Varying signals that can represent a range of values.
  • Usage: Reading sensor data (e.g., temperature, light intensity).

Feb 12, 2025
Read More
Tutorial
javascript

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

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);
    }
  }
}
  • Setup: The setup function initializes the canvas and video capture. The video is hidden by p5.js’s default element so that we can draw it onto the canvas manually.
  • Model Loading: We load the COCO-SSD model asynchronously. Once the model is ready, we start continuous object detection by calling detectObjects().
  • Detection Loop: The detectObjects function uses the loaded model to analyze the current video frame and stores the detection results. It recursively calls itself so that new frames are analyzed continuously.
  • Drawing: In the draw loop, the video feed is displayed and for each detected object, a rectangle and label are drawn. The bounding box coordinates and object class are provided by the model.

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++

#ifndef DSL_PARSER_H
#define DSL_PARSER_H

#include "Lexer.h"
#include "AST.h"
#include <memory>

class Parser {
public:
    Parser(Lexer& lexer);
    std::unique_ptr<ASTNode> parseExpression();

private:
    Lexer& lexer;
    Token currentToken;

    void eat(TokenType type);
    std::unique_ptr<ASTNode> factor();
    std::unique_ptr<ASTNode> term();
};

#endif // DSL_PARSER_H

Implementation: Parser.cpp

Feb 12, 2025
Read More