Skip to content

Instantly share code, notes, and snippets.

View sandeepkv93's full-sized avatar

Sandeep Vishnu sandeepkv93

View GitHub Profile

Advanced HashMap Methods in Java - Use Cases & Examples

1. getOrDefault(K key, V defaultValue)

Use Cases:

  • Counting occurrences efficiently.
  • Handling missing keys.
  • Providing default responses.

Example: Word Frequency Counter

✅ Use Case: Apply Only Top Commit from a Branch on Top of main

🎯 Goal

From a feature branch, apply only the latest commit on top of the latest main branch — and discard all earlier commits in that branch.


📌 Assumptions

✨ Move Top Commit to Stash and Rebase on Latest main

This guide shows how to take the top commit from your current branch, temporarily stash it, update your branch to match the latest main, and then re-apply the stashed changes.


🔧 Use Case

You’ve made one local commit on a feature branch but later realize you want that commit to apply on top of the latest main instead. Rather than rebasing or cherry-picking, you want to:

@sandeepkv93
sandeepkv93 / cleanup_sensitive_files.md
Created July 12, 2025 01:26
Remove File from All Git Commits

Complete Guide: Remove File from All Git Commits

This guide shows how to permanently delete a file from all commits in a Git repository, including its entire history.

Prerequisites

  • Git installed
  • Python 3.x installed (for git-filter-repo)
  • Administrator/owner access to the repository
@sandeepkv93
sandeepkv93 / graphite-cli-guide.md
Created July 14, 2025 14:06
Graphite CLI for Stacked Pull Requests - Complete Guide
@sandeepkv93
sandeepkv93 / python3-leetcode-wiki.md
Created October 27, 2025 02:03
Python3 LeetCode Complete Wiki