搜尋此網誌

2026年3月23日星期一

Partial metering

Partial metering is especially useful when photographing a backlit subject because it prioritizes exposure on the subject itself, ensuring they aren’t rendered too dark against a bright background. The trade-off is that the background often becomes overexposed, but this can be used creatively.

逆光攝影(Backlit Photography)是指將主光源(通常是太陽或燈光)置於主體正後方的一種佈光方式。這種技巧能為照片增添戲劇感、層次感和一種夢幻般的視覺效果。

Microsoft Copilot

Google Search Engine AI Mode

Numbers in Python

int('100', 2)

means: convert the string '100' into an integer, interpreting it as a binary number.

A floating point error usually refers to the small inaccuracies that occur when computers represent and calculate with decimal numbers.

from decimal import Decimal, getcontext

The decimal module in Python is designed to avoid the floating point errors we just talked about. By using Decimal objects, you can represent numbers exactly as decimal fractions, and you can even control the precision of calculations with getcontext.

getcontext().prec = 4

round(0.1 + 0.2, 1)  # 0.3

Microsoft Copilot

測光

在攝影中,矩陣模式(Matrix Metering),通常也被稱為評價測光(Evaluative Metering)、多區測光或平均測光,是現代數碼相機中最智能化、最常用的測光模式。

Nikon:矩陣測光 (Matrix Metering)

Canon:評價測光 (Evaluative Metering)

Sony:多重測光 (Multi-segment Metering) 

Google AI Overview

2026年3月17日星期二

Macro lens

微距鏡拍攝時背景模糊的主要原因是景深極淺。鏡頭在近距離對焦時,清晰範圍非常有限,導致主體清晰而背景自然模糊。這種效果是微距攝影的特徵之一。

為什麼微距鏡背景容易模糊?

景深淺

微距鏡在近距離拍攝時,即使使用小光圈,景深仍然非常有限。只有焦點附近的區域清晰,其他部分迅速失焦,形成背景模糊。

放大倍率高

微距鏡能將物體放大到 1:1 或更高比例,這會進一步壓縮景深,使背景更容易模糊。

對焦距離短

微距鏡的最近對焦距離通常只有幾十公分甚至更短,這種近距離拍攝本身就會造成背景失焦。

Macro lenses have an extremely shallow depth of field (DOF), often measured in millimeters or less, because of the high magnification and short focusing distance. This is why only a tiny part of the subject is sharp while the rest quickly falls out of focus.

Microsoft Copilot

Lens Compression

在攝影中,長鏡頭的「壓縮效果」是指透過長焦距鏡頭拍攝時,畫面中遠近物體之間的距離感被「拉近」,使得背景看起來比肉眼所見更靠近主體,整體呈現一種扁平、擁擠的視覺感受。

常見應用場景

善用壓縮效果可以提升照片的藝術張力,常見於以下題材:

人像攝影:讓主體更突出,背景的雜物因「拉近」而變得模糊且緊湊,營造豐富的層次感。

風景攝影:如拍攝「大月亮」或「巨大夕陽」,長鏡頭能讓遠處的天體看起來與前方的建築物或人物比例相近,視覺上非常震撼。

城市建築:將層層疊疊的樓房、街道或人群「擠」在一起,呈現城市生活的繁華與壓迫感。

運動/生態:在無法靠近主體的情況下,捕捉清晰細節的同時保留背景的完整性。

焦距(Focal Length)與景深(Depth of Field, DOF)成反比關係:焦距越長,景深越淺(背景虛化越明顯);焦距越短,景深越深(前後景都清晰)。

Google AI Overview

Magnum Opus

pricey: expensive

squish (something) if something soft squishes or is squished, it is pushed out of shape when it is pressed

slog: to walk or travel somewhere steadily, with great effort or difficulty

tedious: lasting or taking too long and not interesting

decent: of a good enough standard or quality

conundrum: of a good enough standard or quality

​game (for something/to do something) ready and willing to do something new, difficult or dangerous

slouch: to stand, sit or move in a lazy way, often with your shoulders and head bent forward

Bill Gates spent significant time at Harvard’s Aiken Computation Laboratory during the mid-1970s. As a student, Gates often used the lab’s PDP-10 computer for intensive programming, sometimes racking up hundreds of hours of computer time monthly and, along with Paul Allen, was noted for using university resources for early commercial projects.

emulate something (computing) (of a computer program, etc.) to work in the same way as another computer, etc. and perform the same tasks

the pecking order: (informal, often humorous) the order of importance in relation to one another among the members of a group

idle: (of machines, factories, etc.) not in use

chunk: (informal) a fairly large amount of something

frenzied: ​involving a lot of activity and strong emotions in a way that is often violent or frightening and not under control

sabotage something to prevent something from being successful or being achieved, especially deliberately

bust: (North American English) a thing that is not good

tuck something + adv./prep. to push, fold or turn the ends or edges of clothes, paper, etc. so that they are held in place or look neat

A bootstrap loader is a specialized, small program residing in firmware (ROM/BIOS/UEFI) that initializes hardware and loads the operating system (OS) kernel into memory upon powering on a computer.

magnum opus: ​a large and important work of art, literature or music, especially one that people think is the best work ever produced by that artist, writer, etc.

Bill Gates "Source Code"

Online Dictionaries Used:

hk.dictionary.search.yahoo.com

www.oxfordlearnersdictionaries.com

Google AI overview

2026年3月16日星期一

Quiz

An object is any value that lives in memory in Python (numbers, strings, lists, functions, classes, user‑defined things, etc.).

An instance is an object viewed in relation to its class/type, i.e. “this object is an instance of that class.”

In Python, a constructor is the special method that runs automatically when you create an object from a class, usually used to set up initial attributes.

class Person:

    def __init__(self, name, age):  # constructor

        self.name = name

        self.age = age

p = Person("Alice", 30)

Assuming a Dog class exists,

type(Dog('Rover'))

Python evaluates it like this:

- Dog('Rover') creates a new instance (object) of the Dog class, with 'Rover' passed to its constructor.

- type(...) then returns the type of that object.

So the result is the class itself


myList = [[1,2], ['apple'], [3,4,5]]

listLen = len(myList)

- myList is a list containing three sublists:

- [1, 2]

- ['apple']

- [3, 4, 5]

- When you call len(myList), Python counts the top-level elements of myList, not the items inside each sublist.


false = False
- False (capitalized) is a built-in Boolean constant.
- false (lowercase) is just a variable name you created. Python is case-sensitive, so false and False are completely different things


Tuples in Python are immutable — once created, you cannot add, remove, or change their elements.


In Python, while True: means “keep looping forever” because the condition after while is always True.

Here’s the breakdown:

- while is a loop that repeats as long as its condition is true.

- True is a Boolean constant that never changes.

- So while True: creates an infinite loop — the code inside will run endlessly until you manually stop it (like pressing Ctrl + C in a terminal) or break out of it with a break statement.


Microsoft Copilot
Perplexity.AI

植物解剖學

sepal(萼片): a part of a flower, like a leaf, that lies under and supports the petals (= the thin colored parts that make up the head of the flower). Each flower has a ring of sepals called a calyx.

petal(花瓣): a delicate colored part of a flower. The head of a flower is usually made up of several petals around a central part.

calyx(花萼): the ring of small green leaves (called sepals) that protect a flower before it opens

stamen(雄蕊): a small, thin male part in the middle of a flower that produces pollen and is made up of a stalk supporting an anther. The center of each flower usually has several stamens.

gynoecium(雌蕊): a small, thin male part in the middle of a flower that produces pollen and is made up of a stalk supporting an anther. The center of each flower usually has several stamens.

carpel(心皮): the part of a plant in which seeds are produced

Online Dictionaries Used:

hk.dictionary.search.yahoo.com

www.oxfordlearnersdictionaries.com

www.merriam-webster.com

喀布爾日常

就像指南針的針永遠指向北方,男人問罪的手指找到的永遠是女人。永遠都是。好好記住吧,瑪黎安。

卡勒德.胡賽尼《燦爛千陽》李靜宜譯

2026年3月12日星期四

Factorial

def factorial(num):
    if not isinstance(num, int):
        return None
       
    if num < 0:
        return None
   
    if num == 0:
        return 1

    result = 1
    for num in range(1 , num + 1):
        result *= num
    return result

Microsoft Copilot

2026年3月10日星期二

Old lens I bought

Canon EF-S 18-135mm f/3.5-5.6 IS USM lens (已停產)

for my entry-level DSLR Canon EOS 1500D

Manufacturing location: Taiwan

Disadvantages:

- Variable aperture (f/3.5–5.6) – not ideal for low-light or professional portrait work.

- Not weather-sealed – less durable in harsh outdoor conditions.

在日本亞馬遜購買,全新。運輸有延誤,未能在這兩日假期內試鏡。

Most important warning: Do not look at the sun or a bright light source through the lens or single-lens reflex camera.

Manual focus adjustments are not possible when the camera is off.

Attach the lens: align the lens's red or white index with the camera's index matching the same color

Red dot → for EF lenses

White square → for EF-S lenses

Once aligned, gently rotate the lens clockwise until it clicks into place.

Microsoft Copilot

Camera and lens Instruction Manual

Not wide enough

On APS-C, the smaller sensor applies a crop factor (≈1.6× for Canon), so the lens behaves like a 29–216mm equivalent on full-frame. On a full-frame body, the same lens gives its true 18–135mm range.

Microsoft Copilot

Exposure Compensation Limit

On the Canon EOS 1500D, exposure compensation in Shutter Priority mode may appear ineffective because the camera automatically adjusts aperture to maintain correct exposure. If the lens reaches its aperture limits, compensation has no visible effect.

ISO Settings: If ISO is fixed, the camera has fewer options to adjust exposure. In Auto ISO, the camera may override compensation by adjusting ISO instead.


How to Make Exposure Compensation Work

- Use Aperture Priority (Av) or Program (P) Mode: These modes give the camera more flexibility to adjust shutter speed or aperture, so compensation is more effective.

- Enable Auto ISO: This allows the camera to adjust ISO when aperture limits are reached, making compensation visible. (咁點解唔自己調 ISO?)

Microsoft Copilot

Prototype

solder: to join pieces of metal or wire with solder

toggle switch: ​an electrical switch that you move up and down or backwards and forwards

avid: very enthusiastic about something (often a hobby)

holy grail: a thing that you try very hard to find or achieve, but never will

add-on: a thing that is added to something else

hitch: a problem or difficulty that causes a short delay

mainframe: a large, powerful computer, usually the center of a network and shared by many users

pore over: to look at or read something very carefully

devise: to invent something new or a new way of doing something

conceive: to form an idea, a plan, etc. in your mind

viable: that can be done; that will be successful

tweak: to make slight changes to a machine, system, etc. to improve it

rocketry: the area of science which deals with rockets and with sending rockets into space; the use of rockets

Traf-O-Data was a 1970s business partnership formed by Bill Gates, Paul Allen, and Paul Gilbert to analyze raw traffic data from pneumatic road counters and create reports for traffic engineers. While only moderately successful and ultimately a failure, it was the precursor to Microsoft, providing essential experience with Intel 8008 microprocessors and data processing.

Micro Instrumentation and Telemetry Systems, Inc. (MITS), was an American electronics company founded in Albuquerque, New Mexico that began manufacturing electronic calculators in 1971 and personal computers in 1975.

proclamation: an official statement about something important that is made to the public; the act of making an official statement

clunky: (of technology) old-fashioned; not well designed

prototype: the first design of something from which other forms are copied or developed


Bill Gates "Source Code"

Online Dictionaries Used:

hk.dictionary.search.yahoo.com

www.oxfordlearnersdictionaries.com

Google AI overview

en.wikipedia.org

2026年3月9日星期一

Classes and Objects in Python

In Python, there is no difference between using double quotes ("Samson") and single quotes ('Samson') when defining a string. Both represent the same type of string object.

print("Samson")  # Output: Samson

print('Samson')  # Output: Samson

In Python, __init__ is a special method used in classes. It’s often called the constructor, because it runs automatically whenever you create a new object (an instance) from that class.

In Python, class names are typically written with a capitalized first letter.

Class: A blueprint or template. It defines what attributes (data) and methods (behavior) its objects will have.

Object: A specific instance created from that class. Each object has its own data but follows the structure defined by the class.

Microsoft Copilot

2026年3月3日星期二

Lilas Ikuta - Time Machine

I wish I could return

to the time when I knew nothing.

Even knowing the ending would never change,

I still longed for a little time

to escape and look away.


The single lie you told,

in just an instant,

turned the colorful days we had built

into monotonous black and white.

My eyes grew clouded,

and even everything I saw

lost its light.


But in truth, I lied too.

Shouting that it was for both our sakes,

I left behind an answer

opposite to my heart.

Convincing myself it was the right choice

to deceive myself.


If a time machine truly existed in this world,

if there were magic to erase everything,

I would wish for no memory to remain.

If we could meet again, that alone would be enough.

How many times I wished for that—

even now, I wish to fall in love with you once more.


Your helplessness always made me sad,

yet gave me a happiness

I could never find anywhere else.

Compared to all the months and years we shared,

the ending was too abrupt,

disproportionate to what we had.


The future we sketched together,

I erased piece by piece.

And each time, I wondered—

if another future had existed,

would we be laughing together now?

Such thoughts linger endlessly.


Even if a time machine truly existed,

I could never erase everything.

Not the days we loved so deeply.


If there was love,

then being bound together,

and being torn apart,

all held meaning.

So that someday,

on the day I fall into my final love,

I can say with all my heart:

“It was wonderful to meet you.”

And let this goodbye

be one I can accept.


Next time, I will never

let go of someone’s precious hand.

I hope that someday I’ll understand—

this was a love

that taught me what mattered most.

A journey I was meant to experience.

Similar words

machine: a piece of equipment with many parts that work together to do a particular task. The power used to work a machine may be electricity, steam, gas, etc. or human power.

mechanics [uncountable] the science of movement and force

mechanism: a method or a system for achieving something

www.oxfordlearnersdictionaries.com

P 模式

程式自動曝光(Program AE,簡稱 P 模式)是一種半自動攝影模式,相機會根據環境亮度自動設定「光圈」和「快門速度」以獲得平衡曝光。相比全自動模式,P 模式允許攝影師自由調整 ISO、白平衡、閃光燈和曝光補償(EV),適合想專注構圖又需一定自定義功能的場景。

Google AI overview

一字之差

巴基斯坦

  • Pakistan
  • country in southern Asia bordering the Arabian Sea; originally comprising two parts—West Pakistan (now Pakistan) and East Pakistan (now Bangladesh)—separated by about 1000 miles (1600 kilometers) of northern India; a dominion 1947–56, an Islamic republic since 1956, and a member of the Commonwealth of Nations 1956–72; formed from parts of former British India; capital Islamabad area 307,374 square miles (796,095 square kilometers), population 207,863,000
  • www.merriam-webster.com/dictionary
  • 巴勒斯坦
  • Palestine
  • Palestine, region of Southwest Asia along the eastern Mediterranean, generally regarded as consisting of the southern coastal area between Egypt, where Asia meets Africa, and Tyre, which in ancient times was the most prominent of the Phoenician city-states.
  • www.britannica.com/place

functions in python

parenthesis: IPA[pəˈrenθəsɪs]

parentheses /pəˈrenθəsiːz/

Common Uses of Shift + Enter

- Jupyter Notebook / JupyterLab

- Runs the current cell and moves to the next one.

- Equivalent to executing code in that cell.

- VS Code (with Python extension)

- By default, it can send selected code to the terminal or Python Interactive window.

- Sometimes it runs code in the terminal instead of the interactive window, depending on your settings.

- You can customize this in Keyboard Shortcuts by mapping Shift + Enter to Python: Run Selection/Line in Python Interactive Window.

In Python, the keyword def is used to define a function. Functions are reusable blocks of code that perform a specific task when called

In Python, the return statement is used inside a function to send a value back to the caller. It’s one of the most important ways to control the flow of data in your program.

Examples
Returning a value:
def square(n):
    return n * n

result = square(4)
print(result)  # Output: 16

append something (to something) to add something to the end of a piece of writing

def greet(name):
    print("Hello,", name)

x = greet("Samson")
print(x)  # Output: None

- Use return when you want your function to produce a value that can be used later.
- Skip return when your function’s job is just to perform an action (like printing or updating a file)

- With return → function is like a vending machine (you get something back).
- Without return → function is like a loudspeaker (it just outputs sound, but you don’t get a reusable object).

Mainly from Microsoft Copilot

2026年2月25日星期三

Feature of Python

Indentation in Python

Unlike many other programming languages, Python uses indentation to define code blocks instead of braces {} or keywords. This makes indentation not just stylistic, but syntactically required.

Microsoft Copilot

Operators in Python

Double asterisk in Python: exponentiation operator

print(10 % 3)   # 1   (because 10 = 3*3 + 1)

print(25 % 7)   # 4   (because 25 = 7*3 + 4)

The operator <= means “less than or equal to.”

Python has two membership operators that test whether a value is present in a sequence (like a list, tuple, string, or set) or a mapping (like a dictionary).

d = {"x": 10, "y": 20}

print("x" in d)        # True

print(10 in d)         # False (10 is a value, not a key)

Microsoft Copilot

Trans fat and cholesterol profile

Trans fats raise “bad” LDL cholesterol and often lower “good” HDL cholesterol, creating one of the worst possible cholesterol profiles for your heart and blood vessels. Even small amounts in the diet are linked to higher rates of heart attack and death from heart disease.

Head‑to‑head trials suggest trans fats disturb the cholesterol profile at least as much as, and in some ways more than, cholesterol‑raising saturated fats. Unlike most saturated fats, trans fats both increase LDL and lower HDL, which makes their overall effect on the LDL/HDL ratio particularly harmful. Because of this pattern, expert groups describe trans fats as the most damaging dietary fat per gram for cardiovascular health.

Deep Research using Perplexity.ai

拉之眼

The Eye of Ra is a powerful ancient Egyptian symbol representing the sun god Ra's protective yet destructive force. While it shares a similar "wedjat" design with the Eye of Horus, the Eye of Ra is traditionally depicted as the right eye and symbolizes solar energy, royal authority, and divine retribution.

Google AI overview

2026年2月24日星期二

Data structures of Python

Lists are ordered collections. Sets are unordered collections.

A tuple is one of the built-in data types used to store collections of items. It’s similar to a list but with a key difference: tuples are immutable, meaning once created, their elements cannot be changed, added, or removed.

immutable: that cannot be changed; that will never change

Similarities of sets and dictionaries:
  • Both can be modified after creation
  • Both are defined with curly brackets
  • Both are unordered collections
Source mainly from Microsoft Copilot

v > c

Tachyons are hypothetical subatomic particles that always travel faster than the speed of light. Proposed to exist within the framework of special relativity, they possess imaginary mass and would speed up as they lose energy, requiring infinite energy to slow down to light speed. No experimental evidence confirms their existence.

Google AI Overview

星芒效果

要拍攝出漂亮的星芒效果,核心技巧是使用小光圈(通常為 f/11-f/16)對點光源進行拍攝。將相機固定在三腳架上,結合低 ISO 和長曝光,可以使夜景、路燈或太陽的單點光線發散成清晰的放射狀線條。

Google AI overview

Large improvement of hardware

The William Lowell Putnam Mathematical Competition is the premier, notoriously challenging mathematics competition for undergraduate students in the U.S. and Canada, held annually on the first Saturday of December.

pant: to breathe quickly with short breaths, usually with your mouth open, because you have been doing some physical exercise, or because it is very hot

slush: partly melted snow that is usually dirty

toggle switch: an electrical switch that you move up and down or backwards and forwards

full-blown: having all the characteristics of somebody/something; fully developed

exploit: exploit something to use something well in order to gain as much from it as possible


Bill Gates "Source Code"

Online Dictionaries Used:

hk.dictionary.search.yahoo.com

www.oxfordlearnersdictionaries.com

2026年2月19日星期四

Something basic

Single equal sign (=) is an assignment operator.

Double equal signs (==) are used as a comparison operator.

Microsoft Copilot

2026年2月17日星期二

"宝石" 伶 feat. 幾田りら

I made up my mind not to cry

I knew it all along

There'd be a time we'd eventually part

Memories send so much loneliness

Into my heart

Should have been sick of

Our foolish exchanges long ago but

I kind of miss it now

As if you've forgotten how it ended last time

Your regular smile

Really suits you

We're just continually searching

For the one and only version of ourselves

Like a star that floats up in the sky by day

It's there, even if it can't be seen

We've had it in our possession all along

This invaluable thing

Be continuing to improve upon it, one day

We'll find it

The song I memorized repeatedly

The melody that's seeped into me

Circulates through my body

I'll burn them all into memory

That irreplaceable

Place where I'm meant to return

Hurt at times

Bringing together that have yet to heal

We talked until morning

To bodies that felt a little lighter

We poured in hope

And kept going for it, didn't we

I'll be leaving here tonight

Leaving behind this loneliness I've accumulated

Don't have to put everything into words

I can tell when I see you nod

The times we've spent together up 'til now

The light that shined upon us

No one can shut it out

It'll be okay

I started out alone

And today, I walk on my own again

But in this baggage I shoulder

Are our days spent together, like gemstones

I'm no longer alone

This light that continues to shine in my heart

Is without a doubt, you

Forever and ever

Greeting

"How are you" and "how are you doing" are common, casual greetings inquiring about someone's wellbeing, often answered with "I'm fine" or "Good, thanks". "How do you do" is a formal, old-fashioned greeting, usually used upon first introduction, and is properly answered by repeating the phrase back, rather than answering the question.

Google AI overview

Python Course Quiz

a = [1,2,3]   # 'a' points to the list [1,2,3]

b = a            # 'b' now points to the same list as 'a'

a = [4,5,6]   # 'a' is reassigned to a new list [4,5,6]

Importantly, this does not change b; b still points to the original [1,2,3]

Microsoft Copilot

2026年2月10日星期二

brainstorming

mystique: the quality of being mysterious or secret that makes somebody/something seem interesting or attractive

A corrupter (or corruptor) is a person or thing that causes moral decay, dishonesty, or the rotting/spoiling of something.

sober: not drunk (= not affected by alcohol)

chaperone: (in the past) an older woman who, on social occasions, took care of a young woman who was not married

dewdrop: a small drop of dew or other liquid

irrevocably: in a way that cannot be changed

forage (for something) (of a person) to search for something, especially using the hands

exploit something: to use something well in order to gain as much from it as possible

sift: to examine something very carefully in order to decide what is important or useful or to find something important

mocktail: a cocktail (= mixed drink) that does not contain any alcohol

glitch: a small problem or fault that stops something working successfully

tedious: ​lasting or taking too long and not interesting

doggedly: ​in a way that shows that you are determined and do not give up easily

plead: to ask somebody for something in a very strong and serious way

tollbooth: a small building by the side of a road where you pay to drive on a road, go over a bridge, etc.

inclination: a feeling that makes you want to do something

skeptically: ​in a way that shows doubts that a claim or statement is true or that something will happen


Bill Gates "Source Code"

Online Dictionaries Used:

hk.dictionary.search.yahoo.com

www.oxfordlearnersdictionaries.com

dictionary.cambridge.org

2026年2月3日星期二

Final Quiz

In C++, the term insertion operation usually refers to adding elements into data structures (like arrays, vectors, lists, sets, or maps) or inserting output into streams.

concatenate: to put things together as a connected series

#include <iostream>

#include <fstream>

#include <string>

using namespace std;


int main() {

    ifstream inputFile("example.txt"); // open file for reading


    if (!inputFile) {

        cerr << "Error opening file!" << endl;

        return 1;

    }


    string line;

    while (getline(inputFile, line)) { // read line by line

        cout << line << endl;          // print each line

    }


    inputFile.close(); // close the file

    return 0;

}


Microsoft Copilot

Poker

lottery: a way of raising money for a government, charity, etc. by selling tickets that have different numbers on them that people have chosen. Numbers are then chosen by chance and the people who have those numbers on their tickets win prizes.

slob: a person who is lazy and dirty or untidy

stake: something that you risk losing, especially money, when you try to predict the result of a race, game, etc., or when you are involved in an activity that can succeed or fail

grungy: dirty in an unpleasant way

Seven-card stud, also known as Seven-Toed Pete or Down-The-River, is a variant of stud poker.

khakis: a strong yellow-brown cloth, used especially for making military uniforms

stow: to put something in a safe place


Bill Gates "Source Code"

Online Dictionaries Used:

hk.dictionary.search.yahoo.com

www.oxfordlearnersdictionaries.com

Anubis, ancient Egyptian god

Anubis, ancient Egyptian god of funerary practices and care of the dead, represented by a jackal or the figure of a man with the head of a jackal. In the Early Dynastic period and the Old Kingdom, he enjoyed a preeminent (though not exclusive) position as lord of the dead, but he was later overshadowed by Osiris. His role is reflected in such epithets as “He Who Is upon His Mountain” (i.e., the necropolis), “Lord of the Sacred Land,” “Foremost of the Westerners,” and “He Who Is in the Place of Embalming.”

阿努比斯,古埃及掌管葬禮儀式與亡者照護的神祇,以豺狼或人身豺狼頭的形象呈現。在早王朝時期與古王國時期,他享有至高(雖非唯一)的地位,為亡者之主,但後來逐漸被歐西里斯所取代。他的角色反映在一些尊號中,如「山上之神」(即墓地)、「聖地之主」、「西方人之首」以及「在防腐之所者」。

His particular concern was with the funerary cult and the care of the dead; hence, he was reputed to be the inventor of embalming, an art he first employed on the corpse of Osiris. In his later role as the “conductor of souls,” he was sometimes identified by the Greco-Roman world with the Greek Hermes in the composite deity Hermanubis.

他特別關注葬禮崇拜與亡者的照護;因此,他被傳說為防腐術的發明者,並首先將此技藝運用於歐西里斯的屍體。在他後來作為「靈魂引導者」的角色中,希臘羅馬世界有時將他與希臘神赫密斯相結合,形成合成神赫曼努比斯。

Source: https://www.britannica.com/topic/Anubis

Anubis is the guardian of mummies and cemeteries. He is responsible for weighing the heart during the judgement after death and guiding the deceased along the path to the afterlife.

阿努比斯是木乃伊與墓地的守護者。他負責在死後審判時秤量心臟,並引導亡者走向通往來世的道路。

Yan, H. Y. (2025). Ancient Egypt Unveiled: Treasures from Egyptian Museums. The Hong Kong Palace Museum.

The human heart was balanced on the scale against Ma’at’s feather of truth. If the heart weighed more than the feather, the person’s identity would essentially cease to exist: the hybrid deity Ammit would eat the heart, and the soul would be destroyed. But if the heart weighed the same as the feather, the deceased would pass through the underworld (Duat) and into the Afterlife.

人類的心臟在天秤上與瑪亞特的真理之羽相衡。如果心臟比羽毛更重,這個人的身份便會徹底消失:混合神阿米特會吞食心臟,靈魂也將被毀滅。但若心臟與羽毛重量相同,亡者便能通過冥界(杜阿特),進入來世。

Source: https://egyptianmuseum.org/deities-Anubis

Translated with Microsoft Copilot and Edited

2026年1月27日星期二

Exception handling in C++

Exception handling in C++ is a structured way to detect and manage runtime errors using try, catch, and throw keywords, allowing programs to recover gracefully instead of crashing. It helps deal with issues like division by zero, invalid memory access, or file (input and output) I/O failures.

try block

    Contains code that might generate an exception.

    Example: risky operations like division or file handling.

throw keyword

    Used to signal that an error has occurred.

    Example: throw "File not found";

catch block

    Defines how to handle the exception.

    Example: catch (const char* msg) { cout << msg; }


#include <iostream>

using namespace std;


int main() {

    try {

        int x = 10, y = 0;

        if (y == 0) {

            throw runtime_error("Division by zero error!");

        }

        cout << x / y;

    }

    catch (runtime_error &e) {

        cout << "Exception caught: " << e.what() << endl;

    }

    return 0;

}


Output:
Exception caught: Division by zero error!


In C++, the e.what() method is used with exceptions that are derived from the standard exception class std::exception.

What it does

  • std::exception defines a virtual function what() that returns a C-style string (const char*) describing the error.
  • When you catch an exception object (like std::runtime_error, std::out_of_range, etc.), calling e.what() gives you a human-readable message about what went wrong.


In C++, array index out-of-bounds occurs when you try to access an element outside the valid range of an array.

In C++, the symbol || is the logical OR operator.

    It evaluates two boolean expressions (conditions).

    The result is true if at least one of the conditions is true.

    The result is false only if both conditions are false.


Always catch exceptions by reference (usually const &) to:

    Avoid object slicing.

    Preserve polymorphic behavior (what() works correctly for derived classes).

    Improve performance (no extra copy).


Microsoft Copilot

Threatening Dream

dread: causing fear

gambit: a thing that somebody does, or something that somebody says at the beginning of a situation or conversation, that is intended to give them some advantage

Monomaniacal is an adjective describing an obsessive, fanatical, or extreme preoccupation with one single subject, idea, or cause to the exclusion of all others.

cram (for something) (North American English, informal or British English, old-fashioned) to learn a lot of things in a short time, in preparation for an exam

perilous: very dangerous

Combinatorial refers to the branch of mathematics (combinatorics) concerned with counting, arranging, and selecting discrete, finite elements.

nerd: ​a person who is boring, stupid and not fashionable

revert: to reply

nonchalance: ​a calm and relaxed way of behaving; behavior that gives the impression you are not feeling worried

Bill Gates "Source Code"

Online Dictionaries Used:

hk.dictionary.search.yahoo.com

www.oxfordlearnersdictionaries.com

Google AI overview

Osiris, God of Afterlife

Who Osiris Was

  • Osiris started as a local fertility god in Lower Egypt (Busiris).
  • By around 2400 BCE, he became both:
    • God of fertility (life, crops, growth).
    • God of the dead (embodiment of the deceased king).
  • Egyptian kingship tied into this:
    • The dead king became Osiris.
    • The living king was Horus, Osiris’s son.
    • Isis was Osiris’s wife and Horus’s mother.
    • Seth was Osiris’s brother and murderer.

歐西里斯是誰

  • 歐西里斯最初是下埃及布西里斯的地方生育神。
  • 約在西元前2400年,他同時成為:
    • 生育之神(掌管生命、農作物、成長)。
    • 死亡之神(象徵已逝的國王)。
  • 埃及王權與此結合:
    • 已逝的國王化為歐西里斯。
    • 在世的國王是荷魯斯,歐西里斯之子。
    • 伊西斯是歐西里斯的妻子,也是荷魯斯的母親。
    • 賽特是歐西里斯的兄弟與殺害者。

The Myth of Osiris

  • According to Plutarch, Seth killed Osiris, cut his body into 14 pieces, and scattered them across Egypt.
  • Isis and Nephthys found and buried the pieces (except the phallus), reviving Osiris.
  • Osiris then ruled the underworld as judge of the dead.
  • Horus fought Seth, avenged his father, and became king of Egypt.

歐西里斯的神話

  • 根據希臘作家普魯塔克的記載,賽特殺害歐西里斯,將其屍體切成十四塊並散佈埃及各地。
  • 伊西斯與其姊妹奈芙蒂斯找回並埋葬了所有部分(除了陽具),使歐西里斯復生。
  • 從此歐西里斯成為冥界的統治者與審判者。
  • 荷魯斯擊敗賽特,為父報仇,並成為埃及的新王。

Osiris’s Role in Life and Death

  • Osiris wasn’t just ruler of the dead—he symbolized life itself:
    • Fertility of crops.
    • The Nile’s annual flood.
  • Around 2000 BCE, Egyptians believed all people became linked with Osiris at death, not just kings.
  • This didn’t mean resurrection, but renewal of life in the afterlife and through descendants.

歐西里斯在生命與死亡中的角色

  • 歐西里斯不僅是死後的統治者,他象徵著生命本身
    • 農作物的肥沃。
    • 尼羅河的年度氾濫。
  • 約在西元前2000年,埃及人相信所有人死後都與歐西里斯相連,而不僅僅是國王。
  • 這並不意味著復活,而是生命的更新,在來世與後代中延續。

Worship and Festivals

  • Osiris’s cult spread widely, merging with other fertility and underworld gods.
  • Festivals in the Middle Kingdom (1938–1630 BCE) included:
    • Processions and night rituals at Abydos.
    • Public participation and burials along the processional road.
  • Annual festivals reenacted Osiris’s fate:
    • “Osiris gardens” were made—molds shaped like Osiris, filled with Nile soil and grain.
    • Sprouting plants symbolized Osiris’s strength and renewal.

崇拜與祭典

  • 歐西里斯的信仰廣泛傳播,並與其他生育與冥界神明融合。
  • 中王國時期(西元前1938–1630年)的祭典包括:
    • 在阿拜多斯舉行的遊行與夜間儀式。
    • 民眾可參與,並在遊行道路旁埋葬或立紀念碑。
  • 每年祭典重演歐西里斯的命運:
    • 建造「歐西里斯花園」—— 歐西里斯形狀的模具,填入尼羅河水與穀物。
    • 穀物萌芽象徵歐西里斯的力量與更新。

Later Connections

  • At Memphis, Osiris was linked with the sacred bull Apis → Osiris-Apis, later becoming Serapis in Hellenistic times.
  • Greeks and Romans connected him with Dionysus.
  • He was also identified with Soker, another god of the dead.

後期的聯繫

  • 在孟菲斯,歐西里斯與神聖公牛阿比斯結合 → 西里斯-阿比斯,後來演變為希臘化時期的塞拉比斯
  • 希臘與羅馬人將歐西里斯與酒神狄奧尼索斯相連。
  • 歐西里斯也與孟菲斯的死神索克同化。

Depictions

  • Oldest images date to ~2300 BCE.
  • In the New Kingdom (1539–1075 BCE), Osiris was shown as:
    • A mummy with arms crossed.
    • Holding a crook and flail (symbols of kingship).
    • Wearing the atef crown (white crown of Upper Egypt + two ostrich feathers).

歐西里斯的形象

  • 最早的形象約在西元前2300年。
  • 新王國時期(西元前1539–1075年),歐西里斯被描繪為:
    • 木乃伊,雙臂交叉於胸前。
    • 一手持牧杖,一手持鞭。
    • 頭戴阿特夫冠(上埃及白冠加兩根鴕鳥羽毛)。


Original Information: https://www.britannica.com/topic/Osiris-Egyptian-god

Summarized, simplified and translated with Microsoft Copilot and edited

2026年1月22日星期四

Exposure

在手動模式 (Manual Mode) 下,曝光補償 (Exposure Compensation) 功能通常不會直接使用,因為您完全控制光圈、快門和 ISO。

〈有牌爛仔〉

雙十暴動是1956年10月10至12日間在香港九龍及荃灣等地發生的一次騷亂。事件的導火線是徙置事務處職員在中華民國國慶10月10日移除懸掛在李鄭屋徙置區的中華民國國旗和大型「雙十」徽牌。

騷動衝着國共力量在港的矛盾,由雙十掛國旗的糾紛觸發,再引來連串駭人的暴力事件。衝突結果帶來六十人死、四百四十三人傷。

Grammar in Use

Wrong: When did this bridge being built?

Correct: When was this bridge built?

Interviews

whisk somebody/something + adv./prep. to take somebody/something somewhere very quickly and suddenly

fabled: ​famous and often talked about, but rarely seen

A DEC computer refers to machines made by the Digital Equipment Corporation (DEC), a pioneering American company famous for revolutionizing computing with affordable minicomputers.

cling: to hold on tightly to somebody/something

"Bonneville" refers to a significant early programming job Bill Gates and Paul Allen had for the Bonneville Power Administration (BPA) in North Bonneville, Washington, where they debugged software for the Pacific Northwest's electrical grid control system for defense contractor Thompson Ramo Wooldridge (TRW).

awed: showing or feeling respect and slight fear; extremely impressed by somebody/something

bask (in something) to enjoy sitting or lying in the heat or light of something, especially the sun

hone: to develop and improve something, especially a skill, over a period of time

veer: to change direction suddenly

angst: a feeling of great worry about a situation, or about your life

Plymouth was a popular American car brand by Chrysler, launched in 1928 to offer affordable cars against Ford and Chevy, becoming known for reliable models like the Valiant and iconic muscle cars.


Bill Gates "Source Code"

Online Dictionaries Used:

hk.dictionary.search.yahoo.com

www.oxfordlearnersdictionaries.com

Google AI overview

2026年1月20日星期二

Open a txt file for reading

reading file: ifstream (input file stream)

writing file: ofstream (output file stream)

eof() in C++ is a member function of file stream classes (ifstream, ofstream, fstream) that stands for end-of-file.

stoi in C++ stands for "string to integer".


Meaning of letter = str[0];

  • str → a std::string object.
    • [0] → accesses the first character of the string (indexing starts at 0).
    • letter → a variable of type char that stores the result.

    So this statement assigns the first character of the string str to the variable letter


    Microsoft Copilot

    成長

    hype: to advertise something a lot and make its good qualities seem better than they actually are, in order to get a lot of public attention for it

    conglomerate: (business) a large company formed by joining together different firms

    off base: (North American English, informal) completely wrong about something

    blurt out: say something suddenly, impulsively, and without thinking, often revealing a secret or a thought you intended to keep hidden, typically due to excitement or nervousness, and sometimes leading to regret

    flaw: a mistake in something that means that it is not correct or does not work correctly

    fluster: to make somebody nervous and/or confused, especially by giving them a lot to do or by making them hurry

    dumb: (especially North American English, informal) stupid

    stalk: to walk in an angry or proud way

    dread: to be very afraid of something; to fear that something bad is going to happen

    congenial: (of a person) pleasant to spend time with because their interests and character are similar to your own

    comeuppance: ​a punishment for something bad that you have done, that other people feel you really deserve

    cringe: to feel very embarrassed and uncomfortable about something


    Bill Gates "Source Code"

    Online Dictionaries Used:

    hk.dictionary.search.yahoo.com

    www.oxfordlearnersdictionaries.com

    2026年1月16日星期五

    Working with files

    In C++, the fstream class (from the header) is used for both reading and writing files. It combines the functionality of ifstream (input file stream) and ofstream (output file stream), allowing you to open a file and perform input/output operations on it.

    The is_open() function in C++ is a member of the file stream classes (ifstream, ofstream, and fstream). It is used to check whether a file stream is currently associated with (and successfully opened) a file.

    getline() in C++ — it’s one of the most useful functions for reading text input, especially when dealing with files or user input that includes spaces.

    #include <iostream>

    #include <string>

    using namespace std;


    int main() {

        string name;

        cout << "Enter your full name: ";

        getline(cin, name);  // reads entire line including spaces

        cout << "Hello, " << name << "!" << endl;

        return 0;

    }


    ios::app is a file open mode flag used with file streams (ofstream, fstream).

    Meaning: Append mode.

    When you open a file with ios::app, all output operations are performed at the end of the file, preserving existing content.

    The file pointer is moved to the end before each write.

    Existing data is not erased.


    console: a flat surface that contains all the controls and switches for a machine, a piece of electronic equipment, etc.


    ios::in

    • Meaning: Open file for input (reading).
    • Behavior:
      • The file must exist; otherwise, opening fails.
      • You can read data from the file using the stream.
    • Typical use: Used with ifstream or fstream.

    ios::out

    • Meaning: Open file for output (writing).
    • Behavior:
      • If the file exists, its contents are truncated (erased) unless combined with ios::app.
      • If the file doesn’t exist, it is created.
      • You can write data into the file.
    • Typical use: Used with ofstream or fstream.


    The .close() function in C++ is used with file stream objects (ifstream, ofstream, fstream) to close an open file.


    Microsoft Copilot

    Precocious

    sophomore: a student in the second year of a course of study at a college or university

    audit something (North American English) to attend a course at college or university but without taking any exams or receiving credit

    enthuse: to talk in an enthusiastic and excited way about something

    precocious: (of a child) having developed particular abilities and ways of behaving at a much younger age than usual

    complimentary: expressing approval, praise, etc.

    brat: a person, especially a child, who behaves badly

    dejected: unhappy and disappointed

    stunned: very surprised or shocked; showing this

    propriety: moral and social behavior that is considered to be correct and acceptable

    conversant: moral and social behavior that is considered to be correct and acceptable

    whizz: to do something very quickly

    innate: ​(of a quality, feeling, etc.) that you have when you are born

    subtly: in a way that is not very obvious or easy to notice

    nerd: ​a person who is boring, stupid and not fashionable

    stark: unpleasant; real, and impossible to avoid

    deception: the act of deliberately making somebody believe something that is not true

    hands-down: easily the winner of a contest; definitely the one that people prefer

    suite: a set of rooms, especially in a hotel

    confide: to tell somebody secrets and personal information that you do not want other people to know

    epiphany: a sudden and surprising moment of understanding

    implicit: suggested without being directly expressed

    vibe: a mood or an atmosphere produced by a particular person, thing or place

    prod: to try to make somebody do something, especially when they are unwilling

    languish: to be forced to stay somewhere or suffer something unpleasant for a long time

    scrawl: to write something in a careless untidy way, making it difficult to read

    vocation: a type of work or way of life that you believe is especially suitable for you

    dicey: dangerous and uncertain


    Bill Gates "Source Code"

    Online Dictionaries Used:

    hk.dictionary.search.yahoo.com

    www.oxfordlearnersdictionaries.com

    2026年1月13日星期二

    Chapter Quiz

    A class template allows you to define a class that can work with any data type. Instead of writing separate classes for int, double, string, etc., you write one generic class and let the compiler generate the specific version when you use it

    Inheritance allows one class (the derived class) to reuse and extend the functionality of another class (the base class).

    Polymorphism means “many forms” — the ability of different classes to be treated through a common interface, often using virtual functions.

    In C++ (and in object-oriented programming generally), a superclass is simply another name for a base class — the class that is being inherited from.

    A constructor is a special member function that is automatically called when an object of a class is created.

    A destructor is a special member function that is automatically called when an object goes out of scope or is deleted.


    template <typename T>

    size_t size_in_bits(const T& a) {

        return sizeof(a) * 8;

    }

    template <typename T>

    Declares a function template that can accept any type T.

    const T& a

    The function takes a constant reference to an object of type T.

    Using const ensures the function doesn’t modify a.

    Using a reference avoids copying large objects.

    sizeof(a)

    Returns the size of the object a in bytes.

    * 8

    Converts bytes into bits (since 1 byte = 8 bits).

    Return type size_t

    A standard unsigned integer type used for sizes.


    Queue (FIFO — First In, First Out)

    • Think of a line at a ticket counter: the first person to arrive is the first person served.
    • Operations:
      • Enqueue → add an element at the back.
      • Dequeue → remove an element from the front.

    Stack (LIFO — Last In, First Out)

    • Think of a stack of plates: the last plate you put on top is the first one you take off.
    • Operations:
      • Push → add an element on top.
      • Pop → remove the top element.


    What is std::map?

    • A sorted associative container in the C++ Standard Library.
    • Stores elements as key–value pairs (std::pair).
    • Keys are unique (no duplicates).
    • Internally implemented as a balanced binary search tree (usually a Red-Black Tree).
    • Provides logarithmic time complexity (O(log n)) for insert, search, and delete operations.


    What is std::vector?

    • A sequence container that stores elements in a contiguous memory block (like an array).
    • Unlike arrays, vectors can grow or shrink dynamically.
    • Provides random access to elements (constant time O(1) for indexing).
    • Efficient insertion/removal at the end (push_back, pop_back are amortized O(1)), but slower at the front or middle (O(n)).
    contiguous: touching or next to something

    What is std::list?

    • A sequence container that stores elements in a doubly linked list.
    • Unlike std::vector, elements are not stored contiguously in memory.
    • Provides fast insertion and deletion anywhere in the list (O(1) if you already have the iterator).
    • Slower random access (O(n)), since you must traverse nodes sequentially.

     What is std::priority_queue?

    • A container adapter in the C++ Standard Library.
    • Works like a queue, but instead of FIFO order, it always keeps the largest (or highest priority) element at the front by default.
    • Internally implemented using a heap (usually a max-heap).
    • Provides logarithmic time complexity (O(log n)) for insertion and removal, and constant time O(1) for accessing the top element.

    Pointer

    • A pointer is a variable that stores the memory address of another variable.
    • You can use it to directly access and manipulate memory.
    int x = 10;
    int* p = &x;   // p points to x
    cout << *p;    // dereference → prints 10

    *p → dereference (access value at address).
    &x → address-of operator.
    Pointers can be incremented/decremented to move through contiguous memory (like arrays).

    Iterator

    • An iterator is an object that behaves like a pointer but is designed to work with STL containers (vector, list, map, etc.).
    • Provides a uniform way to traverse containers without worrying about their internal structure.
    In computer science, traversing means systematically visiting or accessing every element in a data structure (like an array, tree, or graph) to process it, often using loops or specific algorithms.

    #include <vector>
    #include <iostream>
    using namespace std;

    int main() {
        vector<int> v = {1, 2, 3, 4};

        // Iterator
        vector<int>::iterator it;
        for (it = v.begin(); it != v.end(); ++it) {
            cout << *it << " ";  // dereference iterator
        }
    }

    begin() → returns iterator to first element.
    end() → returns iterator past the last element.
    Iterators can be incremented (++it) to move forward.
    Some iterators support random access (like pointers in vector), while others only support sequential traversal (like in list).

    Operator overloading in C++ lets you redefine how operators (like +, -, ==, [], etc.) behave for your own classes. It’s a powerful way to make user-defined types feel natural and intuitive to use.

    Normally, operators work with built-in types (int, double, etc.).

    With operator overloading, you can extend them to work with objects.

    Example: Adding two Complex numbers with + instead of writing a function like add(c1, c2).

    Complex numbers are numbers of the form a+bi, where a is the real part, b is the imaginary part, and i is the imaginary unit defined by i^2=-1. They extend the real number system to allow solutions to equations like x^2+1=0, which have no real solutions.


    Microsoft Copilot

    competition among elite

    dazzle: dazzle (somebody) if a strong light dazzles you, it is so bright that you cannot see for a short time

    camaraderie: a feeling of friendship and trust among people who work or spend a lot of time together

    footing: the basis on which something is established or organized

    excel: to be very good at doing something

    outlier: a person or thing that is different from or in a position away from others in the group

    awkward: difficult to deal with

    nudge: a slight push, usually with the elbow

    premed: (especially North American English) a course or set of classes that students take in preparation for medical school

    intently: with strong interest and attention

    monstrous: very large

    agilely: (of the way someone or something moves) quickly and easily

    intimidating: ​frightening in a way that makes a person feel less confident

    crammer: ​a school or book that prepares people quickly for exams

    maniacal: ​wild or violent

    gobble: to eat something very fast, in a way that people consider rude or greedy

    preoccupied: thinking and/or worrying continuously about something so that you do not pay attention to other things

    dingy: dark and dirty

    grimy: ​covered with dirt

    stunned: ​very surprised or shocked; showing this

    screwed: in very bad trouble or difficulty


    Bill Gates "Source Code"

    Online Dictionaries Used:

    hk.dictionary.search.yahoo.com

    www.oxfordlearnersdictionaries.com

    dictionary.cambridge.org

    2026年1月9日星期五

    Learn from exercise

    std::deque (short for double-ended queue) is a container in C++ that allows fast insertion and deletion at both ends. It’s part of the Standard Template Library (STL).

    contiguous: touching or next to something

    #include <deque>
    #include <iostream>
    using namespace std;

    int main() {
        deque<int> dq;

        // Add elements
        dq.push_back(10);   // [10]
        dq.push_front(20);  // [20, 10]

        // Access elements
        cout << dq.front() << endl; // 20
        cout << dq.back() << endl;  // 10
        cout << dq[1] << endl;      // 10

        // Remove elements
        dq.pop_front(); // [10]
        dq.pop_back();  // []

        return 0;
    }

    dq[1] means "give me the element at index 1".

    Since C++ uses zero-based indexing, dq[0] is the first element, and dq[1] is the second element.

    ​intimidate somebody (into something/into doing something) to frighten or threaten somebody so that they will do what you want

    In C++, template is used to define generic functions or classes, while typename clarifies that a dependent name inside a template refers to a type.

    template <typename T>
    T add(T a, T b) {
        return a + b;
    }

    enum class in C++ is a strongly typed enumeration introduced in C++11. It improves upon traditional enum by providing better type safety and scoping.

    #include <iostream>
    using namespace std;

    enum class Color { Red, Green, Blue };
    enum class Fruit { Apple, Banana, Orange };

    int main() {
        Color c = Color::Red;
        Fruit f = Fruit::Apple;

        // Scoped access
        cout << (c == Color::Red) << endl;   // true
        cout << (f == Fruit::Banana) << endl; // false

        // No implicit conversion to int
        // int x = c; // ❌ Error

        // Explicit cast required
        int x = static_cast<int>(Color::Green); // ✅ Works
        cout << x << endl; // prints 1
    }

    In C++, the operator == is the equality comparison operator.

    It checks whether two values are equal.
    Returns a boolean (true or false).

    The symbol :: in C++ is called the scope resolution operator. It’s used to specify the scope in which a name (variable, function, class, etc.) is defined.

    Main Uses of ::

    1. Accessing Global Variables
    If a local variable shadows a global one, :: lets you access the global version:
    #include <iostream>
    using namespace std;

    int x = 10; // global

    int main() {
        int x = 20; // local
        cout << x << endl;   // prints 20
        cout << ::x << endl; // prints 10 (global x)
    }

    2. Accessing Class Members
    Used to define or access members outside the class body:
    class MyClass {
    public:
        static int value;
        void show();
    };

    int MyClass::value = 42; // define static member

    void MyClass::show() {   // define member function
        std::cout << "Value = " << value << std::endl;
    }

    3. Accessing Namespaces
    Used to access functions, classes, or variables inside a namespace:
    #include <iostream>
    namespace Math {
        int add(int a, int b) { return a + b; }
    }

    int main() {
        std::cout << Math::add(3, 4) << std::endl; // 7
    }

    4. Enumerations
    With enum class, you must use :: to access enumerators:
    enum class Color { Red, Green, Blue };

    Color c = Color::Red; // scoped access

    In programming, a dummy value usually means a placeholder value that doesn’t carry real meaning but is used temporarily.

    #include is a C++ standard library header that provides a collection of utility functions, classes, and templates commonly used in generic programming.

    Here is one of the most important components:

    std::pair

    • A simple container that holds two values.
    • Useful for returning two results from a function or storing key-value pairs.
    for (initialization; condition; update) {
        // code to execute repeatedly
    }

    Let’s combine a for loop with a switch statement in C++. This is a common pattern when you want to iterate through values and perform different actions depending on the case.

    #include <iostream>
    using namespace std;

    int main() {
        // Loop from 1 to 5
        for (int i = 1; i <= 5; i++) {
            switch (i) {
                case 1:
                    cout << "Case 1: Hello" << endl;
                    break; // exit switch

                case 2:
                    cout << "Case 2: World" << endl;
                    break;

                case 3:
                    cout << "Case 3: Foo" << endl;
                    break;

                case 4:
                    cout << "Case 4: Bar" << endl;
                    break;

                default:
                    cout << "Default case: i = " << i << endl;
                    break;
            }
        }
        return 0;

    - The for loop runs from i = 1 to i = 5.
    - Each iteration enters the switch block.
    - The case labels match specific values of i.
    - The break ensures the program exits the switch after executing one case (otherwise it would “fall through” to the next case).
    - The default handles values not explicitly (clearly or directly, so that the meaning is easy to understand) listed in cases.

    Case 1: Hello
    Case 2: World
    Case 3: Foo
    Case 4: Bar
    Default case: i = 5

    - break inside switch only exits the switch, not the for loop.
    - If you want to exit the entire loop from inside a switch, you can use break with a label (C++20) or goto, or simply return if inside main.

    for (const auto& op : operations) {
        // use op here
    }

    - operations → a container (like std::vector, std::deque, std::list, etc.).
    - op → each element in the container, one at a time.
    - auto& → deduces the element type automatically and binds it by reference (so no copy is made).
    - const → ensures you cannot modify the element inside the loop.

    if (!schedule.empty())

    - schedule → some container (like std::vector, std::deque, std::list, std::map, etc.).
    - .empty() → a member function that returns true if the container has no elements, false otherwise.
    - ! → logical NOT operator, flips the result.
    So the condition means:
     “If schedule is NOT empty, then execute the following block.

    Microsoft Copilot

    1970s Computers in Harvard University

    ECL: Extensible Computer Language

    LHASA (Logic and Heuristics Applied to Synthetic Analysis) is a computer program developed in 1971 by the research group of Elias James Corey at the Harvard University Department of Chemistry. The program uses artificial intelligence techniques to discover sequences of reactions which may be used to synthesize a molecule. This program was one of the first to use a graphical interface to input and display chemical structures.

    idle: ​(of machines, factories, etc.) not in use

    The RAND Tablet is a graphical computer input device developed by The RAND Corporation.

    stylus: (computing) a special pen used to write text or draw an image on a special computer screen

    ubiquitous: seeming to be everywhere or in several places at the same time; very common

    Chevrolet is an American automobile division of the manufacturer General Motors.

    Digital Equipment Corporation (DEC) using the trademark Digital, was a major American company in the computer industry from the 1960s to the 1990s.

    tinker (with something) to make small changes to something in order to repair or improve it, especially in a way that may not be helpful

    legendary: very famous and talked about a lot by people

    Spawn in computing refers to a function that loads and executes a new child process.

    frivolous: ​(of people or their behavior) silly or funny, especially when such behavior is not suitable

    snowflake: a small soft piece of frozen water that falls from the sky as snow

    groundbreaking: making new discoveries; using new methods

    A computer rack is a metal frame that is used to keep different hardware devices such as servers, hard disk drives, modems, and other electronic equipment.

    Sketchpad is a computer program written by Ivan Sutherland in 1963 in the course of his PhD thesis.

    "By then" is a phrase indicating a point in the future or past that has already been established in the conversation

    soup up: (informal) to make changes to something such as a car or computer, so that it is more powerful or exciting than before

    harness something to control and use the force or strength of something to produce power or to achieve something

    nifty: practical; working well

    devise something: to invent something new or a new way of doing something

    Xerox PARC (Palo Alto Research Center) is a legendary R&D center by Xerox that invented foundational technologies for modern computing, including the graphical user interface (GUI), mouse, Ethernet, laser printers, bitmap graphics, and object-oriented programming (OOP) (Smalltalk).

    PostScript (PS) is a page description language and dynamically typed, stack-based programming language.

    cockpit: the area in a plane, boat or racing car where the pilot or driver sits

    A baseball pitch is the act of a pitcher throwing the ball to the batter to start a play, varying velocity, movement, and location using different grips (like four-seam fastball, curveball, slider, changeup) to deceive the hitter and get an out.

    "Scooping" in baseball is a fielding technique, especially for first basemen, to cleanly catch low throws or ground balls by digging the glove down and "up" to get under the ball, preventing it from going in the dirt.

    A pop fly (or pop-up) in baseball is a short, high, arcing batted ball, usually hit to the infield, that doesn't travel far and is often an easy catch for an out, though sometimes dropped due to sun or misjudgment, leading to potential errors.

    shortstop: (in baseball) a player who tries to stop balls that are hit between second and third base; the position of this player

    aka: also known as

    deliberately: done in a way that was planned, not by chance

    hype: advertisements and discussion in the media telling the public about a product and about how good or important it is

    quirk: a strange thing that happens, especially by accident

    de facto: (from Latin, formal) existing as a fact although it may not be legally accepted as existing

    subsist (on something) to manage to stay alive, especially with limited food or money

    suite: a set of rooms, especially in a hotel

    trivia: unimportant matters, details or information

     ALaserDisc (LD) used for music, often featuring music videos, concerts, or high-fidelity audio, predating DVDs, known for its large 12-inch size (like vinyl LPs) and ability to hold both video and high-quality stereo/surround sound

    instill: to gradually put an idea or attitude into somebody's mind; to make somebody feel, think or behave in a particular way over a period of time

    obsession: the state in which a person’s mind is completely filled with thoughts of one particular thing or person in a way that is not reasonable or normal

    mundane: not interesting or exciting

    a restaurant where you choose and pay for your meal before you carry it to a table. Cafeterias are often found in factories, colleges, hospitals, etc.

    pinball: a game played on a pinball machine, in which the player sends a small metal ball up a sloping board and scores points as it bounces off objects. The player tries to prevent the ball from reaching the bottom of the machine by pressing two buttons at the side.

    abortion: the deliberate ending of a pregnancy at an early stage

    crook: (informal) a dishonest person

    coed: a female student at a co-educational school or college

    velvet: ​a type of cloth made from silk, cotton or nylon, with a thick, soft surface

    bell-bottoms: trousers with legs that become very wide below the knee

    posse: (informal) a group of people who are similar in some way, or who spend time together

    if people do or say something in unison, they all do it at the same time

    stammer: to speak with difficulty, repeating sounds or words and often stopping, before saying things correctly

    bushwhack: To bushwhack means to move through thick, uncleared terrain by cutting a path (like in hiking or exploring)

    meld: to combine with something else; to make something combine with something else

    congeal: (of blood, fat, etc.) to become thick or solid


    Bill Gates "Source Code"

    Online Dictionaries Used:

    hk.dictionary.search.yahoo.com

    www.oxfordlearnersdictionaries.com

    Google AI overview

    2026年1月6日星期二

    Function objects

    In C++, a function object (also called a functor) is any object that can be called like a function using the operator(). They are widely used in the Standard Template Library (STL) for algorithms, sorting, and predicates because they can hold state and be passed as types.

    - A function object is a class or struct that overloads the operator().
    - This allows instances of the class to be used with function-call syntax.
    - Unlike normal functions, function objects can store state (data members) and be customized.

    In C++, operator overloading allows you to redefine how operators (like +, -, [], (), etc.) behave for user-defined types such as classes and structs. This makes objects act more like built-in types and enables intuitive syntax for complex data structures.

    class Point {
        int x, y;
    public:
        Point(int a, int b) : x(a), y(b) {}  // Parameterized constructor
        void display() { std::cout << x << ", " << y << std::endl; }
    };

    1. Data Members
    - int x, y; → These represent the coordinates of the point.
    - They are private by default (since no access specifier is given before them)

    2. Parameterized Constructor
    - This constructor takes two arguments (a and b) and initializes x and y.
    - The member initializer list (: x(a), y(b)) is the recommended way to initialize members because it’s efficient and works well with const/reference members

    3. Member Function
    - Prints the point’s coordinates in (x, y) style.

    x is a data member (or field) of the class Point.
    - It belongs to each object of the class.
    - It represents the state of the object (the x-coordinate of the point).
    - Stored inside the object itself.

    a is a constructor parameter (a local variable passed into the constructor).
    - It exists only during the execution of the constructor.
    - It is used to initialize the data member x.

    How They Work Together
    When you write:
    Point(int a, int b) : x(a), y(b) {}

    - a and b are temporary input values.
    - x and y are the persistent attributes of the object.
    - The initializer list : x(a), y(b) assigns the values of a and b to the object’s members x and y.
    Example:
    Point p1(3, 4);
    p1.display(); // Output: 3, 4

    - Here, a = 3, b = 4 (constructor parameters).
    - These values are stored into x = 3, y = 4 (object’s data members).
    - After the constructor finishes, a and b disappear, but x and y remain inside p1.

    Analogy
    Think of it like filling out a form:
    - a is the value you write on the form (temporary input).
    - x is the information stored in the database (permanent attribute of the object).

    Summary:
    - x is a member variable of the class (lives as long as the object exists).
    - a is a constructor parameter (temporary, exists only while the constructor runs).
    - The constructor uses a to initialize x.

    MultiplyBy multiplyBy5(5);

    1. MultiplyBy → the class name
    - This tells the compiler what type of object you want to create.
    - In this case, you’re saying: "I want an object of type MultiplyBy."

    2. multiplyBy5 → the variable name
    - This is the name you’re giving to the object you’re creating.
    - You could call it anything: m, functor, timesFive, etc.

    3. (5) → the constructor argument
    - This passes the value 5 into the constructor of MultiplyBy.
    - That sets the private member factor_ to 5.

    encapsulate something (in something) to express the most important parts of something in a few words, a small space or a single object

    functionality: (computing) the range of functions that a computer or other electronic system can perform

    In C++, a std::pair is a simple container that holds two values (often of different types) together as a single unit.

    const std::pair<std::string, int>& enemy
    - enemy is a reference to a std::pair object.
    - No copy of the pair is made — this avoids unnecessary overhead, especially when working with large objects.
    - The const ensures you cannot modify the original pair through this reference.

    std::sort(enemies.begin(), enemies.end(), SortByHealth());
    - Comparator provided: SortByHealth is a functor that defines how two elements should be compared.
    - Sorting criterion: In your case, enemies are sorted by their health (second element of the pair).

    std::sort(enemies.begin(), enemies.end());
    - No comparator provided: std::sort uses the default operator < for the element type.
    - Sorting criterion: For std::pair, the default < works lexicographically:
    - First compares first (the string name).
    - If the names are equal, then compares second (the health).
    - Result: Enemies would be sorted alphabetically by name, not by health.

    - bool operator() defines the comparison logic.
    - std::sort calls this operator repeatedly to decide the order.

    A lambda expression is a concise way to define an anonymous function (a function without a name) that can be used where a function is expected, such as an argument to another function or assigned to a variable. They are widely used in many modern programming languages, including Python, Java, C#, and C++, to write cleaner, more readable, and efficient code.

    Lambda with Parameters:

    #include <iostream>

    int main() {
        auto add = [](int a, int b) {
            return a + b;
        };

        std::cout << "Sum: " << add(3, 4) << std::endl;  // Output: 7
    }

    Using Lambda in Sorting:

    #include <iostream>
    #include <vector>
    #include <algorithm>

    int main() {
        std::vector<int> scores = {10, 40, 20, 50, 30};

        // Sort descending using a lambda
        std::sort(scores.begin(), scores.end(),
                  [](int a, int b) { return a > b; });

        for (int score : scores)
            std::cout << "Score: " << score << std::endl;
    }

    Explanation of local scope operations:

    #include <iostream>
    using namespace std;

    int main() {
        int x = 10;  // global to main()

        {
            int y = 20;  // local to this block
            cout << "Inside block: x = " << x << ", y = " << y << endl;
        }

        // y is not accessible here
        // cout << y;  // Error: 'y' was declared in a local scope

        return 0;
    }

    Microsoft Copilot