git worktree add <path> <branch> # Create worktree for a branch that already exists in the repo
git worktree add -b <new-branch> <path> # Create worktree with new branch
git worktree list # List all worktrees
git worktree remove <path> # Remove a worktreeThe Null Object pattern replaces null return values with a special "do-nothing" object
that shares the same interface as the real object. This eliminates the need for null checks
at every call site and prevents "Call to a member function on null" fatal errors.
A collection of dev notes and Q&A on web development topics.
| File | Topic |
|---|---|
| Git-conventional-commits.md | Conventional Commits — feat, fix, and friends |
| JS-worklets-vs-main-thread.md | Worklets vs Main Thread |
| Tool-copilot-edit-vs-plan-vs-agent.md | GitHub Copilot Modes — Edit vs Plan vs Agent |
| Web-chrome-third-party-cookies.md | Chrome & Third-Party Cookies (2025) |
| Web-storage-comparison.md | sessionStorage vs localStorage vs Cache Storage vs Shared Storage |
A Pen by davidon dan on CodePen.
A Pen by davidon dan on CodePen.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System.IO; | |
| using System; | |
| class Solution { | |
| // Complete the hourglassSum function below. | |
| static int hourglassSum(int[][] arr) { | |
| int[] sum = new int[16]; | |
| int k = 0; | |
| for (int i = 0; i <= 3; i++) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public function format_phone_number($S) { | |
| $S = str_replace(' ', '', $S); | |
| $S = str_replace('-', '', $S); | |
| $len = strlen($S); | |
| $num_groups = floor($len / 3); | |
| $remain = $len % 3; | |
| if ($num_groups >= 1 && $remain == 1) { | |
| $num_groups -= 1; | |
| $remain += 3; //4 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include "pch.h" | |
| #include <iostream> | |
| #include <algorithm> | |
| #include <string> | |
| #include <vector> | |
| #include <time.h> | |
| using namespace std; | |
| int get_max_profit(vector<int> prices); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| //this is to get the max gap in an array supposing gap can only be a later number minus a former number | |
| $stock_prices_yesterday = [25, 7, 5, 8, 11, 9]; | |
| $m_profit = GetMaxProfit($stock_prices_yesterday); | |
| # returns 6 (buying for $5 and selling for $11) | |
| print "1st:the most profit should be 6: {$m_profit}"; | |
| $stock_prices_yesterday = [10, 7, 11, 5, 8, 9]; | |
| $m_profit = GetMaxProfit($stock_prices_yesterday); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| // you can write to stdout for debugging purposes, e.g. | |
| // print "this is a debug message\n"; | |
| function solution($A) { | |
| // write your code in PHP7.0 | |
| $arr_checker = range(1, 100000); | |
| $A = array_unique($A, SORT_NUMERIC ); | |
| sort($A); |
NewerOlder