👋 Hello, I'm

Deniz Memduev

Software Developer from Bulgaria 🚀

Welcome to my personal website, where I explore the latest and most innovative technologies and techniques in the digital world. As a tech enthusiast and lifelong learner, I'm always on the lookout for new ways to push the boundaries of what's possible with technology. Through my website, I share my knowledge and insights on a variety of topics, including machine learning, artificial intelligence, blockchain, cybersecurity, and more. Whether you're a fellow technologist or simply curious about the latest trends in the tech world, you'll find valuable resources and information here.

image

☕ Recent posts

Keep scrolling while i get a coffee for you

tabs-or-spaces

Tabs or Spaces: How to Choose the Right Indentation Method for Your Code?

One of the oldest debates in programming is between using tabs or spaces for code indentation. You might wonder why this is so important since they are just blank spaces in the code. However, the choice of indentation method can significantly impact the readability of the code, consistency within teams, and even file size. In this blog post, we will explore the advantages and disadvantages of each method and help you decide which one is best for you.

What is indentation?

Indentation is the way code is visually organized to make it easier to read and understand. This is especially important for block structures like functions, loops, and conditionals. Well-formatted code with clear indentation is much easier to maintain and comprehend, both for the code’s author and for other developers.

Tabs

Tabs are a special character that usually occupies one position in a text editor but can be configured to display with different widths.


Advantages of tabs:

  1. Customizable: Tabs allow each programmer to configure how their code looks. In different environments and text editors, the width of tabs can be adjusted to personal preferences.
  2. Smaller file size: Tabs take up less space since they are represented by a single character, whereas spaces take up more room. This can have a small impact on large projects with lots of code.
  3. Accessibility: For people with visual impairments or other needs, tabs allow them to adjust how the code is displayed by increasing or decreasing the visual width of tabs.


⁠Disadvantages of tabs:

  1. Inconsistent appearance: One of the biggest downsides of tabs is that they may look different on different systems and editors, as each can display tabs with different widths.
  2. Harder to align: When trying to align code, especially when organizing multiple lines into columns, tabs can cause misalignment across different environments.


Spaces

⁠Spaces are fixed-width characters and, unlike tabs, they always occupy the same width in the code, regardless of the editor’s settings.


Advantages of spaces:

  1. Consistency: Spaces ensure that the code looks the same for all developers, regardless of their text editor settings. This eliminates the possibility of different visual representations of the same code.
  2. Precise alignment: With spaces, you have precise control over how your code is aligned. This is particularly useful when aligning elements, such as in tables or long lists of arguments.
  3. Industry standard: Many large companies and organizations (like Google and Microsoft) prefer spaces. Using spaces can help you adapt more easily to open-source projects or large teams.



Disadvantages of spaces:

  1. Not customizable: Unlike tabs, spaces cannot be adjusted to look different for different users. Once set, they are fixed.
  2. Larger file size: Although the difference may be minimal, using spaces increases the file size since each space takes up room, whereas tabs are represented by a single character.



What do teams and the industry prefer?

Many developers prefer spaces because they provide a consistent appearance of the code for everyone, no matter the environment or editor. This makes spaces a popular choice for large teams and open-source projects. In fact, some large companies like Google and Microsoft standardize the use of spaces with a 2 or 4-space indentation width.

On the other hand, tabs are favored by programmers who value flexibility and customization. Tabs allow developers to control how their code appears on different devices and text editors without changing the actual code.

.editorconfig – For Consistency in Teams

To achieve consistency in coding style across team projects, you can use the .editorconfig file. This is a configuration file that defines formatting rules for different languages and file types. If your project involves developers with different editor settings, .editorconfig helps ensure the same coding style is maintained.

Example of an .editorconfig file:

# Basic settings for all files [*] 
 indent_style = tab
 indent_size = 4
 end_of_line = lf
 charset = utf-8
 trim_trailing_whitespace = true
 insert_final_newline = true
⁠
# Specific settings for JavaScript files [*.js] 
 indent_style = space
 indent_size = 2

With this file, you ensure that all contributors to the project use the same rules for indentation and code formatting, regardless of their local settings.


Conclusion: Tabs or Spaces?

The answer depends on the context and personal preference. If you work alone and like to customize how your code looks, tabs might be more suitable for you. However, if you work in a team or need guaranteed consistency in your code, spaces are the better choice.

Whatever you choose, the most important thing is to follow the rules of your team or project and maintain consistency in your code. In the end, whether you use tabs or spaces, well-written and clearly structured code will always be easy to read and maintain.

smart-contracts

Smart Contracts: The Digital Transaction Revolution

Introduction:⁠


Welcome to the world of smart contracts - the new era of digital transactions. Rooted in blockchain technology, smart contracts are transforming how we interact and conduct business in the digital age. But what exactly is a smart contract, and how does it work? In this blog post, we'll explore the key features and benefits of smart contracts.

Key Features of Smart Contracts:⁠


Automation
: Smart contracts automatically execute the agreed-upon terms, facilitating and speeding up transactions without the need for intermediaries.

Transparency and Trust: All terms are clearly visible and accessible on the blockchain network, ensuring transparency and fostering trust among participants.


Security and Immutability: Once created, smart contracts cannot be altered, making them extremely secure and reliable.


Versatility: They can be applied in numerous sectors – from finance and insurance to logistics and legal services.


Cost-Effectiveness and Efficiency: Avoiding intermediaries and automation lead to significant time and resource savings.

Speed: Smart contracts are executed immediately once the set conditions are met, speeding up processes.


Challenges and Limitations:

Despite their many advantages, smart contracts are not without challenges. These include difficulties in making changes post-creation, potential security risks, and the need for technical understanding by the participants.


Conclusion:⁠

Smart contracts are more than a technological novelty – they are a catalyst for change in the way we conduct transactions and manage contractual relationships. Their ability to automate and simplify complex processes while offering security and transparency makes them a valuable tool in the future of the digital economy.

web-sockets

Building a Real-Time Chat App with WebSockets, React, and NestJS

Real-time applications are everywhere—from collaborative tools to chat applications. In this blog post, we'll build a simple real-time chat application using WebSockets, React, and NestJS.


Table of Contents

  1. Introduction
  2. Setting up the NestJS Backend
  3. Setting up the React Front-end
  4. Conclusion


Introduction

The modern web is all about real-time updates. WebSockets enable real-time, full-duplex communication between the server and connected clients. We'll use NestJS for our back-end and React for our front-end.


Setting up the NestJS Backend

First, make sure you have the NestJS CLI installed:

npm i -g @nestjs/cli

Now, create a new NestJS application:

nest new nest-chat-backend

Navigate to the newly created project directory and install the required WebSocket package:

cd nest-chat-backend npm install @nestjs/websockets @nestjs/platform-socket.io

Create a WebSocket gateway:

nest generate gateway chat

Edit chat.gateway.ts:

import { SubscribeMessage, WebSocketGateway, WebSocketServer } from '@nestjs/websockets';
import { Server, Socket } from 'socket.io';

@WebSocketGateway()
export class ChatGateway {
@WebSocketServer() server: Server;

@SubscribeMessage('message')
handleMessage(client: Socket, payload: string): void {
this.server.emit('message', payload);
}
}


Setting up the React Front-end

Create a new React project:

npx create-react-app react-chat-frontend

Navigate to the project and install the Socket.io client:

cd react-chat-frontend npm install socket.io-client

Edit App.js:

import React, { useState, useEffect } from 'react';
import io from 'socket.io-client';

const socket = io('http://localhost:3000');

function App() {
const [message, setMessage] = useState('');
const [chat, setChat] = useState([]);

useEffect(() => {
socket.on('message', (message) => {
setChat([...chat, message]);
});
}, [chat]);

const sendMessage = () => {
socket.emit('message', message);
setMessage('');
};

return (
<div>
<div>
{chat.map((message, i) => (
<div key={i}>{message}</div>
))}
</div>
<input
type="text"
value={message}
onChange={(e) => setMessage(e.target.value)}
/>
<button onClick={sendMessage}>Send</button>
</div>
);
}

export default App;


Conclusion

You've successfully built a real-time chat application using WebSockets with NestJS and React! This is a basic example, but it demonstrates the real-time capabilities of WebSockets and how smoothly they integrate with modern web frameworks like React and NestJS.


Happy coding!