Skip to content

Instantly share code, notes, and snippets.

View sandeepkv93's full-sized avatar

Sandeep Vishnu sandeepkv93

View GitHub Profile

✅ 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

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

@sandeepkv93
sandeepkv93 / maven-google-java-format-guide.md
Last active January 29, 2025 20:19
Automated Java Code Formatting with Maven using google-java-format

Automated Java Code Formatting with Maven using google-java-format

This guide explains how to set up automated code formatting in a Java Maven project using Google's Java code formatter via the fmt-maven-plugin.

Overview

The setup combines two key components:

  • Google Java Format (google-java-format): Google's Java code formatter that enforces Google Java Style
  • Spotify's fmt-maven-plugin: A Maven plugin that integrates google-java-format into the Maven build lifecycle
@sandeepkv93
sandeepkv93 / Setup-Guide.md
Created September 6, 2024 01:18
Software Engineer's Mac Setup Guide

Software Engineer's Mac Setup Guide for 2021 Intel-based Mac

Essential Software and Tools

  1. Xcode Command Line Tools
  2. Homebrew
  3. iTerm2
  4. Zsh and Oh My Zsh
  5. Powerlevel10k
  6. Python 3
@sandeepkv93
sandeepkv93 / settings.json
Created December 6, 2023 10:56
VSCode User Settings
{
"workbench.startupEditor": "newUntitledFile",
"editor.suggestSelection": "first",
"editor.rulers": [160],
"files.exclude": {
"**/.classpath": true,
"**/.project": true,
"**/.settings": true,
"**/.factorypath": true
},
@sandeepkv93
sandeepkv93 / RESTvsGraphQLvsGRPC.md
Last active August 4, 2023 12:31
When to use REST, GraphQL and gRPC?

REST (Representational State Transfer)

REST is a standard for designing networked applications. It uses HTTP methods to implement the concept of CRUD (Create, Read, Update, Delete).

When to use REST:

  1. Public APIs for third-party developers : REST is widely adopted and understood by many developers, making it a good choice for public APIs.
  2. Microservices with HTTP/JSON : If your microservices are lightweight and primarily use HTTP/JSON, REST can be a good choice.
  3. Stateless operations : REST is stateless, meaning each HTTP request happens in complete isolation. When the client makes an HTTP request, it includes all information necessary for the server to fulfill that request.
  4. Cacheable data : If your application serves data that can be cached to improve performance, REST can be a good choice because HTTP supports caching out of the box.
  5. Web applications : REST is a good fit for web applications, especially when combined with JavaScript frameworks like Angular or Reac
@sandeepkv93
sandeepkv93 / yt-dlp.md
Created October 30, 2022 16:19
Download a Youtube Playlist using yt-dlp with numbering prefix on each videos
.\yt-dlp.exe --cookies .\youtube.com_cookies.txt -f "mp4" -o "%(playlist_index)s-%(title)s.%(ext)s"
@sandeepkv93
sandeepkv93 / windows-invm-notification.ps1
Created May 7, 2020 05:04
Windows Powershell script for InVM Notification using Azure Metadata Service
# 1. RDP into the VM
# 2. Open PowerShell in Administrator Mode.
# 3. Run the command ‘Set-ExecutionPolicy Unrestricted’.
# 4. Create a powershell script called ‘windows-invm-notification.ps1’ and copy the following content in the file.
DO
{
Invoke-WebRequest http://169.254.169.254/metadata/scheduledevents?api-version=2019-01-01 -H @{"Metadata"="true"};
Start-sleep -Seconds 2;
} While ($true)
@sandeepkv93
sandeepkv93 / invm-notification.sh
Last active May 7, 2020 02:18
Azure Invm Scheduled Events notification for Linux VMs
#!/bin/bash
while true
do
echo " Press [CTRL+C] to stop.."
curl -H Metadata:true "http://169.254.169.254/metadata/scheduledevents?api-version=2019-01-01"
sleep 2
done

Pull a docker image

docker pull <image_name>

Run a docker image with a start command

docker run -it <image_id> commad
example: docker run -it <image_id> /bin/bash