The Parallel of A.I. Fear and Automobile Fear

Folks who fear AI, are usually from the Fundamentalist (not very smart folks because ignorance of God's general revelation) church. Their argument is not different than folks who argue against cars back in the days:

These folks never learn from history. What were the common fear when Automobile first came around, having to transition from horse chariots to cars?

Google Gemini said:
The transition from "horse power" to the internal combustion engine was far from smooth. While we now see the early 20th century as a time of exciting progress, many people at the time viewed the automobile with genuine terror, suspicion, and deep moral concern.

Here were the most common fears and anxieties when cars first appeared on the streets:

  1. The Loss of "Horse Intelligence"
    One of the most profound fears was the loss of the horse’s own brain. People argued that a horse provided a "second intelligence" on the road. A horse wouldn't knowingly walk off a cliff, stumble into a deep ditch, or collide with another animal.

The Fear: Without a horse to act as a "natural cruise control," people feared that human drivers were too fallible to handle a machine that had no instincts of its own.

The Habit: Early drivers were famously known to yell "Whoa!" or "Stop!" at their cars during a panic, forgetting that a machine required a physical brake rather than a verbal command.

  1. "Speed Madness" and Safety
    In the late 1800s, the world moved at about 10–15 mph (the speed of a trotting horse). When cars began reaching 25 or 30 mph, it was seen as a reckless, life-threatening pace.

The "Devil Wagon": Cars were often called "devil wagons" because they moved without any visible means of propulsion, which felt supernatural or "ungodly" to some.

Danger to Children: Since streets were previously a shared space where children played and pedestrians walked freely, the sudden arrival of fast, heavy machines led to a high number of fatalities, sparking "Anti-Automobile" riots in cities like New York and Cincinnati.

  1. The "Red Flag" and "Blanket" Laws
    The fear was so high that governments passed "Red Flag Acts."

Manual Warning: In some parts of the UK and the US, a car was legally required to have a person walking 60 yards ahead of it waving a red flag to warn pedestrians and horse-riders of the "danger" approaching.

The Pennsylvania Law: One proposed (though possibly apocryphal or short-lived) law in Pennsylvania required a motorist who saw a horse coming to pull over and cover their car with a canvas blanket that blended into the scenery. If the horse still seemed scared, the driver was supposed to take the car apart, piece by piece, and hide the components in the bushes until the horse passed.

  1. Economic and Social Displacement
    Entire industries were built around the horse: blacksmiths, stable hands, carriage makers, and "buggy whip" manufacturers.

Job Loss: There was a massive fear that the "horseless carriage" would bankrupt the working class.

Elitism: For the first decade, cars were toys for the ultra-wealthy. Farmers and rural residents often saw them as "arrogant" machines that tore up dirt roads, scared their livestock, and provided no practical use for a working man.

  1. Environmental and Sensory Assault
    We often think of cars as the original polluters, but at the time, cars were marketed as the "Green" solution.

Manure vs. Smoke: In 1898, the first international urban planning conference in NYC was canceled early because no one could figure out what to do about the 2.5 million pounds of horse manure dropped on city streets every day.

The New Fears: Despite the manure solution, people hated the "mechanical" smell of gasoline and the "infernal" racket of the early engines. The noise was so disruptive that some towns banned cars from operating on Sundays to keep the peace for church services.

  1. Mechanical Unreliability
    Early cars were notoriously unreliable. This led to the famous 1890s-1900s jeer: "Get a horse!"

The Fear of Being Stranded: If a horse got tired, it could rest; if it was hungry, it could graze. If a car ran out of gas or "popped a tire" (which happened constantly on roads filled with horseshoe nails), the driver was completely helpless. People feared being stranded in the wilderness with a "useless pile of iron."

  1. Physical Health Concerns
    Some doctors even hypothesized that the human body wasn't designed to travel at such high speeds. There were concerns that the "vibrations" of the engine would cause internal organ damage or that the "rushing air" at 30 mph would make it impossible for passengers to breathe, leading to "respiratory paralysis."
Posted in News, Theologization | Leave a comment

Journal of the Week

02/21/2026 Saturday

GCC Men's fellowship, led by Vincent, topic's good, which was on "Church Growth" but the content gets sidetracked here and there especially when others chimed in. I have no clue where Frank, who talked the longest (more than 5 mins, while others average to 1.5 minutes) thought he was going with some miracle happening in his life finding a long lost friend. The focus should be on our responsibility rather than the lack of before God. The pastor, Clyde, and even Phil got it right most. Phil's was a little impressive bringing Esther into the picture where her uncle told the queen if she does nothing, God will raise up others to accomplish His plan. That's spot on. But the group does err into the let go and let God false dichotomy: If it's my work, then it's not God's work. So overall, it's is shallow. A fail in understanding active vs. passive. A fail in the understanding of Matthew 5:16 ...let "your" light shine. Not God's light. Focus is on your (plural) light, so it's YOUR work (biblical), through the Spirit (Reformed understanding in Biblical Theology).

Clyde raised an interesting question: So I guess our failure was built into the plan? @36:24
The pastor answered: I mean, we're liable for it. We're wrong in it. We don't say, God wanted me to do wrong. He wanted me to do faithfully. And we have to look back and say, if I was obedient, it would have been better. But even in my failure, he turns it around and I learn this lesson, which I needed.

I would have answered: Failure was not built into the plan, but the correction or discipline of our failure was built into the plan. You can say failure was decreed. But you cannot say failure was built into the plan. Beyond that would just be semantics.

02/18/2026 Wednesday

It's interesting to know from Presbycast that there are more conservative PCA elders who do not approve of removing noisy children from service, having halftime in the middle of service for social activities and announcements, etc. Nothing new to me, I believe these are relative matters to be treated with wisdom, there's no need to absolutize it because the reasons they gave don't always work either: i.e. @44:48 "solemnity can be caught" by children observing their parents, which could also lead to hypocrisy without learning much of God's words, making the pew an idol. I also learned that the Directory for the Publick Worship of God (1647 - Scottish rendition) is Westminster's standard replacement of the Book of Common Prayer, due to the abolishment of Catholicism rituals, but this replacement didn't last long, resulting in the Book of Common Prayer still being used in Anglicanism while the Presbyterians use the Directory for the Publick Worship.

This is also the 2nd time (First from GRII) I heard of Zwingli's people having sausage feast during Lent as a protest (grace vs. work) to Catholicism's Lent fasting:

02/17/2026 Tuesday

Watched this done by Hillsdale College in conjunction with the White House. It's a highlight of Black people's achievements in American history from the Ring Wing perspective. Thanks to Google Gemini, I can always query any youtube talks/lectures by: "Summarize, fact check, comment and critique this:..." Here's an excerpt of what I get from the AI in italic, and its interesting critique regarding Dunmore Proclamation, British freeing slaves in America to fight against Revolutionists:

The core of the presentation highlights four specific Black figures from the Revolutionary era:

  • Prince Estabrook: A slave and minuteman who was the first Black soldier wounded at the Battle of Lexington [02:45].
  • James Armistead Lafayette: A slave turned double agent who gathered critical intelligence from General Cornwallis, leading to the victory at Yorktown [03:26].
  • Phillis Wheatley: The first African American to publish a book of poetry, whose writing "stirred the conscience of patriots" [04:41].
  • Lemuel Haynes: A minuteman and the first Black ordained minister in the U.S., who used his pulpit to argue that slavery was a sin against God [05:49].

Omission of the British "Dunmore Proclamation": A critical historical critique would be that the video does not mention that thousands of Black Americans also fought for the British. Lord Dunmore’s Proclamation promised freedom to any enslaved person who fled their rebel masters to fight for the Crown. This context is often omitted in patriotic narratives but was a major motivator for why Washington eventually allowed Black men to enlist in the Continental Army.

The Dunmore Proclamation, also known as Lord Dunmore's Offer of Emancipation, was a historic and controversial decree issued on November 7, 1775, by John Murray, the 4th Earl of Dunmore and the last Royal Governor of Virginia. It was a pivotal moment in the American Revolutionary War that forced both patriots and the enslaved population to reconsider the meaning of "liberty."

Initially, George Washington (himself an enslaver) had banned Black men from enlisting in the Continental Army. Dunmore's success forced Washington to reverse this policy in 1776 to prevent more people from fleeing to the British side.

Love this quote from SP weekly:

“Where there is no vision, there is no hope.” — George Washington Carver

After watching The Pendragon Cycle series (the Celtic-Christian fantasy-history themed film's not bad) directed by Jeremy Boreing, I was reminded that he was a questionable Christian. So I looked it up and was assured of what was wrong with his faith, so I replied on his self-bio on X:

of course none of it assures your salvation. Only that you're clever, at best. However, it doesn't excuse you from being ashamed to be called Christian in public. The smug mask you put on against "gang slogan" only reminds us why the offices of priest and king were separated.

02/16/2026 Monday

This morning, I went to sleep after sending Nadia to work at 6am. Woke up at around 11am, finding Nadia calling me multiple times with much worry because my phone was on silent since church the day before and I called back. I do feel very heartbroken listening to her worry when she first picked up my callback. She had tried to call everyone including my mother out of worry.

Posted in Faults, Quotes, Theologization | Leave a comment

Geopolitic/Economic Surveys & Reports Worth Noting

I learned most of these from Phoenix TV’s 石評天下 interview with a Pro-China commentator: Shi Qiping (石齊平). Though pro-China (親中反美), I do enjoy listening especially after too much propaganda from left and right from American side of reports. The following reports, though Western, are what the China side is attending to, so they must mean something:

The Carnegie Survey, by the Carnegie Endowment for International Peace 卡内基国际和平基金会

RAND Research

Posted in Economics, Geography | Leave a comment

The Closer I move my Spectacles, the higher the power: Vertex Distance

This drew my attention when I am trying to adjust my prescription from https://vr-rock.com for the RayNeo XR Air 3s Pro I bought recently, for extending my smartphone & computer screens.

The power attached to the XR (or AR?) glasses is naturally too high for me perhaps due to its distance from my eyes. While the center of the lenses offer clarity still but combined with the somewhat higher power of the peripherals, I could certainly use less power. And if I push the glasses slightly away from my eyes for a few mm, then the power decreases and I could see the clarity with better comfort. Less power is always less stressful to cope than too much power.

This change in distance is called vertex distance. So in my myopia (short-sighted) case (not hyperopia/long-sighted), the negative degree becomes more negative as the lenses draw closer to my eyes. And this is the formula for the vertex compensation:


To calculate the new effective power (Fe) of a lens based on a change in distance, use the vertex distance formula:

De = Do/(1 + d(Do))

Where:

De= Effective power (new power)
Do= Original lens power (in diopters)
d = The change in vertex distance in meters (e.g., a 3mm shift is 0.003)

Note on Sign: When the lens moves closer to the eye, d is treated as a positive value in this formula.


And there're calculators online for vertex compensation: https://www.omnicalculator.com/physics/contact-lens-vertex

So in order to not risk harming my eyes, I would have to order another set of these prescription lenses from VR-Rock, which did not disappoint. I'll just have to measure how much distance is adjusted.

RayNeo Air 3s & 3s Pro Prescription Lenses × 1 $64 total:

Prescription Type: With Prescription
Model Selection: RayNeo Air 3s Pro
RIGHT SPH: -8.75 (+ $5.00)
RIGHT CYL: -1.00
RIGHT AXIS: 85°
LEFT SPH: -8.50 (+ $5.00)
LEFT CYL: -0.75
LEFT AXIS: 95°
Lens Upgrade: Anti-Fog(Cost-Free), Oil-Resistant (Cost-Free), Scratch-Resistant (Cost-Free), Easy to Clean (lotus effect) (Cost-Free), Radiation-Resistant (Cost-Free), Anti-Glare (+ $5.00)

Update 3/4/2026: Ordered a second set with lower power for vertex compensation of about 11 mm:

Prescription Type: With Prescription Model Selection: RayNeo Air 3s Pro
RIGHT SPH:-8.00 (+ $5.00)
RIGHT CYL: -0.75
RIGHT AXIS: 85°
LEFT SPH: -7.75 (+ $5.00)
LEFT CYL: -0.50
LEFT AXIS: 95°
PD:63
Lens Upgrade:
Anti-Fog(Cost-Free),
Oil-Resistant (Cost-Free),
Scratch-Resistant (Cost-Free),
Easy to Clean (lotus effect) (Cost-Free),
Radiation-Resistant (Cost-Free),
Anti-Glare (+ $5.00)

Posted in Biology | Leave a comment

Stock Market = Investment

I had an entry called "Stock Market = Gambling" years ago. Now, with AI, I believe I can learn more about the stock market with questions I asked but got no good answers from people before.

Ever since I follow The Rundown Podcast (daily financial news podcast by Public.com), I've gained more interest about it. With the right knowledge, gambling isn't gambling but investment.

Zaid Admani called Trump's focus on the Dow Jones outdated, because it's based on flawed index of 30 companies. Now, we measure the stock market using S&P500 or Nasdaq indexes.

Posted in Economics | Leave a comment

Understanding IP68 vs. IPX8 Water Proof Classes

From Google AI:

IP (Ingress Protection): The standard code defining protection against solids and liquids.

First Digit (0-6): Solid Particle Protection (Dust). A "6" means totally dust-tight.

Second Digit (0-8): Liquid Ingress Protection (Water). An "8" means protection against continuous submersion at a manufacturer-specified depth, usually > 1m.

The "X": If a digit is replaced with X, it means it has not been formally tested for that factor.

IP68 and IPX8 both provide high-level, long-term submersion protection (waterproof beyond 1m), but differ in dust protection. IP68 guarantees both dust-tight resistance (6) and high-level water resistance (8). IPX8 signifies water resistance only (8), as the 'X' means the device was not officially tested or rated for dust protection.

Key Differences: IP68 vs. IPX8

  • Dust Protection: IP68 ensures the device is completely dust-tight ("6"), while IPX8 ("X") does not certify protection against dust or solid particles.
  • Waterproofing Level: Both signify the highest level of submersion, generally lasting more than 30 minutes at depths over 1 meter.
  • Use Cases: IP68 is ideal for devices requiring protection from both sand/dust and water (e.g., smartphones). IPX8 is often found on items specialized only for underwater use (e.g., cameras, certain smartwatches).

Important Nuances

  • Manufacturer Specifics: While both are "8" rated, the exact depth and time (e.g., 1.5m for 30 min vs. 6m for 30 min) vary by manufacturer.
  • Fresh Water: These ratings are generally tested in fresh water, not swimming pools, saltwater, or hot showers.
  • IPX8 Limitation: A device rated IPX8 might be perfectly waterproof but could fail if dust enters the device.
Posted in Technical | Leave a comment

Journal of the Week

02/11/2026 Wednesday

Nadia once said she had problem with Trump saying "I don't like the way you talk" on Apprentice show, now this happens again with Trump with the "prime minister" (Trump's mistaken identity of former Swiss President Karin Keller-Sutter) of Switzerland, which is a funny habit of Trump I suppose. Whether that's really his decision based on a person's attitude in talking is another story:

02/10/2026 Tuesday

When Behind the Pulpit mentioned that Kathy Keller made all of Tim Keller's sermons free online since he passing, Pastor Dave Hentschel gave Tim Keller high praise when he said that "[Tim Keller] was one of the few people ever that I would pay for a sermon.":

02/09/2026 Monday

My SONY NW-WS413 underwater headset does not turn on anymore. USB shows no activity/connection as well. It must have been more than 2 years. It's time. Ordered from Amazon Fanisic 2026 Swimming Bone Conduction (supposedly better than conventional underwater due to slash noise) Headphones Bluetooth & 32GB MP3 player, for $42.64 (returned a more expensive $95.95 VLOP brand of similar headset.)

So it seems that Asian restaurants now are not going to give cash "discount" any more in fear of perhaps the state. But whether it's tariffs, sales taxes, credit card merchant fees, etc. business owners are prone to incur the burden on customers. So the idea that these help consumers are not quite true. At best it discourages businesses that don't want to play along and pass the taxes/fees to the customers with the very small chance that it discourages customers who are aware of this to do business from them in the future. Tariffs only scares customers not to trade with businesses being levied upon with tariffs "penalties", it does not mean the government makes more profit out of business/foreign owners. So next time, if I want to really care about saving 60 cents for a $19 dollar meal, I would have to pay with either cash or debit card. And I cannot get away with sales tax $1.20 no matter what.

02/08/2026 Sunday

Ana Kasparian on the accused Leon Black for sexual assault on a 16-year-old, vetting for death penalty "Watch the pig squeal!" is an example of vengeance justice we don't want to subscribe to, as tempting as it can be:

Self-reflection dialogue after attending various Chinese churches (or English speaking churches with larger Asian population):

Question: By what measure do you call Rev. Laura Lin's CCCNY church and not the other Asian churches here in America anti-gospel?
Answer: By the fact that Rev. Laura Lin associate herself with STEMI's activities and other Stephen Tong's ministry. Stephen Tong's very pro gospel/evangelism, while Rev. Lin is not and at times against it, referring to the "I'm/we're not called for that" argument. Not only the other churches not associate with Stephen Tong the way Rev. Lin does in her "supporting the evangelical ministry" appearance, these churches actually do have their own evangelical activities. So, having the appearance of support but actually not really care about evangelism directly, is a fake support of such ministry, and therefore, anti-Gospel. Gospel supporting is not Gospel centered, so Anti-Gospel centered invalidates Gospel supporting and thus, anti-Gospel itself.

Question: Why do you think that is with Rev. Lin?
Answer: I believe when one cares more about reputation of men than the glory of God, one becomes confused as to who one is truly serving.

Question: Why then do you not talk to Rev. Lin about it in private rather than just judge her so?
Answer: Scripture teaching on such applies to Christians in true fellowship. When you realize the one before you is actually a rapist, do you go talk to him about it in private?

Question: How then can such a "rapist" reconcile with the people of God?
Answer: Should she even care, she must make the first move in good faith and sincerity.

Question: If someone judged you a "rapist", would you have made the first move to reconcile?
Answer: Of course, and I always have. Always make sure they either clarify their judgment or that there's no more good faith communication possible (when they started ghosting you without reason.)

Posted in Dialogues, Economics | Leave a comment

NJTransit - South Amboy to New York Penn.

Now, this direct line ($15.65) is more expensive than breaking the trip up as South Amboy to Rahway ($3.85) & Rahway to New York Penn. Station ($10.90). Whoever design the fare rates here is not very smart.

Holes are punched (not all the time) onto the receipt which then becomes the valuable pass placed on each passenger's seat and is meant to be carried by the passenger at all times during the ride before taken away by the conductor. Some thieves love to steal other people's passes due to this system. The pass color also changes from time to time to avoid copycats. This is the site for the Zones of North Jersey Coast line: https://en.wikipedia.org/wiki/North_Jersey_Coast_Line

I made this (would need to be updated from time to time due to fare changes) Excel spreadsheet (Saved on Backup as "Work\Home\NJTransit North Jersey Coast Line Fares.xlsx") as a guide, Stations: South Amboy, Perth Amboy, Woodbridge, Avenel, Rahway, Linden, Elizabeth, Newark, Secaucus, NY. I then pasted the table from the excel workbook to MS Word in order to be copy pasted onto WordPress here:

SAPAWbAvRwLdEbNwSECNY
SA 2.62.63.553.854.956.4510.6515.6515.65
PA  2.62.63.554.15.99.4514.4514.45
Wb   2.62.62.64.17.6512.712.7
Av    2.62.63.556.4511.511.5
Rw     2.62.65.910.910.9
Ld      2.64.951010
Eb       3.558.58.5
Nw        4.956.15
SEC         4.95
NY15.6517.0515.315.0514.7514.9514.9516.820.6 

Last row NY shows rate comparison according to mid point station. Thus, Rw column is cheapest $14.75.

Even AI (Google Gemini) figured this out, once I fed it this spreadsheet:

Based on the fare data provided in Sheet2, the cheapest way to travel from South Amboy to New York (NY) is by purchasing a combination of two tickets rather than a single direct ticket.

Cheapest Combination:

The most cost-effective route involves splitting your journey at Rahway:

  1. Ticket 1: South Amboy to Rahway — $3.85
  2. Ticket 2: Rahway to NY — $10.90

Total Cost: $14.75

Comparison:

  • Direct Fare: $15.65
  • Savings: $0.90 per trip

By using this combination, you save $0.90 compared to the standard direct fare of $15.65. Other combinations, such as splitting at Elizabeth ($14.95) or Woodbridge ($15.20+), are more expensive than the Rahway split.

Posted in Uncategorized | Leave a comment

My first coding (powershell scripting) using AI: Matching (one to many) list of names from one Excel Spreadsheet with another Spreadsheet and update its rows accordingly

To streamline a routine work at SPG, I used Microsoft Copilot for this. This was the prompt I used:

write a powershell script that takes a list from an excel sheet column, and match every value on that list with another excel sheet to update some values of it in the matching rows.

I was asked to install a new module: Install-Module ImportExcel -Scope CurrentUser

PS: This doesn't update anything on sharepoint. So I actually would need to copy the sharepoint file to PC to be the target file and then I copy paste the PowerShell updated column from the local file to the sharepoint file (not replacing the entire file).

And I got this code from M365 Copilot Chat:


#Requires -Modules ImportExcel

param(
    [Parameter(Mandatory)] [string] $ListFile,
    [Parameter(Mandatory)] [string] $ListSheet,
    [Parameter(Mandatory)] [string] $ListKeyColumn,

    [Parameter(Mandatory)] [string] $TargetFile,
    [Parameter(Mandatory)] [string] $TargetSheet,
    [Parameter(Mandatory)] [string] $TargetKeyColumn
)

# ---- Settings: columns to update in the target (constants) ----
$ConstantUpdates = @{
    "Status"    = "Disabled"
    "UpdatedOn" = (Get-Date).ToString("yyyy-MM-dd")
}

# ---- Safety: create a backup first ----
$backup = "$TargetFile.bak_{0:yyyyMMdd_HHmmss}" -f (Get-Date)
Copy-Item $TargetFile $backup -Force
Write-Host "Backup created: $backup"

# ---- Read list keys ----
$listRows = Import-Excel -Path $ListFile -WorksheetName $ListSheet
if (-not $listRows) { throw "List sheet returned no rows." }

$keys = $listRows |
    ForEach-Object { $_.$ListKeyColumn } |
    Where-Object { $_ -ne $null -and "$_".Trim() -ne "" } |
    ForEach-Object { "$_".Trim() } |
    Select-Object -Unique

if ($keys.Count -eq 0) { throw "No keys found in column '$ListKeyColumn'." }

# Build a fast lookup set (case-insensitive by default)
$keySet = [System.Collections.Generic.HashSet[string]]::new([System.StringComparer]::OrdinalIgnoreCase)
$null = $keys | ForEach-Object { $keySet.Add($_) }

# ---- Open target workbook and update in place ----
$pkg = Open-ExcelPackage -Path $TargetFile
try {
    $ws = $pkg.Workbook.Worksheets[$TargetSheet]
    if (-not $ws) { throw "Target sheet '$TargetSheet' not found in '$TargetFile'." }

    $endRow = $ws.Dimension.End.Row
    $endCol = $ws.Dimension.End.Column

    # Map headers (row 1) to column indexes
    $headerToCol = @{}
    for ($c = 1; $c -le $endCol; $c++) {
        $h = $ws.Cells[1, $c].Text.Trim()
        if ($h) { $headerToCol[$h] = $c }
    }

    if (-not $headerToCol.ContainsKey($TargetKeyColumn)) {
        throw "Target key column '$TargetKeyColumn' not found in header row."
    }

    # Ensure update columns exist
    foreach ($colName in $ConstantUpdates.Keys) {
        if (-not $headerToCol.ContainsKey($colName)) {
            throw "Update column '$colName' not found in target header row."
        }
    }

    $keyColIndex = $headerToCol[$TargetKeyColumn]

    $matched = 0
    $updated = 0

    for ($r = 2; $r -le $endRow; $r++) {
        $key = $ws.Cells[$r, $keyColIndex].Text.Trim()
        if (-not $key) { continue }

        if ($keySet.Contains($key)) {
            $matched++

            foreach ($colName in $ConstantUpdates.Keys) {
                $colIndex = $headerToCol[$colName]
                $newValue = $ConstantUpdates[$colName]

                # Only write if different
                $current = $ws.Cells[$r, $colIndex].Text
                if ($current -ne "$newValue") {
                    $ws.Cells[$r, $colIndex].Value = $newValue
                    $updated++
                }
            }
        }
    }

    Close-ExcelPackage -ExcelPackage $pkg -Save

    Write-Host "Matches found: $matched"
    Write-Host "Cells updated: $updated"
}
catch {
    # If anything fails, close without saving to avoid partial writes
    Close-ExcelPackage -ExcelPackage $pkg -NoSave
    throw
}

And I only needed to made a few modifications:


#Requires -Modules ImportExcel

$ListFile = "C:\Users\original.xlsx"
$ListSheet = "sheet1"
$ListKeyColumn = "User principal name"

$TargetFile = "C:\Users\target.xlsx"
$TargetSheet = "Users"
$TargetKeyColumn = "Email"



# ---- Settings: columns to update in the target (constants) ----
$ConstantUpdates = @{
    # "Status"    = "Disabled"
    "DOT" = (Get-Date).ToString("d")
}

# ---- Safety: create a backup first ----
#$backup = "$TargetFile.bak_{0:yyyyMMdd_HHmmss}" -f (Get-Date)
#Copy-Item $TargetFile $backup -Force
#Write-Host "Backup created: $backup"

# ---- Read list keys ----
$listRows = Import-Excel -Path $ListFile -WorksheetName $ListSheet
if (-not $listRows) { throw "List sheet returned no rows." }

$keys = $listRows |
    ForEach-Object { $_.$ListKeyColumn } |
    Where-Object { $_ -ne $null -and "$_".Trim() -ne "" } |
    ForEach-Object { "$_".Trim() } |
    Select-Object -Unique

if ($keys.Count -eq 0) { throw "No keys found in column '$ListKeyColumn'." }

# Build a fast lookup set (case-insensitive by default)
$keySet = [System.Collections.Generic.HashSet[string]]::new([System.StringComparer]::OrdinalIgnoreCase)
$null = $keys | ForEach-Object { $keySet.Add($_) }

# ---- Open target workbook and update in place ----
$pkg = Open-ExcelPackage -Path $TargetFile
try {
    $ws = $pkg.Workbook.Worksheets[$TargetSheet]
    if (-not $ws) { throw "Target sheet '$TargetSheet' not found in '$TargetFile'." }

    $endRow = $ws.Dimension.End.Row
    $endCol = $ws.Dimension.End.Column

    # Map headers (row 1) to column indexes
    $headerToCol = @{}
    for ($c = 1; $c -le $endCol; $c++) {
        $h = $ws.Cells[1, $c].Text.Trim()
        if ($h) { $headerToCol[$h] = $c }
    }

    if (-not $headerToCol.ContainsKey($TargetKeyColumn)) {
        throw "Target key column '$TargetKeyColumn' not found in header row."
    }

    # Ensure update columns exist
    foreach ($colName in $ConstantUpdates.Keys) {
        if (-not $headerToCol.ContainsKey($colName)) {
            throw "Update column '$colName' not found in target header row."
        }
    }

    $keyColIndex = $headerToCol[$TargetKeyColumn]

    $matched = 0
    $updated = 0

    for ($r = 2; $r -le $endRow; $r++) {
        $key = $ws.Cells[$r, $keyColIndex].Text.Trim()
        if (-not $key) { continue }

        if ($keySet.Contains($key)) {
            $matched++

            foreach ($colName in $ConstantUpdates.Keys) {
                $colIndex = $headerToCol[$colName]
                $newValue = $ConstantUpdates[$colName]

                # Only write if different
                $current = $ws.Cells[$r, $colIndex].Text
                if ([string]::IsNullOrWhiteSpace($current) -and ($current -ne "$newValue")) {
                    $ws.Cells[$r, $colIndex].Value = [datetime]($newValue)
                    $ws.Cells[$r, $colIndex].Style.HorizontalAlignment = "Right"
                    $updated++
                }
            }
        }
    }

    Close-ExcelPackage -ExcelPackage $pkg

    Write-Host "Matches found: $matched"
    Write-Host "Cells updated: $updated"
}
catch {
    # If anything fails, close without saving to avoid partial writes
    Close-ExcelPackage -ExcelPackage $pkg -NoSave
    throw
}
Posted in Computer Science | Leave a comment

Middlesex Recycling Program

Recycling in America can be a pain sometimes. Legally (like many would care), you cannot just throw away batteries, fluorescent light bulbs, etc. in regular garbage nor regular recycling bins. It's standard that you pay a service to get rid of these. Occasionally, you get to drop them off at certain locations, and of that, only certain days maybe for free.

So for our county, Middlesex, this is where to start. Obtained from my yahoo email, Jan 29 (Thurs) 2026, under subject line: Recycle Right Feb 2026

Posted in General | Leave a comment