2024,江端さんの技術メモ

/*
	c:\users\ebata\dscan\dscan3.go

	DBSCANアルゴリズムを実装し、3次元空間のデータ(x、y、t)をクラスタリングするシンプルなプログラムです。
	このプログラムでは、各データポイントは3次元座標(x、y、t)で表され、距離の計算にはユークリッド距離を使用します。

	DBSCANをk-meansの違いで説明します。

	DBSCAN(Density-Based Spatial Clustering of Applications with Noise)とk-meansは、クラスタリングアルゴリズムですが、そのアプローチや動作原理にはいくつかの違いがあります。

	(1)クラスタリング方法:

	- DBSCAN: 密度ベースのクラスタリングアルゴリズムであり、データポイントの密度に基づいてクラスタを形成します。各点は、一定の距離(ε、epsilon)内に最小限の近傍点数(minPts)が存在する場合、その点を中心としたクラスタが形成されます。
	- k-means: 距離ベースのクラスタリングアルゴリズムであり、データポイントの距離に基づいてクラスタを形成します。クラスタの数(k)を事前に指定し、各点を最も近いセントロイド(クラスタの中心)に割り当てます。

	(2)クラスタの形状:

	- DBSCAN: クラスタの形状は任意であり、密度の高い領域に基づいて形成されます。したがって、DBSCANは非凸形状のクラスタを処理できます。
	- k-means: クラスタの形状は円形(球形)であり、各クラスタのセントロイドからの距離に基づいて決定されます。したがって、k-meansは凸形状のクラスタを前提としています。

	(3)ハイパーパラメータ:

	- DBSCAN: ε(epsilon)とminPtsの2つのハイパーパラメータを必要とします。εは近傍点の距離の閾値を定義し、minPtsはクラスタと見なすための最小の近傍点数を指定します
	- k-means: クラスタの数(k)を指定する必要があります。

	(4)ノイズの処理:

	- DBSCAN: ノイズポイントを自動的に検出し、外れ値として扱います。密度が低い領域に存在するポイントは、任意のクラスタに割り当てられず、ノイズとして扱われます。
	-k-means: 外れ値やノイズの処理を明示的に行いません。各点は必ずどれかのクラスタに割り当てられます。

	 要するに、DBSCANは密度ベースのアルゴリズムであり、任意の形状のクラスタを検出し、ノイズを処理する能力があります。一方、k-meansは距離ベースのアルゴリズムであり、クラスタの形状が円形であることを前提としています。


*/

package main

import (
	"fmt"
	"math"
)

// Point represents a 3D point with coordinates x, y, and t
type Point struct {
	X, Y, T float64
}

// DistanceTo calculates the Euclidean distance between two 3D points
func (p Point) DistanceTo(other Point) float64 {
	dx := p.X - other.X
	dy := p.Y - other.Y
	dt := p.T - other.T
	return math.Sqrt(dx*dx + dy*dy + dt*dt)
}

// Cluster represents a cluster of points
type Cluster struct {
	Points []Point
}

// DBSCAN performs density-based clustering of 3D points
func DBSCAN(points []Point, epsilon float64, minPts int) []Cluster {
	var clusters []Cluster
	var visited = make(map[Point]bool)

	for _, point := range points {
		if visited[point] {
			continue
		}
		visited[point] = true

		neighbours := getNeighbours(points, point, epsilon)
		if len(neighbours) < minPts {
			continue
		}

		var clusterPoints []Point
		expandCluster(&clusterPoints, points, visited, point, neighbours, epsilon, minPts)
		clusters = append(clusters, Cluster{Points: clusterPoints})
	}

	return clusters
}

// getNeighbours returns all points within distance epsilon of the given point
func getNeighbours(points []Point, point Point, epsilon float64) []Point {
	var neighbours []Point
	for _, other := range points {
		if point.DistanceTo(other) <= epsilon {
			neighbours = append(neighbours, other)
		}
	}
	return neighbours
}

// expandCluster expands the cluster from the given point
func expandCluster(cluster *[]Point, points []Point, visited map[Point]bool, point Point, neighbours []Point, epsilon float64, minPts int) {
	*cluster = append(*cluster, point)
	for _, neighbour := range neighbours {
		if !visited[neighbour] {
			visited[neighbour] = true
			neighbourNeighbours := getNeighbours(points, neighbour, epsilon)
			if len(neighbourNeighbours) >= minPts {
				expandCluster(cluster, points, visited, neighbour, neighbourNeighbours, epsilon, minPts)
			}
		}
		// Add neighbour to cluster if not already in another cluster
		var isInCluster bool
		for _, c := range *cluster {
			if c == neighbour {
				isInCluster = true
				break
			}
		}
		if !isInCluster {
			*cluster = append(*cluster, neighbour)
		}
	}
}

func main() {
	// Example usage
	points := []Point{
		{X: 1, Y: 2, T: 0},
		{X: 1.5, Y: 1.8, T: 1},
		{X: 5, Y: 8, T: 2},
		{X: 8, Y: 8, T: 3},
		{X: 1, Y: 0.6, T: 4},
		{X: 9, Y: 11, T: 5},
		{X: 8, Y: 2, T: 6},
		{X: 10, Y: 2, T: 7},
		{X: 9, Y: 3, T: 8},
	}

	epsilon := 3.0
	minPts := 2

	clusters := DBSCAN(points, epsilon, minPts)
	for i, cluster := range clusters {
		fmt.Printf("Cluster %d:\n", i+1)
		for _, point := range cluster.Points {
			fmt.Printf("  (%.2f, %.2f, %.2f)\n", point.X, point.Y, point.T)
		}
	}
}

2024,江端さんの忘備録

原作者と二次著作者の間における超有名な事件といえば、「キャンディキャンディ事件」のはずですが、先日の事件と併わせた形では、この話題を見ません。

The most famous case between an author and a secondary author should be the "Candy Candy Case," but I have not seen this topic discussed in conjunction with the recent case.

もしかしたら、「これが、『業界タブー』という奴なのかもしれないなぁ」と、空気の読めない江端(私)は思っています。

Perhaps this is called an "industry taboo," thinks Ebata (me), who can't read the air.

著作権法には、『原作者最強』は絶対的ですが、利益が絡んでくると『金持ち最強』になってしまうのは、どこの世界でも同じようです。

In copyright law, 'the original author is the strongest' is absolute, but when profit is involved, 'the rich are the strongest' seems the same in every world.

-----

この問題は、創作者や研究者自身にとっても、あまり触れたくないものなのです。

This is an issue that creators and researchers do not want to touch.

私のコラムは、色々な書籍やオープンデータをベースにしていますし、私のイラストも他の方の記載されたイラストや写真を参考にしています。

My columns are based on various books and open data, and my illustrations are based on illustrations and photos described by others.

研究活動に至っては、既往研究の論文がなくては、1mmも進めることができません。

Regarding research activities, not a single millimeter of progress can be made without a paper on previous research.

逆に、私の創作物が、他の著作で引用されていることもあります(転用や盗用も山ほどあります)。

Conversely, my creations are sometimes cited in other works (and there are plenty of diversions and plagiarism).

執筆したけど特許権にできなかった私の特許明細書の一つが、70以上もの、後願の特許出願を拒絶査定に追い込んだという話も聞きました(これを、『先行発明の後願排除効』といいます)。

I have heard that one of my patent specifications, which I wrote but could not patent, has rejected more than 70 subsequent patent applications (the "effect of exclusion of subsequent applications for prior inventions").

何が言いたいかというと、『先行著作物と全く無関係な創作活動』は、『幻想である』ということです。

I am trying to say that 'creative activity completely unrelated to prior works' is 'an illusion.

-----

ともあれ、今クリエイターに求められているのは、何よりもまず創造活動そのものであることは言うまでもありません。

At any rate, what is now required of creators is, of course, first and foremost, the creative activity itself.

でも、その次に重要なのは、法律(著作権法)の勉強かもしれません。

But the next most crucial thing might be to study the law (copyright law).

面倒くさいですけど、自分の著作物と自分の命を守る為には、必要なことです。

It's a hassle, but protecting your work and life is necessary.

未分類

その1
Go言語で、250人分のエージェントを作成して、次の処理にかかろうとして
"for"
と書いただけで、
    for i := 0; i < 250; i++ {
        fmt.Println("person[", i, "].Origin:", person[i].Origin.Name, person[i].Origin.Loc.Lng, person[i].Origin.Loc.Lat)
        fmt.Println("person[", i, "].Destination:", person[i].Destination.Name, person[i].Destination.Loc.Lng, person[i].Destination.Loc.Lat)
        fmt.Println("person[", i, "].Route:", person[i].Route)
    }

と、ここまで、自動的にコードを提案された。

その2
Go言語で、
// 時速4kmの場合、1秒間に移動する距離は、
と書いたら、
Copilotが、その後ろに、
4km/h ÷ 3600s/h = 0.00111111111km = 1.11111111m
と、文案を提案してきた。
正直、怖い

2024,江端さんの忘備録

最近、「マルハラ」という新しい種類のハラスメントが話題になっているようです。

Recently, a new type of harassment called "maru-harassment" has become a hot topic.

「承知しました。」という一見、何の変哲もないフレーズの、最後の「。」が怖いということから命名されたハラスメントだそうです。

"It's O.K.." This harassment is named by youth because some fear the "." of the last of "It's O.K.."

もちろん、これを一蹴することは易いですし、反論もできますが ―― 多分、そいうことではないと思うのです。

Of course, it's easy to kick this out and argue -- but maybe that's not the point.

-----

私は、『ハラスメントとは、それを感じる者、すなわち、被害者が一方的に決めつけるもので、加害者は、それに抗弁できない』と認識しています。

I recognize that 'harassment is a unilateral decision made by the one who feels it, i.e., the victim, and the perpetrator has no defense against it.

私たちシニアは、ここ20年くらいの間、それを「セクハラ」や「パラハラ」で思い知ってきました。

We seniors have been reminded of this with "sexual harassment" and "power-harassment" for the last 20 years or so.

「セクハラ=コミュニケーション」、「パワハラ=教育」と言われた時代は、確かにあったし、その時代は、そういう取り扱いでも問題はなかったのです(正確には『当事者には大問題だったけど、世間は取り合ってくれなかった』が正しい)。

There was undoubtedly a time when "sexual harassment = communication" and "power harassment = education," and there was no problem with such treatment in those days (more accurately, "it was a big problem for the parties involved, but the public didn't take it up" is correct).

でも、時代は変わり、社会の価値観が変わり、そして、"昔"は許されても、"今"は許されない「社会悪」です。

But times change, society's values change, and what was acceptable in the past is unacceptable today.

ここで重要なのは「絶対悪(殺人や暴力)」とは異なり、「社会悪」は、日々変化し続けているということです。

It is important to note that unlike "absolute evil" (murder and violence), "social evil" is constantly changing from day to day.

で、このような、変化する社会悪にフォローできないのがシニア(具体的には、私を含む、ジジイとババア)です。

And it is the seniors (the old guys and old ladies, including me) cannot follow up on these changing social evils.

シニアの私としては、政府から「本日から施行される『社会悪』」として官報(*)を出して欲しいくらいです。

As a senior citizen, I want to see the government issue an official gazette(*) as "a 'social evil' that goes into effect today."

(*)官報とは、国の広報誌で、、法律・政令・条約などを公布する媒体として、重要な役割をもっている

(*)The Official Gazette is a government public relations magazine and plays an important role as a medium for promulgating laws, government ordinances, treaties, etc.

それはさておき。

Aside from that.

-----

「マルハラ」という観点から言えば、私のブログは「マルハラ」が満載です。

Regarding "maru-harassment," my blog is full of "maru-harassment."

私の文章は長いから、当然、句読点も山盛りです。

My sentences are long, so naturally, there is a lot of punctuation.

そして、何より、"。"を怖がる人が、耐えられるようなコンテンツではありません。

And above all, these are not the kind of content that people who are afraid of "." will be able to tolerate.

SNSのコミュニケーションツールと、ブログや小説を同じカテゴリーで語るのは無理があるかもしれませんが。

Discussing social networking communication tools, blogs, or novels in the same category may be unreasonable.

-----

ただ、この「マルハラ」とはちょっと違うのですが、思い当たることがあります。

However, I can think of something different from this "maru-harassment."

私のページには、大体一日4000人~5000人の皆さんにご訪問頂いていて、これは、ここ2~3年ほど変動がありません(PVは、その1.5~2倍程度)。

My pages are visited by roughly 4,000 to 5,000 people daily, which has not changed for the past 2 to 3 years (PV is about 1.5 to 2 times that number).

「2~3年間、変動がないことをどう考えるか 』―― これは、なかなかに難しいのです。

"How should I think about the fact that there will be no change for two to three years?" This is a tricky question.

私の文章は、独特で、基本的に内容はキツい(強烈な批判と皮肉の集大成)です。

My writing is unique, and the content is harsh (a collection of solid criticism and sarcasm).

これを毎日読み続けるのは、私ですら、結構な体力が必要です。

It takes a lot of strength, even for me, to keep reading this every day.

私のサイトは、いわば「江端ハラスメント」、"エバハラ"と命名しても良いレベルです。

My site is at the level of "Ebata harassment," so to speak, which I may name "Ebahara.

それゆえ、毎日、ご訪問して頂いている皆様は、まさに、この"エバハラ"を乗り越えた勇者である、と言えるのではないか、と思っています。

Therefore, I believe those of you who visit my pages daily are the brave ones who have overcome this "ebaharah.

少なくとも、「マルハラ」に怯える若者が入って来られるようなブログではない、と思います。

At the very least, I think it is not the kind of blog that young people frightened of "maru-harassment" can enter.

逆に言えば、このブログに集って頂いているこの4000~5000人の皆様は、この江端の"エバハラ"に相対しうる「勇者」であると認定できると思います。

Conversely, the 4,000 to 5,000 of you gathered on this blog can be identified as the "brave" who can stand up to Ebata's "ebahara.

私は、あなたのことを「勇者 ―― ビヨンド エバハラ」、省略して「エバハラ勇者」と命名したいと思います。

I want to name you "Brave -- Beyond Ebahara," or "Ebahara Brave" for short.

でも、少なくとも「エバハラ勇者」は"尊称"にはならないでしょう ―― むしろ、悪い"レッテル"になりそうです。

But at the very least, "Ebahara brave" will not be a "title" -- rather, it will be a bad "label."

これらを忌避して生きてもいいんですか ―― いいんです(楽天カードのCM風)。

 

 

2024,江端さんの忘備録

私、これまで、日常生活やブログで、色々なことを言ってきました。

I have said many things in my daily life and on my blog.

逆に言っていないことは何だろうな、と考えた時、私は、

When I wondered what I hadn't said to the contrary,

『人を育てる』

"Nurturing People"

というフレーズを使ったことがありません。

I have never used the phrase

(過去の日記を全検索しましたが、確かにありませんでした)

(I searched all past diaries, and it was not there.)

-----

私は、自分の子どもですら『育てる』と思ったことはないです ―― あれは『勝手に育った』です。

I've never thought of even my children as 'Nurturing' -- that was 'Nurtured on their own.

まあ、明らかに間違ったことについては、すさまじい勢いで叱りとばしたことはありますが、それも数えるくらいしか覚えていません。

I have scolded them tremendously for wrong things, but I can only remember a few.

私がやったのは、彼女らの生活インフラの提供と整備と保守だけです(必要なら、組織を壊滅させるくらいのつもりで闘かったこともありますが)。

All I did was provide, build, and maintain the infrastructure for their lives (although I also fought to the point of destroying the organization if necessary).

私の場合、『子どもを育てた』などと言うつもりはありません。

In my case, I will not say that I Nurtured my children or anything like that.

なぜか。

Why?

私は、そんな、面倒くさいことはしたくなかったからです。

Because I didn't want to go through all that hassle.

-----

会社の管理職向けの資料とか読んでいると、『部下を育てる』などという文言が出てきます。

When I read materials for company managers, I see phrases such as "nurture subordinates.

純粋に『凄いなぁ』と感心しています(嫌味ではなく)。

I am genuinely impressed (no sarcasm intended).

私は、人を動かすための"策"は考えますが、それは『人を育てる』ためではありません。

I think of "measures" to move people, but not to "train" them.

純粋に、自分がラクをするためです。

It is purely to make things easier for me.

-----

私が、長い間、サラリーマンをやってきて分かったことは、『人を育てる』などというセリフを平気で使う奴は、大抵、『人を潰している』という現実です。

Through my long career as a salaried worker, I have learned that those who use phrases such as "nurturing people" without hesitation are usually "destroying people.

これは、私の数少ない特技である、発明や特許明細書の作成したプロセスの視点になってしまいますが、特に顕著だったのが、発明創成という業務です。

This is one of my few specialties from the perspective of how inventions and patent specifications were created. Still, it was particularly noticeable in the work of invention-creation.

私は、『若い研究員が必死で案出した、生れたての弱々しく小さな発明を、自分の経験や知見で叩き潰す阿呆な上司たち』を、うんざるするほど見てきました。

I have seen enough of "stupid bosses who crush the freshly born, feeble little inventions of young researchers with their own experience and knowledge.

発明というは、『新生児』のように弱く小さい存在として生まれてきます。

The invention is born as a weak and small being, like a 'newborn.'

この『新生児』に栄養を与えて、歩けるようにして、強い特許権に育て上げることが、上司の役目です。

The boss's role is to nourish this "newborn" and raise it into a strong patent right by enabling it to walk.

これを、『人を育てる』と言いながら、『新規性がない』だの『進歩性がない』などと言って、この新生児を殺し続ける上司を見てきました。

I have seen bosses who say this is 'nurturing people' but continue to kill these newborns because they are 'not novel' or 'not progressive.'

ともあれ、私は、

Anyway, I thought, 

- 何やってんだ? その「新生児」を、苦労しながら一緒に育てていくのが、上司の役目だろう?

- What are you doing? Isn't it the role of the boss to raise that "newborn baby" with you while struggling to make it work?

- 一体、どの口が『部下を育てる』と言っているんだ?

- What in the world are you talking about "Nurturing subordinates"?

と、思ってきました。

-----

しかし、まあ、これは私のちっちゃいスコープの中の一例に過ぎません。

But, well, this is just one example in my tiny scope.

私の狭い視野と経験で、人材育成を論じるのは、おこがましいとさえ思います。

It would be presumptuous of me to discuss human resource development from my narrow perspective and experience.

ともあれ、『人を育てる』ことを『面倒くさい』と考える私が、組織を率いる立場にならなかったことは、極めて当然である、と、深く納得しています。

Anyway, I am deeply convinced that it is pretty natural that I, who consider "Nurturing people" to be "troublesome," have not been in a position to lead an organization.

愛国心

2024,江端さんの忘備録

『閉じたコミュニティの中だから大丈夫』

'It's okay because it's in a closed community.'

レストランで調味料容器を舐める映像を、閉じたネットワークに転送した者が口にする言葉です。

These are the words uttered by the person who transmitted the image of licking a condiment container in a restaurant to a closed network.

この行為の低能さについては、多くの人が語っているので、私は論じません。

I will not discuss the lowliness of this action, as many have spoken of it.

-----

ただ、私が若い頃に、この低能さを無条件に批判できるかと問われれば ―― できないような気がします。

However, if you ask me if I could unconditionally criticize this lowly behavior when I was younger -- I don't think I could.

私は、褒められた若者ではありませんでしたから。

Because I was not a praiseworthy young man.

若い頃の私は、お上(学校とか、役所とか、国家権力の暴力装置(警察等))に、はむかう行為をしていました。

When I was young, I used to be against the higher-ups (schools, government offices, and the violent apparatus of state power (police, etc.)).

もし、当時、今のようなネット環境があったとしたら、これらの行為は、デジタルの記録で残されて、それを理由に生涯ネチネチと苛められていたと思います。

If there had been an Internet environment back then, as there is today, these acts would have been digitally recorded, and I would have been tormented for the rest of my life for them.

『愚かさ』という観点においては、若いころの私は『調味料容器を舐める若者と大して差はない』と思っています(ただ、行為の品格については、差はあると思っていますが)。

In terms of 'stupidity,' I believe that when I was younger, I was 'not much different from a young man licking a condiment container' (although I think there is a difference in the dignity of the act).

私は、ネットがない時代に生まれて、たまたま運が良かっただけです。本当にそう思っています。

I just happened to be lucky enough to be born without the Internet. I genuinely believe that.

それはさておき。

Aside from that.

-----

人間には『楽しいコンテンツは、他人と共有したい』という欲望があります。

Humans have a desire to 'share enjoyable content with others.

いわゆる『他の人には言わないでね。実は・・』です。

It's the so-called 'Don't tell anyone else. Actually...'.

『閉じたコミュニティの無限連鎖』といっても良いかもしれません。

You might call it "an endless chain of closed communities.

ネットに関して言えば、『閉じたコミュニティ』は、幻想です。

Regarding the Internet, 'closed communities' are an illusion.

ですから、秘密にする必要がある情報(犯罪構成要件を成立させる証拠など)は、秘密にしておく必要があるのです。

Therefore, information that needs to be kept secret (e.g., evidence that establishes the requirements for constituting a crime) needs to be kept secret.

つまるところ、「犯罪行為なら最初から止めておけ」ということになるのですが、大人であっても、「犯罪行為」と「いたずら」の区別がつかない、という人は数多くいます。

In the end, the bottom line is that "if it is a criminal act, stop it from the beginning," but there are many people, even adults, who cannot distinguish between a "criminal act" and a "prank.

-----

ちなみに、私の場合、「他の人には言わないでね」と言われたら、その場で「期限は?」と応答します。

By the way, if someone says to me, "Don't tell anyone else about this," I'll be right there with them, "What's the deadline?" I respond with.

「無期限」と言われたら、「約束できない」と応答します。

If they say "indefinitely," I respond, "I can't promise."

「10年間」と言われても、「約束できない」と応答します。

If they say, "for ten years," I reply, "I can't promise that."

「1年間」と言われたら、「それなら約束してもいい」と応答し ―― そして、1年後に暴露します。

If they say "one year," you respond, "I can promise you that," -- and then expose them a year later.

-----

この例外として、自分に課しているのが『江端ファイアウォール』です。

The exception to this is the "Ebata Firewall" that I have imposed on myself.

「江端ファイアウォール」とは

これは、私の尊厳の根幹であり、これを破った時、私は私であることを停止する覚悟があります。

This is the foundation of my dignity, and when I violate it, I am prepared to stop being me.

私は『他の人には言わないでね、実は・・』という人を、『下品な人間』として見下すことができるよう、日々努めています。

I try every day to be able to dismiss people who say, 'Don't tell anyone else, actually...' as 'vulgar people.

2024,江端さんの技術メモ

を起動したら、

となることがあるので、この対応方法をメモしておきます。

https://app.mindmanager.com/ と入力(#my-filesはつけない)

ファイルが表示されるので、これを選択。

表示されるようになる。


のプロパティを開いて新しいURLをコピペする。

以上

2024,江端さんの技術メモ

本プログラムは、

Webサーバに繋っているブラウザが、全部いなくなったことを確認するプログラム

を拡張したものです。index.htmlは、このページに記載されているものを、そのまま、使って下さい。

こちらのプログラムでは、Webサーバに繋っているブラウザが、全部いなくなったと確認できた場合(30秒後)に、url = "http://localhost:8000/cancelAllVideoStreamGround"へメッセージを渡すプログラムです。

デバッグの為に使っていたコメントが残っていますので、適当に削除して下さい。

# c:\users\ebata\webMonitor.py
# https://wp.kobore.net/%e6%b1%9f%e7%ab%af%e3%81%95%e3%82%93%e3%81%ae%e6%8a%80%e8%a1%93%e3%83%a1%e3%83%a2/post-12475/を参照のこと

import threading
import time
import requests
import sys
from flask import Flask, request, jsonify
from requests.exceptions import Timeout
from flask_cors import CORS


app = Flask(__name__)

CORS(app)  # すべてのリクエストに対してCORSを有効にする

last_heartbeat_time = 0
lock = threading.Lock()

def send_notification():
    url = "http://localhost:8000/cancelAllVideoStreamGround"
    try:
        response = requests.post(url, timeout=3)
        response.raise_for_status()
        print("Notification sent successfully.")
        sys.stdout.flush()  # 標準出力をフラッシュする
    except Timeout:
        print("Error: Timeout while sending notification")
    except requests.exceptions.RequestException as e:
        print(f"Error sending notification: {e}")

def check_heartbeat():
    global last_heartbeat_time
    while True:
        current_time = time.time()
        print("ct:",current_time)
        print("lht:",last_heartbeat_time)
        diff = current_time - last_heartbeat_time
        print("diff:",diff)
        with lock:
            if current_time - last_heartbeat_time > 30:
                send_notification()
                last_heartbeat_time = current_time
        time.sleep(1)

@app.route('/heartbeat', methods=['POST'])
def receive_heartbeat():
    print("pass receive_heartbeat()")
    global last_heartbeat_time
    data = request.get_json()
    print(f"Received heartbeat: {data}")
    sys.stdout.flush()  # 標準出力をフラッシュする
    with lock:
        last_heartbeat_time = time.time()
        print("lht_2:",last_heartbeat_time)
    # data = request.get_json()
    # print(f"Received heartbeat: {data}")
    # sys.stdout.flush()  # 標準出力をフラッシュする
    return jsonify({"status": "OK"})

if __name__ == "__main__":
    heartbeat_thread = threading.Thread(target=check_heartbeat)
    heartbeat_thread.start()
    app.run(host='0.0.0.0', port=3000)

私用のコメント
(1)receive_heartbeat():と receive_heartbeat()を同時に走らせる為に、スレッド化しなければならなくなった → で Ctrl-Cで止められなくなったので、ちょっと困っている(が、シェル画面ごと落せばいいので、現在はそうしている)

(2)url = "http://localhost:8000/cancelAllVideoStreamGround" からの時間がもたつく場合には、Timeoutを設定すると良いかもしれない。send_notification()を丸ごと差し替えると、こんな感じ。

def send_notification():
    url = "http://localhost:8000/cancelAllVideoStreamGround"
    try:
        response = requests.post(url, timeout=3)
        response.raise_for_status()
        print("Notification sent successfully.")
        sys.stdout.flush()  # 標準出力をフラッシュする
    except Timeout:
        print("Error: Timeout while sending notification")
    except requests.exceptions.RequestException as e:
        print(f"Error sending notification: {e}")

(3)Webブラウザは、バックエンドに置いておくと、Heatbeatを出力しないことがあるので、常にアクティブにしておく必要があります(バックエンドのままにしておくと、cancelAllVideoStreamGroundが動き出します)

以上

2024,江端さんの忘備録

私、新しい技術が入ってきても、基本的には信じません。

I don't believe in new technology when it comes in.

その新しい技術とやらを真面目にやって、膨大な時間を喰われた挙げく、市場から消え去ったものを、本当に腐るほど見てきたからです。

I have seen so many things that have disappeared from the market after being eaten up by the enormous amount of time spent on serious work on that new technology that it is rotten.

そもそも「スゴい」と言われる技術の殆どが、『今はショボいけど、すぐに流行るようになる』という「前置き」つきであるからです。

In the first place, most of the technologies that are called "awesome" are prefaced with the phrase, "It's a bit timid now, but it will soon become popular.

で、この私の怨念が集約が、この連載シリーズだったりします。

And this series of articles is the culmination of my resentment.

 

-----

私が自分に「スゴい」を信じさせるか否かは、簡単です。

Whether or not I make myself believe in "awesome" is easy.

私が実際に使ってみて「スゴい」と思えれば、それは「スゴい」のです。

If I use it and think it is "awesome," then it is "awesome."

そして、『自腹を切っても使いたい』と思えるものであれば、その「スゴい」は確定です。

And if it is something that 'I want to use even if I have to pay for it myself,' then its 'awesome' is confirmed.

他人の意見を聞く必要はありません。この私が知っているからです。

You don't need to listen to others' opinions. Because of this, I know.

-----

私は、社内のエライさんから通達される『これからば、XXXXXの時代』という言葉を、原則として信じません。

As a rule, I don't believe in the "XXXXXX era" that is being communicated to me by the elites in my company.

『お前らに、これまで、何度騙されてきたことか』 ―― という膨大な記憶があるからです。

I have a vast memory of "How many times have you people fooled me?

しかし、"XXXX"が"生成AI"であれば、抵抗なく受けいれることができます。

However, if "XXXX" is a "Generative AI," it can be accepted without resistance.

これは、私にとって「スゴい」です。本当です。

This is "awesome" to me. It's true.

しかし、この「スゴい」は、私の業務や学業に特化していますので、生成AIが、多くの人にとって「スゴい」のかどうかは正直分かりません。

However, this "awesome" is specific to my business and academic work, so I don't know if the generative AI is "awesome" for most people.

―― 人が言う「スゴい」は胡散臭くて鬱陶(うっとう)しいが、自分が信じる「スゴい」は、ストレスがなく、むしろ気分が良い

-- "Awesome" that people say is stinky and depressing, but "awesome" that I believe in is stress-free and makes me feel good.

ということです。

That is it.

-----

で、今回のオチですが、

So, here's the punchline,

―― 『私は、意外に、簡単にカルト宗教にハマるタイプかもしれない』と思い当たり、ゾッとしている

-- I am horrified to realize that "I may be the type of person who falls into cultism surprisingly easily.

と、なります。

私が、『"原理"はスゴい』などと、訳の分からないことを言い始めたら、皆さんは、直ちに私から離れて下さい。

When I say things like, "The 'Principle' is amazing," you all need to leave me immediately.

それは、もう、津波警報クラスの勢いで、避難を開始して下さい。

It would be best to start evacuating with the vigor of a tsunami warning class.

特に、私の家族には『3秒で私を捨てろ』と、言い含めておきます。

In particular, I will tell my family, 'You have three seconds to leave me.

「お金がなくてもそこそこ幸せになれるのか」を宗教と幸福感から真剣に解析してみる

 

2024,江端さんの忘備録

「土地が隆起する」ということは、知識としては知っていましたが、生きている間に自国の領土で、これを知ることになるとは思いませんでした。

I know that "land rises," but I had no idea I would see it in my territory during my lifetime.

■ 生活用水としての地下水の汲み上げによって、現在、各国の首都で深刻な地盤沈下が進行中

  • Groundwater pumping for domestic use is currently causing severe land subsidence in the capitals of many countries.

■ 地球温暖化による海面上昇によって、現在、沿岸部の都市の多くのエリアが水没中

  • Many areas of coastal cities are now under water due to rising sea levels caused by global warming.

ということは、NHKスペシャル等で知っていました。

I knew this from NHK specials and other sources.

しかし、今回の能登半島の大震災で、4メートルものの海岸線の土地隆起を知り、そして映像でも知りました。

However, after the Noto Peninsula earthquake, I learned about the 4-meter uplift of the coastline and learned about it on video.

こういう現象は、地球誕生後の億年の単位のどこかで発生する事象 ―― 要するに、遠い過去か、遠い未来の「他人事」と思っていました。

I had thought that these phenomena would occur somewhere in the billion years after the birth of the earth -- in other words, they were "someone else's problem" in the distant past or future.

『私は、億年単位の歴史の中で生きているんだなぁ』と実感するに至りました。

I realized that I was living in a billion years of history.

-----

今であれば、世界地図を見れば明らかな「大陸移動説」ですが、当時、この説の提唱者(アルフレート・ヴェーゲナー)は、世間から散々バカにされたそうです(しかも、かなり最近(1912年))。

Today, the theory of continental drift is evident if you look at a world map. Still, at the time, the proponent of this theory (Alfred Wegener) was widely ridiculed by the public (and quite recently (1912)).

でも、まあ、『地面が動くはずなかろうが!』と思うのも、納得できます。

But, well, 'the ground can't possibly move!' I can understand why you would think that.

-----

私、小学生のころ、ハワイが日本の近辺にあったという話を聞いて、計算してみたことがあります。

I heard that Hawaii was near Japan in elementary school, and I did the math.

(1)陸地は、だいたい1年で1cmくらいは移動している

(1) Land moves roughly 1 cm per year.

(2)日本とハワイの間は、現在6600kmである

(2) The distance between Japan and Hawaii is currently 6600 km.

上記(1)(2)をそのまま当てはめると、ハワイが現在の位置に至るのに必要な時間は、660,000,000年 = 6.6億年

Applying (1) and (2) above as they are, the time required for Hawaii to reach its present position is 660,000,000 years = 660 million years

地球誕生が45億年前、ミトコンドリが発生したのが21億年前、多細胞生物は10億年前、6億年前は氷河期だったようです。

The earth was born 4.5 billion years ago, mitochondrion arose 2.1 billion years ago, multicellular organisms a billion years ago, and 600 million years ago was an ice age.

人類の誕生は、ざっくり10~100万年前(0.001億年~0.01億年前)なので、それよりは、十分に長い時間ではあるのですが、

The birth of humankind is roughly 10 to 1 million years ago (0.001 to 0.01 billion years ago), so it is well longer than that,

―― 地面が動く速度は、意外に速いものだなぁ

"The ground moves surprisingly fast."

と、子ども心にも、思ったものでした。

Even as a child, I thought it.

ともあれ、私は『自分の生きている間に、数メートルの地面の隆起が起った』ということに、驚きを感じえずにはいられないのです。

Anyway, I can't help but be amazed that the ground has risen several meters in my lifetime.

地震発生時、テレビが時速43kmで突っ込んできます