Find the code you need
Search through tutorials, code snippets, and development resources
ما هو حقن التبعيات (Dependency Injection)؟
يتم تمرير التبعية عند استدعاء وظيفة معينة تحتاج إليها.
public function handle(Logger $logger) {
$logger->log("Handling action...");
}How to Stop SSH From Timing Out
Edit the SSH daemon config:
sudo nano /etc/ssh/sshd_configHow to Translate URLs in React (2025 Guide)
import i18n from 'i18next';
import { initReactI18next } from 'react-i18next';
import LanguageDetector from 'i18next-browser-languagedetector';
import en from './locales/en.json';
import fr from './locales/fr.json';
i18n
.use(LanguageDetector)
.use(initReactI18next)
.init({
resources: { en: { translation: en }, fr: { translation: fr } },
fallbackLng: 'en',
interpolation: {
escapeValue: false,
},
});
export default i18n;Sample en.json:
Globalization in React (2025 Trends & Best Practices)
new Intl.NumberFormat('en-US', {
style: 'currency',
currency: 'USD'
}).format(4999.99);
// Output: $4,999.99Make this dynamic in React:
Implementing Internationalization (i18n) in a Large React Application (2025 Guide)
This saves the user's preferred language so it's remembered on the next visit.
Implementing i18n is no longer optional — it's essential in 2025 as user bases go global and inclusive design becomes the standard.
Building Micro-Frontends with Webpack Module Federation (2025 Guide)
In 2025, micro-frontends are not just a buzzword — they are a proven way to scale modern frontend architectures. With Webpack Module Federation, teams can deliver independently developed features without sacrificing user experience or performance.
By following this guide, you’ve created a flexible, scalable frontend system that combines React and Vue in real time — powered by the magic of Webpack 5.
State Management Beyond Redux: Using Zustand for Scalable React Apps
Zustand isn't just for simple state management; it also offers advanced features that cater to more complex scenarios:
Zustand supports middleware for logging, persisting state, and more. For example, integrating with Redux DevTools:
Mastering React Rendering Performance with Memoization and Context
const ThemeContext = React.createContext();
const UserContext = React.createContext(); const value = useMemo(() => ({ user, setUser }), [user]);How to Disable MySQL Password Validation on Ubuntu 25.04
INSTALL COMPONENT 'file://component_validate_password';Then you'll need to restart MySQL:
How to Move the MySQL Data Directory to a New Location on Ubuntu 25.04
sudo systemctl stop mysqlChoose your new location, for example /mnt/data/mysql, and move the current data:
How to Install PHP, MySQL, and phpMyAdmin on Ubuntu 25.04 (LAMP Stack Setup Guide)
sudo a2ensite your_domain.conf
sudo a2enmod rewrite
sudo systemctl restart apache2Composer is essential for managing PHP dependencies:
How to Fix NVIDIA Driver Issues on Ubuntu (Dell Vostro 3521)
Install the recommended version:
sudo apt install nvidia-driver-550 nvidia-primeAvoiding Memory Leaks in C++ Without Smart Pointers
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;
};For arrays:
Deep Copy in C++: How to Avoid Shallow Copy Pitfalls
Shallow a(10);
Shallow b = a; // default copy constructorThis causes both a.data and b.data to point to the same memory. When both destructors run, delete is called twice on the same pointer — undefined behavior!
Protect Your Forms Like a Pro: Anti-Spam Techniques That Actually Work
Even though CSRF isn’t about spam exactly, CSRF tokens prevent cross-site attacks, which bots might exploit.
Most frameworks like Laravel, Django, or Express have CSRF protection built-in—use it.
Build a Custom Rate Limiter in Node.js with Redis
- Atomic operations with Redis
- Manual request tracking logic
- Flexibility to customize based on business rules
You’re no longer blindly relying on a package—you understand and control the system.
Arduino Basics: A Step-by-Step Tutorial
- Sensors and Actuators: Learn how to interface with various sensors (e.g., temperature, distance) and control motors or servos.
- Serial Communication: Understand how to send and receive data between the Arduino and your computer.
- Advanced Projects: Dive into projects that combine multiple components for more interactive applications.
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);
}
}
}Building a Cross-Platform Desktop App with Tauri and Svelte: A Step-by-Step Tutorial
Tauri packages your Svelte frontend along with the Rust backend into a lightweight, platform-specific binary.
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:
Implementing a Domain-Specific Language (DSL) with LLVM and C++
Example DSL Code:
(3 + 4) * (5 - 2) / 2