Serving a Hugo Site from Multiple Domains Using Relative URLs

Serving a Hugo Site from Multiple Domains Using Relative URLs Want to host the same Hugo site on multiple domains without generating separate versions? By configuring Hugo to use relative URLs, you can efficiently serve the same fileset across multiple domains. Here’s how you can set it up. Steps to Enable Relative URLs in Hugo 1. Configure Hugo to Use Relative URLs In your config.toml (or config.yaml/config.json), enable relative URLs by setting the relativeURLs option to true: ...

March 15, 2025 · 2 min · Taner

Setting Up a Development Environment for SharePoint with Microsoft Graph API

Setting Up a Development Environment for SharePoint with Microsoft Graph API Setting up a development environment for SharePoint, especially one integrated with the Microsoft Graph API, doesn’t have to be daunting! This guide breaks it down step by step. 1. Choose Your SharePoint Environment You have two main options: SharePoint Online (Office 365): Perfect for Microsoft Graph integration—always current and feature-rich. SharePoint Server (On-Premises): More complex and doesn’t directly support Microsoft Graph. For beginners, SharePoint Online is a no-brainer! ...

March 15, 2025 · 2 min · TC

Specialized Docker Containers: A Detailed Breakdown

Here’s a more detailed explanation of each of my Docker containers and what they specialize in: 1. Authelia Authelia provides identity verification through single sign-on (SSO) and two-factor authentication (2FA). It’s ideal for securing your self-hosted services, requiring users to verify their identity before accessing them. You can configure authentication methods like one-time passwords (OTP) or push notifications. 2. CrowdSec CrowdSec is a modern intrusion detection system that analyzes server logs and identifies suspicious behaviors. It acts as a collaborative threat defense mechanism, sharing community-wide information to prevent cyberattacks. It can block harmful IP addresses, making it a robust tool for proactive security. ...

March 15, 2025 · 3 min · Taner

The Two-Phase Commit (2PC) Pattern: Ensuring Consistency in Distributed Systems

The Two-Phase Commit (2PC) Pattern: Ensuring Consistency in Distributed Systems The Two-Phase Commit (2PC) Pattern is a distributed protocol that guarantees all or none of the operations in a distributed system are successfully completed, ensuring data consistency and integrity. It is essential for achieving atomic transactions across multiple resources, such as databases or services, in distributed systems. Coordinator +------------------+ | | | Transaction | | Coordinator | | | +------------------+ / \ / \ Participant1 Participant2 +---------+ +---------+ | | | | | Node | | Node | | | | | +---------+ +---------+ What is Two-Phase Commit? The Two-Phase Commit protocol divides the transaction process into two phases to coordinate operations across multiple participants: ...

March 15, 2025 · 3 min · Taner

Two-Phase Commit (2PC) vs Outbox Pattern: Ensuring Data Consistency

Two-Phase Commit (2PC) vs Outbox Pattern: Ensuring Data Consistency The Two-Phase Commit (2PC) Pattern and the Outbox Pattern are two prominent strategies for achieving data consistency in distributed systems. While they both solve similar problems, they employ different approaches. Let’s dive into these patterns to help you determine which is best suited for your application needs. Two-Phase Commit (2PC) Pattern The 2PC Pattern is a distributed protocol designed to ensure that all participants in a distributed transaction either commit or rollback their changes, maintaining data consistency across systems. ...

March 15, 2025 · 4 min · Taner

Two-Phase Commit (2PC) vs Paxos vs Raft: Distributed Systems Protocols

Two-Phase Commit (2PC) vs Paxos vs Raft: Distributed Systems Protocols Two-Phase Commit (2PC), Paxos, and Raft are widely used protocols in distributed systems. While they may overlap in their goals of achieving consistency and reliability, they are tailored for different purposes and come with their own strengths and weaknesses. Let’s explore these protocols and understand their distinctions. Two-Phase Commit (2PC) Purpose: Ensures atomicity in distributed transactions, ensuring that all participants either commit or abort collectively. ...

March 15, 2025 · 3 min · Taner

Understanding Distributed Locks: Use Cases, Benefits, and Implementation

Understanding Distributed Locks: Use Cases, Benefits, and Implementation Distributed locks play a vital role in ensuring safe and synchronized access to shared resources in distributed systems. Let’s explore when and why to use distributed locks, their benefits, and practical implementation examples. 1. Introduction to Distributed Locks A distributed lock ensures that only one process or service can access a shared resource at a time, even in a system with multiple nodes. For example, you can use distributed locks to: ...

March 15, 2025 · 3 min · TC

Understanding FetchXML: Breaking Down a Query Example

Understanding FetchXML: Breaking Down a Query Example FetchXML is a powerful XML-based query language for retrieving data from Microsoft Dataverse. Let’s break down a sample FetchXML query and understand its components. FetchXML Query <fetch> <entity name='contact'> <attribute name='fullname' /> <attribute name='emailaddress1' /> <link-entity name='account' from='accountid' to='parentcustomerid' alias='account'> <filter> <condition attribute='accountid' operator='eq' value='ACCOUNT_ID' /> </filter> </link-entity> </entity> </fetch> Explanation of Components <fetch>: The root element of the query, containing the definition of what data to retrieve. <entity>: Defines the primary entity for the query. In this example: ...

March 15, 2025 · 2 min · Taner

Understanding Internet Protocols: HTTP, HTTPS, TCP, UDP, and More

Understanding Internet Protocols: HTTP, HTTPS, TCP, UDP, and More Websites and applications communicate using different protocols, which are standardized methods for transferring data over a network. These protocols define how data is sent, received, and interpreted between systems. Below, we explore the most widely used protocols and their key features. HTTP (Hypertext Transfer Protocol) HTTP is the original protocol used for web communication. It enables the transfer of hypertext documents and allows users to interact with websites. ...

March 15, 2025 · 3 min · Taner

Updated Implementation Using `System.Text.Json`

Updated Implementation Using System.Text.Json using System; using System.Text.Json; using System.Text.Json.Serialization; public abstract class MessageEnvelope<T> { // Properties remain immutable public string EventType { get; private init; } public string SourceService { get; private init; } public DateTime Timestamp { get; private init; } public Guid TraceId { get; private init; } public T Payload { get; private init; } // Private constructor for builder use only private MessageEnvelope() { } public static Builder CreateBuilder() => new Builder(); // Serialization to JSON public string ToJson() { var options = new JsonSerializerOptions { WriteIndented = true // Makes the output JSON easier to read }; return JsonSerializer.Serialize(this, options); } // Deserialization from JSON public static MessageEnvelope<T> FromJson(string json) { var options = new JsonSerializerOptions { PropertyNameCaseInsensitive = true // Handles case differences in JSON properties }; return JsonSerializer.Deserialize<ConcreteMessageEnvelope>(json, options); } // Concrete implementation example for proper deserialization private class ConcreteMessageEnvelope : MessageEnvelope<T> { } public class Builder { private readonly MessageEnvelope<T> _envelope = new ConcreteMessageEnvelope(); public Builder WithEventType(string eventType) { _envelope.EventType = eventType; return this; } public Builder WithSourceService(string sourceService) { _envelope.SourceService = sourceService; return this; } public Builder WithPayload(T payload) { _envelope.Payload = payload; return this; } public Builder WithTimestamp(DateTime timestamp) { _envelope.Timestamp = timestamp; return this; } public Builder WithTraceId(Guid traceId) { _envelope.TraceId = traceId; return this; } public MessageEnvelope<T> Build() { _envelope.Timestamp = _envelope.Timestamp == default ? DateTime.UtcNow : _envelope.Timestamp; _envelope.TraceId = _envelope.TraceId == default ? Guid.NewGuid() : _envelope.TraceId; return _envelope; } } } Example Usage 1. Serialize a MessageEnvelope to JSON var envelope = MessageEnvelope<Reservation> .CreateBuilder() .WithEventType("ReservationExpiry") .WithSourceService("ReservationService") .WithPayload(new Reservation { ReservationId = "res-001", SlotId = "slot-123", ExpiryTime = DateTime.UtcNow }) .Build(); string serialized = envelope.ToJson(); Console.WriteLine($"Serialized Envelope:\n{serialized}"); 2. Deserialize a JSON String to MessageEnvelope string json = "{\"EventType\":\"ReservationExpiry\",\"SourceService\":\"ReservationService\",\"Timestamp\":\"2025-03-25T17:00:00Z\",\"TraceId\":\"8a1db2c2-ec3e-45f7-a3eb-bd9dfb351245\",\"Payload\":{\"ReservationId\":\"res-001\",\"SlotId\":\"slot-123\",\"ExpiryTime\":\"2025-03-25T17:00:00Z\"}}"; var deserializedEnvelope = MessageEnvelope<Reservation>.FromJson(json); Console.WriteLine($"Deserialized EventType: {deserializedEnvelope.EventType}"); Console.WriteLine($"Deserialized Reservation ID: {deserializedEnvelope.Payload.ReservationId}"); Benefits of Serialization Portability: You can transmit envelopes as JSON over APIs, message brokers, or store them in databases. Interoperability: Many systems can parse JSON, making serialized envelopes easy to integrate across platforms. Flexibility: Deserialization lets you reconstruct envelopes when receiving messages. Advantages of System.Text.Json Performance: Faster than Newtonsoft.Json, especially for large-scale applications. Built-in Support: No need for external dependencies; it’s natively part of .NET Core and .NET 5+. Configuration Options: Flexible JSON options like camel casing, case insensitivity, and indented formatting.

March 15, 2025 · 2 min · Taner