Find the code you need
Search through tutorials, code snippets, and development resources
ما هو حقن التبعيات (Dependency Injection)؟
class Logger {
public function log($message) {
echo $message;
}
}
class UserService {
protected $logger;
public function __construct(Logger $logger) {
$this->logger = $logger;
}
public function create() {
$this->logger->log("User created.");
}
}يتم تمرير التبعية عند استدعاء وظيفة معينة تحتاج إليها.
How to Stop SSH From Timing Out
Host *
ServerAliveInterval 60
ServerAliveCountMax 3This ensures your SSH client pings the server regularly.
How to Translate URLs in React (2025 Guide)
npm install react-router-dom i18next react-i18next i18next-browser-languagedetector/src
/locales
en.json
fr.json
/pages
Home.js
About.js
i18n.js
App.js
routes.jsGlobalization in React (2025 Trends & Best Practices)
Use IP detection (via backend or service like IPinfo):
if (userCountry === 'EG') {
showEGPPrices();
} else {
showUSDPrices();
}Implementing Internationalization (i18n) in a Large React Application (2025 Guide)
resources: {
en: {
home: require('./locales/en/home.json'),
dashboard: require('./locales/en/dashboard.json'),
},
fr: {
home: require('./locales/fr/home.json'),
dashboard: require('./locales/fr/dashboard.json'),
},
},
ns: ['home', 'dashboard'],
defaultNS: 'home',In component:
Building Micro-Frontends with Webpack Module Federation (2025 Guide)
npx create-react-app app-shell
cd app-shell
npm install -D webpack webpack-cli webpack-dev-server html-webpack-pluginIn webpack.config.js of app-shell:
State Management Beyond Redux: Using Zustand for Scalable React Apps
const count = useStore((state) => state.count);By selecting only the necessary state slices, you can optimize component rendering and improve performance.
Mastering React Rendering Performance with Memoization and Context
import React from 'react';
const Greeting = React.memo(function Greeting({ name }) {
console.log("Greeting rendered");
return <h3>Hello{name && ', '}{name}!</h3>;
});In this example, Greeting will only re-render when the name prop changes. This optimization is particularly beneficial for components that render frequently with the same props.([React][4], [Content That Scales][5])
How to Disable MySQL Password Validation on Ubuntu 25.04
This should now work without any errors.
If you want to bring back strong password policies:
How to Move the MySQL Data Directory to a New Location on Ubuntu 25.04
Ensure MySQL can access the new directory:
sudo chown -R mysql:mysql /mnt/data/mysqlHow to Install PHP, MySQL, and phpMyAdmin on Ubuntu 25.04 (LAMP Stack Setup Guide)
Ubuntu 25.04 includes PHP 8.3 in its official repositories. Install PHP along with commonly used extensions for Laravel:
sudo apt install php php-cli php-mbstring php-xml php-bcmath php-curl php-mysql php-zip php-gd php-fpm unzipHow to Fix NVIDIA Driver Issues on Ubuntu (Dell Vostro 3521)
nvidia-smiYou should see output like:
Avoiding Memory Leaks in C++ Without Smart Pointers
What’s wrong? If someCondition() returns true, buffer is never deallocated.
void loadData() {
char* buffer = new char[1024];
try {
if (someCondition()) {
throw std::runtime_error("Something went wrong");
}
// more code...
} catch (...) {
delete[] buffer;
throw;
}
delete[] buffer;
}Deep Copy in C++: How to Avoid Shallow Copy Pitfalls
Now consider:
Shallow a(10);
Shallow b = a; // default copy constructorProtect Your Forms Like a Pro: Anti-Spam Techniques That Actually Work
Why it works: Bots usually fill every field, including hidden ones. Real users never see it.
Most humans take a few seconds to fill a form. Bots fill and submit instantly.
Build a Custom Rate Limiter in Node.js with Redis
// server.js
require("dotenv").config();
const express = require("express");
const rateLimiter = require("./rateLimiter");
const app = express();
const PORT = 3000;
app.use(rateLimiter(100, 3600)); // 100 requests/hour per IP
app.get("/", (req, res) => {
res.send("Welcome! You're within rate limit.");
});
app.listen(PORT, () => {
console.log(`Server running on http://localhost:${PORT}`);
});Use Postman or curl:
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.
Building a Real-Time Object Detection Web App with TensorFlow.js and p5.js
You do not need any backend setup since everything runs in the browser using TensorFlow.js and p5.js.
Create a new folder for your project and add an index.html file. In this file, we’ll include the necessary libraries via CDN:
Building a Cross-Platform Desktop App with Tauri and Svelte: A Step-by-Step Tutorial
Tauri provides many built-in APIs to interact with the system (e.g., file system, notifications, dialogs). To call a Tauri API from Svelte, use the Tauri JavaScript API. For example, to display a notification:
npm install @tauri-apps/apiImplementing a Domain-Specific Language (DSL) with LLVM and C++
mydsl/
CMakeLists.txt
include/
DSL/
Lexer.h
Parser.h
AST.h
src/
Lexer.cpp
Parser.cpp
AST.cpp
CodeGen.cpp
main.cppYour CMakeLists.txt should find and link LLVM libraries. For example: