Skip to content

Instantly share code, notes, and snippets.

View ashutoshkrris's full-sized avatar
🏠
Learning from home

Ashutosh Krishna ashutoshkrris

🏠
Learning from home
View GitHub Profile
@ashutoshkrris
ashutoshkrris / state-vs-pkce.md
Created July 29, 2026 17:10
State Parameter vs. PKCE (code_verifier) — A concise comparison of how the OAuth 2.0 state parameter and PKCE protect against different attacks, their security purpose, and where each is validated.
Property state Parameter PKCE (code_verifier)
Primary Threat Login CSRF: An attacker tricks a victim into completing an OAuth flow using the attacker's authorization code. Code Interception: An attacker steals a victim's authorization code and exchanges it for a token.
How It Protects Binds the authorization callback to the user's specific browser session. Proves that the entity exchanging the code is the same entity that requested it.
Validation Point Checked by the Client Application Backend upon
@ashutoshkrris
ashutoshkrris / access-token-vs-refresh-token.md
Created July 29, 2026 17:08
Access Token vs. Refresh Token — A concise comparison of their purpose, lifetime, usage, and storage security in OAuth 2.0 authentication.
Feature Access Token Refresh Token
Primary Purpose Used to access protected APIs Used to obtain new access tokens
Lifetime Very short (15 minutes to 1 hour) Long-lived (days, months, or until revoked)
Sent Where? Sent with every API call to the Resource Server Sent only to the Authorization Server's token endpoint
Storage Security Can be kept in temporary server memory Must be stored encrypted in secure storage
@ashutoshkrris
ashutoshkrris / comparison.md
Created July 11, 2026 06:40
QUERY vs GET vs POST
Architectural Property GET POST QUERY
Request Body Allowed No (Undefined Semantics) Yes Yes
Safe (Read-Only) Yes Potentially No Yes
Idempotent (Safe to Retry) Yes Potentially No Yes
Default Cacheable Yes No (Only future GET/HEAD) Yes (Requires Body-Aware Keying)
Data Payload Location URL Query String Request Body Request Body
Primary Use Case Simple, short resource reads Resour
@ashutoshkrris
ashutoshkrris / Difference between Value and ConfigurationProperties.md
Created November 20, 2025 15:48
This Gist compares Spring Boot’s @value and @ConfigurationProperties annotations. It highlights their strengths, limitations, and ideal use cases. Use this as a quick reference to choose the right approach when binding configuration values in your Spring Boot applications.
Feature @Value @ConfigurationProperties
Best for Single values Grouped or structured properties
Type safety Limited Strong (binds directly to fields)
Supports validation No Yes
Preferred for large configs
@ashutoshkrris
ashutoshkrris / Priority Order.md
Created November 20, 2025 15:37
This Gist shows the priority order of how the @value annotation in Spring Boot works when injecting configuration values. The list is organized from the highest to lowest priority, covering sources like command-line arguments, system properties, environment variables, application property files, and more. Understanding this order is crucial for …
Priority Source Example / Notes
1 Command-line arguments e.g. --my.property=value when running the application
2 Java System properties e.g. -Dmy.property=value
3 OS environment variables e.g. export MY_PROPERTY=value
4 Application properties or YAML files Located in src/main/resources/application.properties or .yml
5 Profile-specific configuration files e.g. application-dev.properties when spring.profiles.active=dev
6 External configuration files Files located in a /config directory outside the packaged JAR
7 JNDI attributes Used in servlet containers or enterprise environments
@ashutoshkrris
ashutoshkrris / YouTube_Playlist_Downloader.md
Last active August 27, 2025 14:46
Download all videos from YouTube Playlist in all supported resolutions (including 1080p and 4K)
  • Using this script, you can download all the videos from a YouTube Playlist in all supported resolutions (including 1080p and 2160p).
  • Enter the playlist url and the resolution you wish to download.
  • Install the required libraries: pytubefix, tqdm, tenacity
  • Make sure you have ffmpeg setup on your machine. Check the tutorial for the setup guide.
  • You can download the videos in the following resolutions: 144p, 240p, 360p, 480p, 720p, 1080p, 1440p, 2160p
  • Check the video for available resolutions.
import csv
import json
from bs4 import BeautifulSoup
from selenium import webdriver
BROWSER = webdriver.Chrome(executable_path="chromedriver.exe")
TOTAL_PERSONS = 100
import json
def write_to_json(data: dict) -> None:
data_list = []
for i in range(TOTAL_PERSONS):
temp = {
"Rank": data["ranks"][i],
"Name": data["names"][i],
"Link": f"https://www.bloomberg.com/billionaires/{data['links'][i]}",
"Total net worth($)": data["worths"][i],
import csv
def write_to_csv(data: dict) -> None:
columns = ['Rank', 'Name', 'Link',
'Total net worth($)', '$ Last change', '$ YTD change', 'Country/Region', 'Industry']
with open(f"top-{TOTAL_PERSONS}-persons.csv", "w", newline="") as csv_file:
writer = csv.DictWriter(csv_file, fieldnames=columns)
writer.writeheader()
for i in range(TOTAL_PERSONS):
temp = {
import csv
import json
from bs4 import BeautifulSoup
from selenium import webdriver
BROWSER = webdriver.Chrome(executable_path="chromedriver.exe")
TOTAL_PERSONS = 100