Find the code you need
Search through tutorials, code snippets, and development resources
ما هو حقن التبعيات (Dependency Injection)؟
بهذه الطريقة، يصبح كل كائن أقل اعتماداً على التفاصيل الداخلية، وأكثر مرونة وقابلاً للاختبار.
عندما تعتمد الكائنات على إنشاء التبعيات داخلياً، فإن النظام يصبح مترابطاً بشكل كبير. حقن التبعيات يفصل عملية الإنشاء عن الاستخدام، مما يقلل الترابط ويجعل البنية أكثر تنظيماً.
How to Stop SSH From Timing Out
If your SSH session closes after a minute of inactivity, it’s usually caused by idle timeouts. You can fix this with keep-alive settings on both the server and client.
Edit the SSH daemon config:
How to Translate URLs in React (2025 Guide)
Install necessary dependencies:
npm install react-router-dom i18next react-i18next i18next-browser-languagedetectorGlobalization in React (2025 Trends & Best Practices)
°C vs °F, km vs miles, 12h vs 24h clock.
- Avoid idioms/slang in content
Implementing Internationalization (i18n) in a Large React Application (2025 Guide)
Then load them like:
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',Building Micro-Frontends with Webpack Module Federation (2025 Guide)
- Load remote components/apps on demand
- Share dependencies to avoid duplication
- Enable code splitting across teams
- Works with different JS frameworks
Let’s say you’re building a dashboard app in React, but your analytics module is handled by another team using Vue. You don’t want to tightly couple the two.
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:
Mastering React Rendering Performance with Memoization and Context
const value = useMemo(() => ({ user, setUser }), [user]); const increment = useCallback(() => setCount(c => c + 1), []);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
sudo mv /var/lib/mysql /mnt/data/mysql> This moves all database files including system schemas like mysql and performance_schema.
How to Install PHP, MySQL, and phpMyAdmin on Ubuntu 25.04 (LAMP Stack Setup Guide)
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php composer-setup.php
sudo mv composer.phar /usr/local/bin/composer
composer --versionIf you're installing global Composer packages:
How to Fix NVIDIA Driver Issues on Ubuntu (Dell Vostro 3521)
Install Mesa utilities:
sudo apt install mesa-utils
glxinfo | grep "OpenGL renderer"Avoiding Memory Leaks in C++ Without Smart Pointers
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;
}Not elegant. Easy to forget or misplace deletes. Let's go better.
Deep Copy in C++: How to Avoid Shallow Copy Pitfalls
This 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!
A deep copy duplicates the actual data pointed to, not just the pointer.
Protect Your Forms Like a Pro: Anti-Spam Techniques That Actually Work
Spam submissions are one of the most common annoyances for web developers. Whether you're dealing with contact forms, login pages, or comment sections—bots will find and abuse them.
In this tutorial, you'll learn real-world, effective anti-spam techniques beyond just slapping on a CAPTCHA. These strategies are easy to implement, and when combined, they make your forms extremely hard to abuse.
Build a Custom Rate Limiter in Node.js with Redis
This isn’t just a quick fix—it’s a deep dive into:
- Atomic operations with Redis
- Manual request tracking logic
- Flexibility to customize based on business rules
Arduino Basics: A Step-by-Step Tutorial
Now that you’ve built your first Arduino project, consider exploring these topics:
- 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
- Filtering Detections: Display only specific classes (e.g., only people or vehicles).
- Custom UI Elements: Use p5.js to add buttons or controls that modify detection settings in real time.
- Performance Optimization: Experiment with frame rate adjustments or model parameters for faster detection.
Congratulations! You’ve built a real-time object detection web application using TensorFlow.js and p5.js. This project demonstrates how to integrate machine learning models into a browser-based environment and interact with live video feeds. With further experimentation, you can adapt this tutorial to a variety of creative projects, from interactive art installations to practical surveillance tools.
Building a Cross-Platform Desktop App with Tauri and Svelte: A Step-by-Step Tutorial
Open the src-tauri/tauri.conf.json file to adjust settings like the application window, bundle identifiers, and security policies. For example, you might configure the window title and size:
{
"package": {
"productName": "TauriSvelteApp",
"version": "0.1.0"
},
"tauri": {
"windows": [
{
"title": "My Tauri App",
"width": 800,
"height": 600,
"resizable": true
}
],
"security": {
"csp": "default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'"
}
}
}Implementing a Domain-Specific Language (DSL) with LLVM and C++
#include "DSL/Parser.h"
#include <stdexcept>
Parser::Parser(Lexer& lexer) : lexer(lexer) {
currentToken = lexer.getNextToken();
}
void Parser::eat(TokenType type) {
if (currentToken.type == type) {
currentToken = lexer.getNextToken();
} else {
throw std::runtime_error("Unexpected token: " + currentToken.text);
}
}
std::unique_ptr<ASTNode> Parser::factor() {
if (currentToken.type == TokenType::Number) {
auto node = std::make_unique<NumberExprAST>(currentToken.value);
eat(TokenType::Number);
return node;
} else if (currentToken.type == TokenType::LParen) {
eat(TokenType::LParen);
auto node = parseExpression();
eat(TokenType::RParen);
return node;
}
throw std::runtime_error("Invalid syntax in factor.");
}
std::unique_ptr<ASTNode> Parser::term() {
auto node = factor();
while (currentToken.type == TokenType::Asterisk || currentToken.type == TokenType::Slash) {
TokenType op = currentToken.type;
eat(op);
auto right = factor();
node = std::make_unique<BinaryExprAST>(op, std::move(node), std::move(right));
}
return node;
}
std::unique_ptr<ASTNode> Parser::parseExpression() {
auto node = term();
while (currentToken.type == TokenType::Plus || currentToken.type == TokenType::Minus) {
TokenType op = currentToken.type;
eat(op);
auto right = term();
node = std::make_unique<BinaryExprAST>(op, std::move(node), std::move(right));
}
return node;
}Our AST nodes will represent numeric literals and binary operations. Later, these nodes are traversed to generate LLVM IR.