比較兩個 JSON 物件,並找出其中的不同之處

USE [JsonJogDemo]
GO

-- 刪除現有的 Compare_JsonObject 函數
DROP FUNCTION [dbo].[Compare_JsonObject]
GO

-- 設定 SQL Server 選項
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

-- 建立比較 JSON 物件的函數
CREATE FUNCTION [dbo].[Compare_JsonObject]
(@SourceJSON NVARCHAR (MAX), @TargetJSON NVARCHAR (MAX))
RETURNS @returntable TABLE
(
    SideIndicator CHAR(2), -- 比較結果指標: == 表示相等, <- 來源有但目標沒有, -> 目標有但來源沒有, <> 表示值不相等
    TheParent NVARCHAR(2000), -- JSON 物件的父層級
    ThePath NVARCHAR(2000), -- JSON 路徑 (SQL JSON 函數使用)

3342. Find Minimum Time to Reach Last Room II

There is a dungeon with n x m rooms arranged as a grid. You are given a 2D array moveTime of size n x m, where moveTime[i][j] represents the minimum time in seconds when you can start moving to that room. You start from the room (0, 0) at time t = 0 and can move to an adjacent room. Moving between adjacent rooms takes one second for one move and two seconds for the next, alternating between the two. Return the minimum time to reach the room (n - 1, m - 1). Two rooms are adjacent if they share a common wall, either horizontally or vertically.
/**
 * @param {number[][]} moveTime
 * @return {number}
 */
var minTimeToReach = function(moveTime) {
    const n = moveTime.length, m = moveTime[0].length;

    // Distance array initialized with Infinity, representing minimum time to reach each cell
    const d = Array.from({ length: n }, () => Array(m).fill(Infinity));

    // Possible movement directions: up, down, left, right
    const dirs = [
        [1, 0],  // Down
        [-1, 0], // Up
        [0, 1],  // Right
        [0, -1], // Lef

Passenger Issues

### Passenger / Engineyard
- Updating ruby version in EY environment, then deployed
  - EY succeeds but site won't load
  - Passenger log says:
```
passenger Could not spawn process for application /data/FSIWorldwide/current: The application encountered the following error: 
Could not find rails-7.0.8.7 in any of the sources (Bundler::GemNotFound)
```
  - Upon closer look, references previous ruby gem version
#### SOLUTION: kill passenger process and redeploy
- `ps aux | grep passenger`
- Look f

How to checkout a tag in git?

git checkout <tag-name>

# However, note that this puts your repo in a "detached HEAD" state, meaning you're not on a branch, and any new commits won't belong to any branch unless you create one.

Abstração

# Enredo
Abstração em Java é o conceito de ocultar detalhes de implementação e expor apenas as funcionalidades essenciais de um objeto, utilizando classes abstratas e interfaces para definir comportamentos sem especificar como eles são implementados.

## Conceito de Abstração em POO
A Abstração envolve a identificação e a modelagem das características e comportamentos essenciais de um objeto, ignorando os detalhes irrelevantes ou secundários para o contexto em questão. Em essência, a abstração p

Throttle

function throttle(fn, delay) {
  let lastCall = 0;

  return function (...args) {
    const now = new Date().getTime();

    if (now - lastCall >= delay) {
      lastCall = now;
      fn.apply(this, args);
    }
  };
}

3341. Find Minimum Time to Reach Last Room I

There is a dungeon with n x m rooms arranged as a grid. You are given a 2D array moveTime of size n x m, where moveTime[i][j] represents the minimum time in seconds when you can start moving to that room. You start from the room (0, 0) at time t = 0 and can move to an adjacent room. Moving between adjacent rooms takes exactly one second. Return the minimum time to reach the room (n - 1, m - 1). Two rooms are adjacent if they share a common wall, either horizontally or vertically.
/**
 * Finds the minimum time required to reach the bottom-right cell of the grid.
 * Each cell contains a time constraint that dictates the earliest possible arrival.
 *
 * @param {number[][]} moveTime - A 2D array representing the minimum time required 
 *                                to step into each cell.
 * @return {number} - The minimum time required to reach the last cell, or -1 if unreachable.
 */
var minTimeToReach = function(moveTime) {
    const rows = moveTime.length;
    const co

CSSで楕円のスムージング

<div class="radius">Squircle</div>

Instalador Windows 10 PRO

Al montar el instalador de windows en un USB con la herramienta oficial NO da opción a seleccionar qué tipo de versión instalar (Home/PRO/...) Hay que añadir un determinado archivo plano, con cierta extensón -importante que no se guarde como .txt- dentro de /sources
[Channel]
Retail

Convert "string" to boolean

<?php

// via https://stackoverflow.com/a/15075609

This method was posted by @lauthiamkok in the comments. I'm posting it here as an answer to call more attention to it.

Depending on your needs, you should consider using filter_var() with the FILTER_VALIDATE_BOOLEAN flag.

filter_var(      true, FILTER_VALIDATE_BOOLEAN); // true
filter_var(    'true', FILTER_VALIDATE_BOOLEAN); // true
filter_var(         1, FILTER_VALIDATE_BOOLEAN); // true
filter_var(       '1', FILTER_VALIDATE_BOOLEAN); // t

join_that_multiplies_records

https://stackoverflow.com/questions/55147656/why-am-i-having-so-many-records-after-a-join
TableA
Number, Text
----
1, Hello
1, There
1, World


TableB
Number, Text
----
1, Foo
1, Bar
1, Baz

SELECT * FROM TableA a INNER JOIN TableB b ON a.Number = b.Number

a.Number, a.Text, b.Number, b.Text
----------------------------------
1, Hello, 1, Foo
1, Hello, 1, Bar
1, Hello, 1, Baz
1, There, 1, Foo
1, There, 1, Bar
1, There, 1, Baz
1, World, 1, Foo
1, World, 1, Bar
1, World

1920. Build Array from Permutation

Given a zero-based permutation nums (0-indexed), build an array ans of the same length where ans[i] = nums[nums[i]] for each 0 <= i < nums.length and return it. A zero-based permutation nums is an array of distinct integers from 0 to nums.length - 1 (inclusive).
/**
 * @param {number[]} nums
 * @return {number[]}
 */
var buildArray = function(nums) {
    let ans = []; // Initialize an empty array to store the result

    // Iterate through each index in the `nums` array
    for (let i = 0; i < nums.length; i++) {
        ans.push(nums[nums[i]]); // Push the element from `nums` at the index specified by `nums[i]`
    }

    return ans; // Return the resulting array
};

TSQL compare index usage to snapshot

select 
    stats.Table_name,
    stats.Index_name,
    stats.user_seeks,
    i.seeks as snapshot_seeks,
    stats.user_seeks - i.seeks as diff_seeks,
    stats.user_scans,
    i.scans as snapshot_scans,
    stats.user_scans - i.scans as diff_scans,
    stats.user_updates,
    i.updates as snapshot_updates,
    stats.user_updates - i.updates as diff_updates
from (
SELECT
    objects.name AS Table_name,
    indexes.name AS Index_name,
    dm_db_index_usage_stats.user_seeks,
    dm_db_index_usage_

TSQL snapshot index usage stats

insert into index_usage (tableName, indexName, seeks, scans, updates) 
SELECT
    objects.name AS Table_name,
    indexes.name AS Index_name,
    dm_db_index_usage_stats.user_seeks,
    dm_db_index_usage_stats.user_scans,
    dm_db_index_usage_stats.user_updates
FROM
    sys.dm_db_index_usage_stats
        INNER JOIN sys.objects ON dm_db_index_usage_stats.OBJECT_ID = objects.OBJECT_ID
        INNER JOIN sys.indexes ON indexes.index_id = dm_db_index_usage_stats.index_id AND dm_db_index_usage_stat

Share data among browser tabs

/*
  https://javascript.plainenglish.io/3-powerful-ways-to-share-data-across-browser-tabs-in-javascript-a6a98dffa1a3
*/

// 1. local storage
// Sender
localStorage.setItem('sharedData', JSON.stringify({
  message: 'Hello from Tab1!',
  timestamp: Date.now()
}));

// Receiver
window.addEventListener('storage', (e) => {
  if(e.key === 'sharedData') {
    const data = JSON.parse(e.newValue);
    console.log('Received data:', data);
  }
});


// 2.  BroadcastChannel API 
// Create a channel (use the