Skip to content

Instantly share code, notes, and snippets.

@patzu
patzu / gist:10799f44bdc49503f29c57116b755c37
Created September 20, 2025 15:49
difference between Git Merge and Git Rebase?
Merge
Think of merge as combining two storylines into one new chapter.
When you git merge feature into main, Git creates a new commit (a “merge commit”) that has two parents: one from main, one from feature.
The history is preserved as a branching tree. You can clearly see that feature branched off and then came back.
Pros: keeps the full history and context of how development actually happened.

Below is the step-by-step tutorial for managing a forked repository using generic names: "some-api" for the original repository and "my-private-repo" for your private repository.


Step-by-Step Tutorial for Managing a Forked Repository

Step 1: Clone the Original Repository

First, you need to clone the original repository to your local machine.

@patzu
patzu / lambda_and_functional_interface.md
Created May 29, 2024 13:16
What are Lambda Expressions and Functional Interfaces in Java 8?

Lambda expressions and functional interfaces are two key features introduced in Java 8 to support functional programming paradigms. Let's explore each of these concepts:

Lambda Expressions

Lambda expressions provide a concise way to represent anonymous functions or blocks of code as instances of functional interfaces. They enable you to treat functionality as a method argument or create small, anonymous functions.

Example:

@patzu
patzu / count_occurrences_in_map.md
Created May 29, 2024 07:01
How can I count the occurrences of values in a map containing integers and names?

To count the occurrences of values in a map containing integers and names, you can employ the following Java approach:

import java.util.HashMap;
import java.util.Map;

public class Main {
    public static void main(String[] args) {
        // Create a map with integer keys and string values
@patzu
patzu / datastructures_vs_collections.md
Created May 28, 2024 20:24
Difference between Data Structures and Collections Framework?

Difference between Data Structures and Collections Framework

  1. Data Structures:

    • Data structures are fundamental concepts in computer science and programming that organize and store data in a specific way to facilitate efficient operations such as insertion, deletion, searching, and sorting.
    • They define the logical relationship between data elements and the operations that can be performed on them. Examples of data structures include arrays, linked lists, stacks, queues, trees, graphs, and hash tables.
    • Data structures can be implemented in various programming languages, and their efficiency often depends on factors such as the specific use case, the size of the data, and the operations performed on it.
  2. Collections Framework:

    • The Collections Framework in Java is a set of classes and interfaces provided by the Java API to represent and manipulate collections of objects.
  • Collections in Java are containers that group multiple elements into a single unit. The framework prov
@patzu
patzu / synchronizedMapVSConcurrentHashMap.md
Last active May 28, 2024 20:25
What are the performance differences between using Collections.synchronizedMap(HashMap) and ConcurrentHashMap in Java?

What are the performance differences between using Collections.synchronizedMap(HashMap) and ConcurrentHashMap in Java?

  1. Collections.synchronizedMap(Map):

    • This method returns a synchronized (thread-safe) map backed by the specified map. It achieves thread safety by synchronizing all access to the backing map.
    • Performance-wise, while it provides thread safety, it can suffer from performance bottlenecks under high concurrency because it uses a single lock for all operations, potentially leading to contention among threads.
    • It's suitable for situations where you need thread safety with relatively low concurrency or where you need to use legacy code that expects a Map interface.
  2. ConcurrentHashMap:

    • This class is designed for high-concurrency scenarios. It provides thread safety without a significant performance penalty by using a different approach than Collections.synchronizedMap.
  • It achieves thread safety by dividing the map into segments, each of which can be locked
@patzu
patzu / data consistency vs integrity.md
Created May 23, 2024 13:28
what is the difference between data consistency and integrity in database?

Data consistency and integrity are essential aspects of database management, particularly in systems like core banking where accuracy and reliability are critical.

Data Consistency: Data consistency refers to the correctness, validity, and reliability of data stored in a database. In other words, it ensures that data remains accurate and valid throughout its lifecycle, despite any changes or operations performed on it. Consistency guarantees that the data meets all specified constraints, rules, and standards set by the database schema.

For example, in a core banking system, consider a scenario where a customer transfers money from one account to another. Data consistency ensures that the transaction is processed accurately and that the balances of both the sender's and receiver's accounts are updated correctly. If, due to a system error or failure, the transaction is only partially completed, data consistency mechanisms would ensure that the database is restored to a consistent state, either by completi

@patzu
patzu / dirty-checking-transactions-acid.md
Created May 23, 2024 13:20
A comprehensive tutorial exploring the integration of dirty checking with transactions and ACID principles in Hibernate and Spring applications.

Mastering Dirty Checking, Transactions, and Data Integrity with Hibernate and Spring

Introduction:

In this tutorial, we'll delve deep into the concepts of dirty checking, transactions, and data integrity in Hibernate and Spring. We'll explore how these mechanisms work together to ensure the reliability and consistency of database operations, especially in the context of concurrent transactions.

Section 1: Understanding Dirty Checking

@patzu
patzu / isolation-levels-in-databases-with-spring-boot.md
Created May 23, 2024 12:41
Understanding Isolation Levels in Databases with Spring Boot

Understanding Isolation Levels in Databases

Introduction: Isolation levels in databases determine how transactions interact with each other when accessing and modifying data concurrently. Different isolation levels provide different levels of consistency and concurrency control. In this tutorial, we'll explore four common isolation levels: Read Uncommitted, Read Committed, Repeatable Read, and Serializable. We'll discuss each level, provide examples, and clarify any ambiguities.


1. What are Isolation Levels?

Isolation levels define the degree to which transactions are isolated from each other's effects when accessing and modifying data concurrently in a database.

@patzu
patzu / intellij_default_branch_fix.md
Last active May 22, 2024 13:16
Solution to set default branch name to 'main' instead of 'master' in IntelliJ IDEA when creating a new Git repository.

When Git was first created by Linus Torvalds in 2005, the default branch name was simply "master". This convention was widely adopted across various Git repositories and became a standard practice in many version control systems. However, as awareness grew around the potentially exclusionary or loaded nature of certain terms like "master" and "slave", there has been a shift in recent years towards more neutral or inclusive language.

The naming convention for default branches in version control systems like Git has garnered attention recently due to its historical connotations and the push for more inclusive language in the tech industry. While it's possible that different software teams have their own reasons for sticking with certain defaults, such as familiarity or compatibility with existing systems, it's also true that changes in industry standards and community feedback can influence these decisions over time.

Whether it's a "battle" or simply a matter of inertia and differing priorities might depend o