| Ko

Managing pull requests with the GitHub CLI

Opening a PR, waiting on CI, reviewing, and merging usually bounces you across several browser tabs. The GitHub CLI (gh) handles the whole process from the terminal. Install instructions vary by OS, so follow the official guide (brew install gh on macOS, sudo apt install gh on Ubuntu/Debian). After installing, authenticate once. gh auth login Browser-based OAuth is the simplest choice. Confirm it worked with the following. $ gh auth status github.com ✓ Logged in to github.com account in-jun (keyring) - Active account: true - Git operations protocol: https - Token scopes: 'gist', 'read:org', 'repo', 'workflow' 1. Create the PR First, branch and push your work. ...

July 19, 2024 · 4 min · 850 words · In-Jun

Cleaning up Git commit history

Building a single feature locally leaves a history like this: f16a902 Add logout feature fbfb5b2 Fix login button style 6cc4fec Add missing import cacd382 Fix typo in login 0559677 Add login feature Fix typo, Add missing import, and Fix login button style all belong inside Add login feature. Committing often while you work is fine: nothing gets lost and you have plenty of rollback points. But pushing it as-is forces your reviewer to read four meaningless commits. ...

July 13, 2024 · 4 min · 758 words · In-Jun

Deleting merged Git branches

Once a PR is merged, the local branch behind it is dead weight. After a few months git branch scrolls past a screenful and you can’t find the branch you’re working on. The commands to clean this up are simple. The point is knowing what’s safe to delete. -d is safe, -D is dangerous There are two ways to delete a local branch. git branch -d deletes only branches that are already merged. If unmerged commits remain, it refuses. ...

July 11, 2024 · 4 min · 657 words · In-Jun

The Floyd–Warshall algorithm

Most shortest-path algorithms solve for distances from one vertex to the rest. Dijkstra and Bellman-Ford both start from a single source. For distances from every vertex to every other vertex, you could run Dijkstra V times, but that rebuilds the priority queue and adjacency list each time, and it fails entirely if any edge is negative. Floyd-Warshall does not fix a source. It puts down a single distance matrix and runs one triple loop, and when it finishes the shortest distance for every pair is in the matrix. The code is twelve lines, it handles negative edges, and it reports whether a negative cycle exists. ...

June 17, 2024 · 8 min · 1612 words · In-Jun

JPA dirty checking

Load an entity, call a setter, end the transaction, and the row in the database changes. No save(), no update(). The mechanism behind that automatic UPDATE is dirty checking. The core of it is how Hibernate knows which fields changed and what it compares against. The snapshot The baseline for the comparison is the snapshot. The moment an entity enters the persistence context, Hibernate copies all of its field values and stores them separately. That copy is the initial state that matches the database. Internally it’s keyed by the entity identifier, with an Object array holding each field value in order as the value. ...

June 8, 2024 · 5 min · 967 words · In-Jun

The JPA N+1 query problem

You fetch a list of members once, then look at the SQL log and find 101 SELECT lines. That’s the N+1 problem. One initial query to fetch the entities, plus N more, one each time you touch the association, for a total of N+1. The signal here isn’t an estimated millisecond count; it’s the number of queries in the log. How one becomes 101 Say Member references Team with lazy loading (FetchType.LAZY). You fetch 100 members and print each one’s team name in a loop. ...

June 8, 2024 · 5 min · 885 words · In-Jun

Spring Data JPA vs JPA

JPA is the standard API. Spring Data JPA is a code-generation layer on top of it: you declare an interface, it generates the implementation, and that implementation calls the EntityManager underneath. Writing the same operation both ways makes the boundary clear. JPA The center of JPA is the persistence context and the EntityManager that manages it. The persistence context is a logical space that holds entities and provides the first-level cache, dirty checking, lazy loading, and write-behind. In plain JPA, you hold the EntityManager and open and close the transaction yourself. ...

June 7, 2024 · 5 min · 853 words · In-Jun

Spring interceptors

What sets an interceptor apart from a filter is position. An interceptor runs inside the DispatcherServlet, after handler mapping has decided which controller handles the request. So an interceptor already knows which handler is about to run. It intercepts that execution at three points (before the controller, after the controller, after view rendering), and at the first point it can block the request entirely. The three hooks HandlerInterceptor provides three methods, each intercepting a different moment. ...

June 4, 2024 · 4 min · 831 words · In-Jun

Servlet filters

A filter is the first thing to touch a request. There’s no DispatcherServlet, no controller, no Spring bean yet, because a filter runs at the servlet container (Tomcat and friends) level. That position defines what a filter is for, and it explains why CORS handling and security token validation live in filters rather than interceptors. Servlet A Java server-side component that processes client HTTP requests and generates responses. It’s a core technology of the Java EE (now Jakarta EE) standard and the foundation of most Java web frameworks. ...

June 4, 2024 · 5 min · 916 words · In-Jun

Web Authentication with Cookies, Sessions, and JWT

Web authentication solves a basic problem created by HTTP’s stateless nature: how a server can recognize the same user across multiple requests. Since Lou Montulli of Netscape Communications invented cookies in 1994, authentication has evolved from session-based approaches to token-based ones. Modern web applications widely use hybrid methods that combine JWT and Refresh Tokens to meet both security and scalability requirements. Understanding Authentication and Authorization The Difference Between Authentication and Authorization ...

June 2, 2024 · 11 min · 2300 words · In-Jun
[email protected]