2024,江端さんの忘備録

ある日、ある地域で大雨が降り、洪水が起こりました。その地域の住民は、家や町から避難しようとしました。その時、一人の人が祈りを捧げました。彼は言いました、『神よ、私を救ってください!』

One day, heavy rain fell in an area, causing flooding. Residents of the area tried to evacuate their homes and towns. At that time, a man prayed. He said, "God, save me!

彼のもとに、救命ボートがやってきました。しかし、その人はボートに乗らず、『大丈夫です、神が助けてくれるはずです』と言いました。

A lifeboat came to him. But the man did not get on the boat and said, 'Don't worry, God will save me.

しばらくして、水がますます上がり、彼は2階に避難しました。そこでもう一度神に祈りました。すると、再び一度救命ボートがやってきましたが、彼は再び乗らず、『神が助けてくれるはずです』と言いました。

After a while, the water rose more and more, and the man took refuge upstairs and prayed again to God. Then a lifeboat came again, but he did not get on it again, saying, 'God will save me.

さらに水位が上昇し、彼は屋根に避難しました。そこでもう一度神に祈りました。すると、救助ヘリコプターが現れ、彼を救出しようとしました。しかし、彼は再び拒否しました。

As the water level rose further, he took refuge on the roof. There, he prayed again to God. Then a rescue helicopter appeared and tried to rescue him. But he again refused.

結局、洪水に巻き込まれ、その人は亡くなってしまいました。

In the end, he was caught in the flood and died.

その後、彼は天国に到達しました。彼は神に尋ねました。

Then he reached heaven. He asked God.

『なぜ私を助けてくれなかったのですか?』

Why didn't you help me?"

神は答えました。

God replied.

『私は3回も助けを差し伸べたが、お前がそれを拒んだからだ』

'I offered you help three times, but you refused them.'

-----

最近、体感できるレベルの地震が、日本全国で多発しているような気がします。

Recently, it seems that earthquakes at a level that we can feel occurring all over Japan.

『私は、何度も警告を出したが、お前がそれに備えなかったからだ』

'I warned you many times, but you were unprepared.'

と神様に言われたら、

Even though God says that, 

―― 反論できないレベルで、"多い"ように思います。

 I think there are "too many" at a level that I can't argue with.

リビングのテレビをつけたら、アナウンサーが、恐しい声で避難を叫んでいました ―― 息も切れんばかりの勢いで。

2024,江端さんの忘備録

この世の中は、若い世代を、「Z世代」だの「ゆとり世代」だの、「○○世代」名前をつけることで、安心する傾向があるようです。

It seems that the world tends to feel comfortable naming the younger generation as "Generation Z," "Yutori Generation," or "Generation XX.

私たちの世代は、「しらけ世代」とか言われていましたが、

Our generation was called the "dampened generation" or something like that,

―― はっきり言って、私は不愉快だった

"I was uncomfortable, to say the least".

-----

大学生の全員が「勉学を侮って、遊興に興じている」かのように言われるのは不愉快でした。

It was distasteful, as if all college students "underestimated their studies and were playing for amusement.

私は、そういう相手に対しては、

I was constantly debunking every old guy who used the "XX generation." Like the following.

■ 隔週でレポート作成の為に徹夜をして、

- Staying up all night every other week to write reports,

■ 毎日毎日、講義に出席し、

- Attending lectures every day, day after day,

■ 午前3時ごろに、ゼミ研究室を退出し、(昭和天皇崩御の際には、蛤御門の前で警官に囲まれて職質されました)

- Leaving the seminar lab around 3:00 a.m. (I was surrounded by police officers and questioned in front of the Hamagurimikado gate when the Showa Emperor died.)

■ 週7日のバイトをして、

- Working part-time, seven days a week,

■ 大学後半と大学院では、学費も自分で収めて、

- paid my tuition for the second half of college and graduate school,

■ 時々、呼吸ができなくなるような胸の痛みで、道路でうずくまったりしていたけど、

- sometimes crouching in the street with chest pains that made it impossible to breathe,

―― それで、私の世代が『何』ですって?

"And my generation is 'what'?"

と、言い放ち、「○○世代」を語る奴を、ことごとく沈黙させ続けていました。

『他の大学生は知りませんが、私の回りには、あなたたちが"期待"するような"若い奴"は、ただの一人たりともいなかったです』

'I don't know about other college students, but I have never met a single "young guy" around me that you would "expect" to be there.'

『変ですねえ。あなたの回りの大学生は、そんな奴らばかりだったんですね』

'That's strange. All those college students around you were like that.'

といって、「○○世代」を語るおっさんたちを、ことごとく論破しまくっていました。

And so, I was debunking every old man who talked about the "XX generation."

-----

Z世代は「受け身・指示待ち型」ーー

"Generation Z is "passive and waiting for instructions."

若い人は、怒っていいぞ。

Young people, you can be angry against this phrase.

「ふざけるな!」 と、怒鳴り返してもいい。

Screw you!" And you can yell back.

そもそも、「ゆとり」や「バブル」や「しらけ」と言われた奴らが、偉そうに若者を語るな。見苦しい。

In the first place, don't let those who were called "Yutori," "Bubble," and "Shirake" talk about the youth with such bravado. It's not nice to see.

むしろ、

Rather, you can say 

『若い部下に、詳細で的確な指示も出せない、自分の無能なマネージメント能力を恥じろ、この無能が』

"You should be ashamed of your inability to give detailed and precise instructions to your young subordinates, you incompetent manager."

と言ってもいい。

事実だから。

Because it's true.

-----

私は、誰かに仕事をお願いする時には、可能な限り詳細に説明するようにしているつもりです。

I will try to be as detailed as possible when I ask someone to do a job.

むしろ、その作業の方が、時間をかかることがあるくらいです。

The process is so much more time-consuming.

特に「仕事の最後の形(ゴール)」については、できる限り詳細にして指示をします。

In particular, I give instructions on the "final form (goal) of the work" in as much detail as possible.

これは、『仕事の失敗を、部下の責任にして逃げるとができない』というリスクを負うことになりますが、そもそも。他人に仕事を頼むというのは、そういうリスクを負うことです。

This means that you run the risk of not being able to escape by blaming your subordinates for your work's failure, but that is the risk you run in the first place. Asking someone else to do a job for you is to take that risk.

『Z世代は「受け身・指示待ち型」』のような言い方で逃げるやつらは、要するに、リスクを負いたくない"ヘタレ"です。

Those who run away with phrases like "Generation Z is passive and waits for instructions" are, in essence, "slackers" who don't want to take risks.

こういう奴を見わける簡単なフレーズがあります。

There is a simple phrase to recognize these guys.

『若い人達の自主性を大切にする』と言う奴なら、確実にその"ヘタレ"です。

Anyone who says, "I value the autonomy of young people," is a "slacker" for sure.

私、このフレーズを一回でも使った奴は、信じないことにしてきました。

I have not believed anyone who uses this phrase even once.

そして、この判断は間違っていなかったと確信しています。

And I am convinced that this decision was not wrong.

これにつきましては、『個性を育てる教育をする』という、学校説明会の校長の言葉に通じるものがあります。

At the school's information session, I remember the principal's words: "We will provide an education that nurtures individuality.

このコラムの、

Please refer to the following page in the column, 

こちらのページに記載の「―― 個性を育てる教育だって? 笑わせるんじゃねーよ」

"The article on this page, "-- Education that fosters individuality? Don't make me laugh."

を御参照下さい。

-----

そもそも、

To begin with,

■「自由にやっていい」といわれて、自由にやれば、それに文句を言われ、

- When your boss told that you are free to do what you want, and you do it freely, the boss will complain about it,

■「言われた通り」にやれば、「言われたことしかやらない」と文句を言われる。

- If you do what your boss orders,  the boss complains that you only say what you do the orders.

これで、仕事ができる人間がいたら、「それは人間ではない」と言ってもいいでしょう。

If someone can do the job, you can say, "That's not a human being.

「受け身・指示待ち型」―― 上等です。それでいいんです。

Passive, waiting-for-directions type - that's fine.

「バカヤロー、お前は俺の仕事の何を見てきたんだ!」と叫ぶメンターに関する一考察

-----

私も、原則「受け身・指示待ち型」でしたが、何もしていなかった訳ではありません。

As a rule, I was also "passive and waiting for instructions," but that does not mean I did nothing.

私は、自分が必要だと思った仕事は『黙って』やっていました。

I 'shut up' and did the work I felt I needed to do.

なぜなら、

Because, 

―― しゃべると、確実に"潰される"から

"If I speak, my boss crushed it for sure."

です。

「人の言うことを聞かない能力」

私の場合、こんな感じでした。

In my case, it went like this.

2024,江端さんの技術メモ

特定領域内で、乱数的な緯度・経度の作成を行うコードをChatGPTに考えて貰いました。

package main

import (
	"fmt"
	"math"
	"math/rand"
)

// Polygon represents a polygon defined by its vertices
type Polygon [][]float64

// Point represents a point with x and y coordinates
type Point struct {
	X float64
	Y float64
}

// isInPolygon checks if a point is inside a polygon using the ray casting algorithm
func (p Polygon) isInPolygon(point Point) bool {
	intersections := 0
	for i := 0; i < len(p); i++ {
		p1 := p[i]
		p2 := p[(i+1)%len(p)]

		if point.Y > math.Min(p1[1], p2[1]) && point.Y <= math.Max(p1[1], p2[1]) &&
			point.X <= math.Max(p1[0], p2[0]) && p1[1] != p2[1] {
			xIntersection := (point.Y-p1[1])*(p2[0]-p1[0])/(p2[1]-p1[1]) + p1[0]
			if p1[0] == p2[0] || point.X <= xIntersection {
				intersections++
			}
		}
	}
	return intersections%2 != 0
}

// generateRandomPointInPolygon generates a random point inside the given polygon
func generateRandomPointInPolygon(p Polygon) Point {
	var minX, minY, maxX, maxY float64
	minX = math.MaxFloat64
	minY = math.MaxFloat64
	maxX = -math.MaxFloat64
	maxY = -math.MaxFloat64

	// Find bounding box of the polygon
	for _, vertex := range p {
		if vertex[0] < minX {
			minX = vertex[0]
		}
		if vertex[1] < minY {
			minY = vertex[1]
		}
		if vertex[0] > maxX {
			maxX = vertex[0]
		}
		if vertex[1] > maxY {
			maxY = vertex[1]
		}
	}

	// Generate random points until a point inside the polygon is found
	var randomPoint Point
	for {
		randomPoint.X = rand.Float64()*(maxX-minX) + minX
		randomPoint.Y = rand.Float64()*(maxY-minY) + minY

		if p.isInPolygon(randomPoint) {
			break
		}
	}
	return randomPoint
}

func main() {
	// Define the polygon
	polygon := Polygon{
		{35.36394967, 139.61846500},
		{35.36216810, 139.61890850},
		{35.36170465505306, 139.6220415552594},
		{35.36163108058289, 139.62334070015595},
		{35.363117271878345, 139.62314221968566},
		{35.36335187635167, 139.62481739887647},
		{35.36310056060587, 139.62485183402688},
		{35.36376860001917, 139.6288186562702},
		{35.36420166714637, 139.6297897196359},
		{35.36754482323006, 139.6296024603071},
		{35.37126945661188, 139.62886244945108},
		{35.37375189636854, 139.62615207124352},
		{35.37464657021711, 139.623189740366},
		{35.37574882601201, 139.6213765671167},
		{35.37527643251494, 139.6210117866997},
		{35.37306314467156, 139.6217413475337},
		{35.37268696718477, 139.62013202216457},
		{35.37018828750506, 139.61840497406456},
		{35.370782160278, 139.61705458898427},
		{35.36947068533102, 139.61641732865053},
		{35.370596575495014, 139.61476348635583},
		{35.37078029225879, 139.61403393574466},
		{35.36864433631068, 139.61438212951467},
		{35.36653571408147, 139.61453772192408},
		{35.36394967, 139.61846500},
	}

	// Generate a random point inside the polygon
	randomPoint := generateRandomPointInPolygon(polygon)
	fmt.Println("Random point inside polygon:", randomPoint)
}

なるほど、と思いながらコードを読んでいたのですが、『あれ? これって、領域に入った緯度・経度の乱数を採用するだけだから、発生頻度が均一にならないんじゃないかな?』と思い、ChatGPTにたずねてみたら『Yes』と言われました。

で、発生頻度を均一になるコードを再度要求したのですが ―― コードを一目見て、『このコードは間違っているな』と分かるようなものが出てきました。

『ChatGPTは、もの凄く真摯な言葉で、嘘をつく』

で、昔のコードを探していたら、PostGISを使うものが出てきました。

// C:\Users\ebata\tomioka3B\src\others\main35.go
/*
	実験用の座標を作る
	修正後 (富岡西5丁目を削除し、富岡6丁目の下1/4を削除)

	このプログラムは、Go言語を使用してPostgreSQLデータベースから空間データを取得し、指定された多角形内に均等に配置された乱数の座標を生成します。以下はプログラムの概要です:

	パッケージのインポート: 必要なパッケージをインポートします。database/sql はデータベースの操作に使用され、fmt と log は出力とログのために使用されます。また、PostgreSQLデータベースへの接続に使用するドライバもインポートされます。
	main() 関数: プログラムのエントリーポイントです。まず、PostgreSQLデータベースに接続します。接続情報は、ユーザー名、パスワード、ホスト、ポート、およびデータベース名で構成されます。
	SQLクエリの実行: query 変数にSQLクエリが格納されています。このクエリは、指定された多角形の領域内に均等に配置された15000個の点を生成するものです。db.Query() を使用してクエリを実行し、結果を rows に格納します。
	結果の処理: rows.Next() を使用して、結果セットの各行を処理します。各行は msg として取得されます。次に、regexp パッケージを使用して、取得した座標データを処理します。
	座標データの分解: 取得した座標データは、MULTIPOINT 形式の文字列として提供されます。この文字列をバラバラに分解し、各点の緯度と経度を取得します。regexp.MustCompile("[() ,]").Split(msg, -1) を使用して、文字列を分割します。
	座標の表示: 緯度と経度のペアを取得し、それぞれを浮動小数点数に変換して表示します。

	このプログラムは、指定された多角形内に均等に分布する乱数の座標を生成し、それを取得して表示します。


*/

package main

import (
	"database/sql"
	"fmt"
	"log"
	"regexp"
	"strconv"

	_ "github.com/lib/pq"
)

func main() {
	// 取り扱うDBによってノード番号が代わるので注意すること
	// 例えばtomioka_db_c とtomioka_dbは全く異なる
	db, err := sql.Open("postgres",
		"user=postgres password=password host=192.168.0.23 port=15432 dbname=tomioka_db_f sslmode=disable")
	if err != nil {
		log.Fatal("OpenError: ", err)
	}
	defer db.Close()

	// 修正後のターゲットの富岡地区 (富岡西5丁目を削除し、富岡6丁目の下1/4を削除)

	query := `
	SELECT st_asText(
		ST_GeneratePoints(
			ST_GeomFromText(
				'POLYGON((
					35.36394967 139.61846500,
					35.36216810 139.61890850,
					35.36170465505306 139.6220415552594,
					35.36163108058289 139.62334070015595,
					35.363117271878345 139.62314221968566,
					35.36335187635167 139.62481739887647,
					35.36310056060587 139.62485183402688,
					35.36376860001917 139.6288186562702,
					35.36420166714637 139.6297897196359,
					35.36754482323006 139.6296024603071,
					35.37126945661188 139.62886244945108,
					35.37375189636854 139.62615207124352,
					35.37464657021711 139.623189740366,
					35.37574882601201 139.6213765671167,
					35.37527643251494 139.6210117866997,
					35.37306314467156 139.6217413475337,
					35.37268696718477 139.62013202216457,
					35.37018828750506 139.61840497406456,
					35.370782160278 139.61705458898427,
					35.36947068533102 139.61641732865053,
					35.370596575495014 139.61476348635583,
					35.37078029225879 139.61403393574466,
					35.36864433631068 139.61438212951467,
					35.36653571408147 139.61453772192408,
					35.36394967 139.61846500
				))'
			),
		15000)
	)
	`
	rows, err := db.Query(query) // この25が生成する乱数座標

	if err != nil {
		log.Fatal(err)
	}
	defer rows.Close()

	var msg string

	for rows.Next() {
		if err := rows.Scan(&msg); err != nil {
			fmt.Println(err)
		}

		// まずはMULTIPOINTをバラバラに分解する
		arr1 := regexp.MustCompile("[() ,]").Split(msg, -1) // '('か、')'か、' 'か、","で分割する → "[中身]" という構造でまぎらわしい

		// 2つの値を一度に取得する (最初の値" MULTIPOIN"をスキップする為に、i:=1から始める)
		for i := 1; i < len(arr1); i += 2 {
			// arr1[i]とarr1[i+1]は2つの値を表します
			if i+1 < len(arr1) {
				value1, _ := strconv.ParseFloat(arr1[i], 64)   // 乱数の緯度
				value2, _ := strconv.ParseFloat(arr1[i+1], 64) // 乱数の経度
				fmt.Println(i, value1, value2)
			}
		}
	}
}

ポイントは、指定された多角形内に均等に分布する乱数の座標を生成 という点です。

どういう仕組みか分かりませんし、ChatGPTが真実を言っているのかも不明ですが、『postGISなら、その程度の仕組みは入れてくるだろう』と期待して、今回は、こちらを使うことにしました。

以上

2013,江端さんの忘備録

新聞の編集部が舞台となっている、ある本を読んでいたのですが、

新人の買いた取材ルポを、上司が一読すると、その用紙をくしゃくしゃにして、ポイと投げるシーンが出てきます。

「ボツ! やりなおし!!」という上司に対して、

「あ、・・あの・・・どこが悪いんでしょうか」と尋ねる新人に、

「自分で考えろ。誰も教えてくれないぞ」といって、新人に大量の資料を手渡す上司が出てくる場面があります。

今の日本では、こういう「バカげた指導」を行っている職場は、残念ながら存在しているようです。

-----

こういうシーンが結構な数、見られるのですよ。特に、テレビ番組の、「寿司職人」「大工職人」などの、職人シリーズに多い。

「バカヤロー、お前は俺の仕事の何を見てきたんだ!」

と怒鳴る先輩職人のシーンを見ると、私なんぞは、

―― バカはお前だ。なぜ、大切な仕事の内容ならば、それを体系だてて、順序よく、理解しやすいように説明してやらないんだ。

―― お前にプレゼン能力(説明能力)がないばかりに、新人が効率よく仕事の内容を取得できずにいるんだろうが、阿呆が。

―― 自分が、「寿司握っているだけ」「工具を使っているだけ」で、新人が育つなどという、そんな都合のいい話があるか、馬鹿野郎めが。

と思ってしまうのですよ。

「仕事は盗むものだ」と信じているこういう先輩や上司は、コスト意識がない上に、自分達の持っている技術を「上限」と信じている傲慢さが見て取れて、気分が悪いです。

自分の持っている技術を踏み台として、新人を、更なる高みを目指させるのが、メンター(指導者)というものではないでしょうか。

-----

ところが、こういうテレビ番組などで、こういう場面が頻出するところを見ると、我々日本人は、「仕事は盗むものだ」というストーリーが大好きなようです。

先輩に責められ、上司に叱責され、何度もやりなおしをさせられ、それでも、最後に成功して、「やればできるじゃないか」という先輩に「ありがとうございました!」と、涙ながら語る新人の台詞で終わる、というストーリーです。

―― 正直、うんざりです。こういう番組。

一人ならチャンネル替えてしまうのですが、食事の時に、家族全員で見ている時などは、つき合わなければならない時もあるのです(また、こういうことを指摘すると、家族の批判の目にも晒されますので、ガマンしています)

でも、どう考えたって、正解はこうでしょう?

(Step.1)先輩が後輩の良くない部分を指摘し、正しいやり方を口頭だけでなく図解や実際のやり方を示して、短時間で所定の技術を取得させる。

(Step.2)そんでもって、同じミスを2回した場合は、それを指摘し、改善がなければ、叱責する。それでも駄目なら辞めて貰う。技術を継承できない者は、不要であるから。

それだけのことですよね。

-----

ただ、このような構成の番組としたら、到底、視聴率は取れないだろうな、ということは、私にも分かります。

未分類

社内報リレー随筆

「人の言うことを聞かない能力」

2004/01/10
[その1]

インターネットが、電話線で細々と繋がっていた頃、私は未来のインターネットを夢想して、張り切って特許明細書を書いてましたが、私より数段偉くて頭の良い人から『意味がない』と論理的に説得されてその執筆を止めてしまったことがあります。

そして今、その発明を他社が実施しているのを悔しい思いで見ながらも、今なお、その論理を論破できない自分がいます。

私が心の底から悔しいと思うことは、世間がなんと言おうが、論理的に破綻していようが、私が信じるものは絶対である、という狂信的な思い込みを持ち得なかった自分に対してです。

-----

[その2]

数年前に私が結婚を決意した時、私の回りは一斉に反対の声を上げました。

私に結婚を思い留まらせる為に合宿まで企画されました(本当)。

『写真のこの娘は堅気の娘ではないか。暗黒サイドのお前とは所詮住む世界が違う!』(暗黒サイドって何?)。

実際、その当時彼女自身、本当に私と結婚したかったかどうかも疑わしく(と言うと嫁さんは『何を言うの!たとえ、あなたが売れない場末の芸人であっても、私は・・』と言い返すのですが)、私は彼女の意見すら十分に聞かずに結婚に踏み切りました。

-----

[結言]

私達は自立した社会人として、人の話をきちんと聞かねばなりません。

しかし時として「人の話を聞かない能力」を問われるものが世の中に2つだけあります。

それが「特許」と「愛」です。

お忘れなきよう。

2013,未分類

最近、非常識な悪ふざけを、Twitter等のソーシャルメディアに投稿して、騒ぎになる事件が後を立たないようです。

かかる事件を置こす彼ら/彼女らは、共通して、以下に示す「5重の低能さ」を露呈していると考えます。

-----

(1)そのような所業しなれば、自己アピールができないという「低能さ」

(2)上記(1)を記録媒体に残すという「低能さ」

(3)上記(2)をネットワーク上に配布するという「低能さ」

(4)上記(3)の行為が社会的に認容されるという見込の甘さや、そのような自体によって発生する影響を推定できないという「低能さ」

(5)ニュース、新聞等のメディアを全く視聴していないという「低能さ」

-----

これは、「低能 of 低能s」、まさに「低能のエリート」「低能の帝王」といっても言いくらいの、低能さです。

これは、冗談でも皮肉でもなく、心底から敬意に値する「低能さ」だと私は思っているのです。

同じ「低能」であるなら、ここまで極めなければならない。

人間は、どうしても、ここまでの「低能さ」を発揮することは難しいと思うのです。

-----

それともう一つ、彼ら/彼女らの行為は、素晴しいことをしてくれています。

このような、ニュースになっている程度の規模を発生させている「低能者」は、私の計算する限り、100人には至っていないように思います。

この数は、本当に事件を発生された確定的にGivenな固定の人数であり、その人数以外には当て嵌まらないと言って良いでしょう。つまり、この100人以上の人間には、無関係であることが、はっきりしているからです。

我が国の15~22歳の人口は、ざっくり、960万人ほどいるのですが、その内の、100人というのは、

「10万人に1人」程度です。

これは統計的な観点から見た「母集団に対する歩留まり」から考えても、

―― 驚異的に小さい値です。

このような観点から見ると、「5重の低能さ」は、間違いなく個人の資質に起因するものと断定して良いでしょう。

このような「低能」さを、若い世代全体に一般化する人(マスコミや評論屋も含めて)は、若者に対して「失礼にも程がある」上に、その程度の計算もできない程、自分自身が「低能」であることを主張しているようにさえ見えます。

-----

私達の世代は「しらけ世代」「遊んでばかりいる大学生」と批難されていました。

しかし、私が知る限り「しらけ」つづけていて、続けられるような勉学ではなかったし、「遊んでばかり」いて、卒業できるほど大学のカリキュラムは甘くはなく、本当に、日々、勉学とのバトルでした(少くとも、私には余裕などなかった)。

ですから、無神経に、このような「一般化」を、マスコミや世間を、心底から

―― 「憎悪」していました。

-----

若い世代に対する、根拠のない不当な「一般化」は止めましょう。

「五重の低能者」は、その資質として「選ばれし低能者」であり、

世代とは全く無関係に、本質的に根本的に絶対的に「低能」なのです。

未分類

WindowsのDockerでFlutter for Web(開発環境構築)

https://qiita.com/toshibe/items/e05ebe152e579ad39a58

で、色々問題がでてくるけど、

Flutter

https://qiita.com/tiri/items/5ad8d173df2c3823a265

の記載の内容で対応できました。

動かし方

1. Dockerfileからイメージを作成する

docker-compose build

 2. イメージからコンテナを作成し、起動する

docker-compose up -d

 3. 起動したコンテナに入る

docker exec -it flutter bash

4. フラッターアプリを作成する

cd workspace
flutter create .

5. サーバーを立ち上げる

flutter run -d web-server --web-port=${WEB_SERVER_PORT} --web-hostname 0.0.0.0

さて、これでサンプルは動かせたんだけど、さて、コーディングはどうやるのかな?


docker exec -it flutter bash でシェルに入った後、

root@0c0fd167601e:/usr/local# ls
Android bin etc flutter games include lib man sbin share src workspace
root@0c0fd167601e:/usr/local# cd workspace/
root@0c0fd167601e:/usr/local/workspace# ls
README.md android ios linux pubspec.lock test windows
analysis_options.yaml build lib macos pubspec.yaml web workspace.iml
root@0c0fd167601e:/usr/local/workspace# cd test
root@0c0fd167601e:/usr/local/workspace/test# ls
widget_test.dart ← これがターゲットのソース(だと思う)

root@0c0fd167601e:/usr/local/workspace/test#more widget_test.dart

 

// This is a basic Flutter widget test.
//
// To perform an interaction with a widget in your test, use the WidgetTester
// utility in the flutter_test package. For example, you can send tap and scroll
// gestures. You can also use WidgetTester to find child widgets in the widget
// tree, read text, and verify that the values of widget properties are correct.

import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';

import 'package:workspace/main.dart';

void main() {
  testWidgets('Counter increments smoke test', (WidgetTester tester) async {
    // Build our app and trigger a frame.
    await tester.pumpWidget(const MyApp());

    // Verify that our counter starts at 0.
    expect(find.text('0'), findsOneWidget);
    expect(find.text('1'), findsNothing);

    // Tap the '+' icon and trigger a frame.
    await tester.tap(find.byIcon(Icons.add));
    await tester.pump();

    // Verify that our counter has incremented.
    expect(find.text('0'), findsNothing);
    expect(find.text('1'), findsOneWidget);
  });
}

という記載が見える。
とりあえず、ここを書き換えれば、最初のアプリが作れるのかな、とアタリを付けています。

上記間違いでした。

vscodeで直接dockerコンテナの中を編集できるので、(これについては、どこかで話ます)、ターゲットは、lib/main.dartでした。

で、ちょっと変えて動くかどうか調べてみました。

という変更をして、

flutter run -d web-server --web-port=${WEB_SERVER_PORT} --web-hostname 0.0.0.0

を実施してみました。

で、http://192.168.0.23:8888 (192.168.0.23: DockerコンテナのあるPC)で、ちゃんと変更されているようです。

とりあえず、これで、改造するポイント分かりました。

その後、このlib/main.dart
https://zenn.dev/ryouhei_furugen/articles/583b1003ebcfc1
(Flutterのサンプル カウンターアプリ)にさしかえさせて頂きました。

問題なく動きました。


 

 

https://docs.flutter.dev/get-started/test-drive

ざっくり、翻訳してみておく

Test drive

What you'll learn

#

  1. How to create a new Flutter app from a sample template.
    サンプルテンプレートから新しいFlutterアプリを作成する方法。
  2. How to run the new Flutter app.
    新しいFlutterアプリの実行方法。
  3. How to use "hot reload" after you make changes to the app.
    アプリに変更を加えた後に「ホットリロード」を使用する方法。

Guide depends on your IDE
ガイドはあなたのIDEに依存します。

#

These tasks depend on which integrated development environment (IDE) you use.
これらの作業は、どの統合開発環境(IDE)を使うかによって異なる。

  • Option 1 explains how to code with Visual Studio Code and its Flutter extension.
    オプション1では、Visual Studio CodeとそのFlutter拡張機能を使ってコーディングする方法を説明する。
  • Option 2 explains how to code with Android Studio or IntelliJ IDEA with its Flutter plugin.
    オプション2では、Android StudioまたはIntelliJ IDEAのFlutterプラグインを使ってコーディングする方法を説明する。Flutter supports IntelliJ IDEA Community, Educational, and Ultimate editions.
    FlutterはIntelliJ IDEA Community版、Educational版、Ultimate版をサポートしています。
  • Option 3 explains how to code with an editor of your choice and use the terminal to compile and debug your code.
    オプション3では、好きなエディターを使ってコードを書き、ターミナルを使ってコンパイルとデバッグを行う方法を説明する。

Choose your IDE
IDEを選ぶ

#

Select your preferred IDE for Flutter apps.
Flutterアプリに適したIDEを選択する。

Create your sample Flutter app

#

  1. Open the Command Palette.
    コマンドパレットを開く。Go to View > Command Palette or press Shift + P.
    表示 > コマンドパレットに移動するか、+ Shift + Pを押します。
  2. Type flutter
    fluter
    とタイプする
  3. Select the Flutter: New Project.
    Flutter: New Projectを選択する
  4. When prompted for Which Flutter Project, select Application.
    どのFlutterプロジェクトかを聞かれたら、Applicationを選択する。
  5. Create or select the parent directory for the new project folder.
    新しいプロジェクトフォルダの親ディレクトリを作成または選択します。
  6. When prompted for a Project Name, enter test_drive.
    プロジェクト名の入力を求められたら、test_driveと入力する。
  7. Press Enter.
    Enterを押す。
  8. Wait for project creation to complete.
    プロジェクトの作成が完了するまで待つ。
  9. Open the lib directory, then the main.dart.
    libディレクトリを開き、次にmain.dartを開く。To learn what each code block does, check out the comments in that Dart file.
    各コードブロックが何をするのかを知るには、そのDartファイルのコメントをチェックしてほしい。

The previous commands create a Flutter project directory called test_drive that contains a simple demo app that uses Material Components.
先ほどのコマンドでtest_driveというFlutterプロジェクトディレクトリが作成され、Material Componentsを使ったシンプルなデモアプリが含まれる。

Run your sample Flutter app
サンプルのFlutterアプリを実行する

#

Run your example application on your desktop platform, in the Chrome web browser, in an iOS simulator, or Android emulator.
デスクトップ・プラットフォーム、Chromeウェブ・ブラウザ、iOSシミュレータ、Androidエミュレータでサンプル・アプリケーションを実行してください。

  1. Open the Command Palette.
    コマンドパレットを開く。Go to View > Command Palette or press Shift + P.
  2. Type flutter
    fluterとタイプする
  3. Select the Flutter: Select Device.
    Flutter: New Projectを選択するIf no devices are running, this command prompts you to enable a device.
    実行中のデバイスがない場合、このコマンドはデバイスを有効にするよう促します。
  4. Select a target device from Select Device prompt.
    Select Deviceプロンプトからターゲットデバイスを選択します。
  5. After you select a target, start the app. Go to Run > Start Debugging or press F5.
    ターゲットを選択したら、アプリを起動する。Run > Start Debuggingに進むか、F5を押す。
  6. Wait for the app to launch.
    アプリが起動するのを待つ。You can watch the launch progress in the Debug Console view.
    起動の進行状況は、デバッグコンソールビューで確認できます。

After the app build completes, your device displays your app.
アプリのビルドが完了すると、デバイスにアプリが表示されます。

Starter app on macOS
Starter app
スターターアプリ

Try hot reload
ホットリロードを試す

#

Flutter offers a fast development cycle with Stateful Hot Reload, the ability to reload the code of a live running app without restarting or losing app state.
Flutterは、ステートフルホットリロード(Stateful Hot Reload)、つまりアプリを再起動したりアプリの状態を失ったりすることなく、実行中のアプリのコードをリロードする機能によって、高速な開発サイクルを提供します。

You can change your app source code, run the hot reload command in VS Code, and see the change in your target device.
アプリのソースコードを変更し、VS Codeでホット・リロード・コマンドを実行すれば、ターゲット・デバイスで変更を確認できる。

  1. Open lib/main.dart.
    lib/main.dartを開く。
  2. Change the word pushed to clicked in the following string. It is on line 109 of the main.dart file as of this writing.
    以下の文字列のpushedをclickedに変更する。これを書いている時点では、main.dartファイルの109行目にある。

    Original New
    'You have pushed the button this many times:' , 'You have clicked the button this many times:' ,
  3. Save your changes: invoke Save All, or click Hot Reload lightning bolt .

Your app updates the string as you watch.
変更を保存する:すべて保存を実行するか、ホットリロードをクリックします。

Starter app after hot reload on macOS
Starter app after hot reload

2024,江端さんの忘備録

我が家では、2台の「豊作ラジオ」を購入してします。

Our family has purchased two "bumper crop radios."

普段はテレビの音を拾う受信機として、そして非常時の災害情報の入手手段です。

It is usually used as a receiver to pick up TV sounds and to obtain disaster information in an emergency.

私にとっては、調理したり、食器を洗いながら見るNスペ(NHKスペシャル)が、一番楽しいです。

このラジオは電池式なのですが、結構な頻度で電池交換が発生します ―― 毎日使っていますし、つけっぱなしにしてしまうことも多いようなので。

This radio is battery-operated, but the batteries need to be changed quite often -- I use it every day and seem to leave it on a lot.

さすがに、これは「電池がもったいないなぁ」と思っていました。

As expected, I thought, "This is a waste of batteries.

そこで、ジャンク箱の中に入っていた、廃棄したスマホの給電アダプタを使って、電池ボックスに結線したのですが、上手く動きません。

So I wired it to the battery box using the power supply adapter from a discarded phone in the junk box, but it did not work well.

『変だな?』と思い、テスターで電圧見てみたら、0.1ボルトも出ていませんでした。意外に簡単に経年劣化するようです。

' I thought, 'That's odd, isn't it?' I looked at the voltage with a tester and found that it was not even 0.1 volts. It seems to deteriorate over time surprisingly quickly.

-----

ふと、我が家のそこかしこに転がっている、100均で購入したUSBアダプタから、USBケーブルを分解して、結線してみたのですが、これが「当たり」でした。

Suddenly, I disassembled a USB cable from a USB adapter I had purchased at a 100-yen store, which was lying all over the place in my house, and tried to wire it together, and it was a "hit

ラジオからは、力強い元気な音が出ています。

The radio emits a robust and energetic sound.

災害時には、電池に切り替えられるように、結線は半田付けなどをしないで、リード線を電極に引っ掛けるだけとしました。

To be able to switch to batteries in case of a disaster, the wiring was done simply by hooking the lead wires to the electrodes without soldering.

で、部屋中に運べるように、5m程度のケーブルを引き廻すことになりました。

So, we had to run a cable about 5 meters long to carry it around the room.

これは、これで、面倒なのですが、電池のメリットを捨てた代わりとしては、まあ仕方がないかな、と思っています。

As it were, this is a hassle, but as an alternative to giving up the benefits of batteries, I think it's just how it is.

-----

私は、電気工学の修士のタイトルホルダーです。

I hold a Master's in Electrical Engineering.

苦労してタイトルを取得したはずですが、日常生活で「電気」に関して役に立っているのは、この程度です。

I have had to work hard to obtain the title, but this is the extent to which it has helped me understand "electricity" in my daily life.

『他の人たちは、ホワイトボードにスペックアウト(書き出す)せずに、他の人に自分の考えを伝えることができるのか?』と、いつも不思議に思っています。

2024,江端さんの忘備録

Raspberry PI4(ラズパイ4)で、ある特定のDockerコンテナが動かないので、頭を抱えています。

I have a headache because a particular Docker container is not working on my Raspberry PI4 (Raspberry PI4).

ラズパイ4から、CPUがAMD(CISCチップ)から、ARM(RISCチップ)に変わりました。

From Raspi 4, the CPU has changed from AMD (CISC chip) to ARM (RISC chip).

ラズパイが、このサイズ(名刺サイズ)のままで、性能を上げるには、低電力消費と高性能を組み合わせたRISC(Reduced Instruction Set Computing)アーキテクチャを使わなければ、やっていけないというのは分かります。

I understand that Raspi cannot do without RISC (Reduced Instruction Set Computing) architecture, which combines low power consumption and high performance, to increase performance at this size (business card size).

しかし、そういう「過渡期をつき合わされるエンジニア」にとっては、災難です。

However, it is a disaster for the engineers dealing with such "transitional periods.

「上司からの、突然の飲み会の誘い」よりも、災難です。

It's more of a disaster than "a surprise invitation for a drink from your boss."

Dockerコンテナは、チップとかOSとかに関係なく動く ―― というのが建前ですが、そうでないことは結構あります。

Docker containers work regardless of chip or OS -- the building block is that they work irrespective of chip or OS, but that's pretty much not the case.

特に、ラズパイでは、私は、この問題に度々巻き込まれてきました。

I have often run into this problem, especially with Raspi.

----

さて、このような、システム変更の問題によって「溶けていく時間」をどのように把握するか、重要です。

Understanding how to figure out the "time to melt" due to these system change issues is essential.

このような時間を、『生産性のない時間の無駄遣い』と見るか、はたまた、『将来への必要な先行投資』と見るか、です。

Do you see such time as an 'unproductive waste of time' or a 'necessary up-front investment for the future'?

実のところ、この議論は、あまり意味がありません。

This argument does not make much sense.

というのは、この手の技術上の課題は、放置しておけば、必ず解決するからです。

This type of technical challenge will always be solved if left alone.

今度もコンピュータの性能は上がり続けますし、チップの変更によって動かなくなったソフトウェアもいずれ動くようになります。

Computers will continue to improve, and software that stopped working because of the chip change will eventually work again.

そういうことを、頑張ってくれる人がいるからです。

That's the kind of thing that people do their best to do.

そういう人たちの成果の「おこぼれ」を、ありがたく頂くことができるのが、このデジタル業界です。

In the digital industry, we can take advantage of the achievements of such people.

-----

先行技術が汎用化されていく時間は恐しく短く、先行開発によって得られる先行者利益は、それほど大きくありません。

The time it takes for prior art to become generalized is frighteningly short, and the first-mover advantage gained from previous development is not great.

先行技術者の利益を守る為に『特許法』というものがあるのですが、デバイス、材料、機械の発明などには、一定の効果があると思います。

There is a "patent law" to protect the interests of prior art inventors, and I believe it has specific effects on device, material, and machine inventions.

しかし、デジタルシステムの発明は、特許法による保護を受けにくいのです。

However, inventions in digital systems are less likely to be protected by patent law.

まず、アルゴリズム自体に特許性がなく(日本では、そう決めている)、そして、侵害立証が死ぬほど難しく、立証できたとしても、取り立てられる金額がショボイからです。

First, the algorithm itself is not patentable (JPO has decided that), and second, it is deathly challenging to prove infringement. Even if we prove it, the amount of money we can get is paltry.

では、なぜ、大手の企業は、金にもならない特許出願を、エンジニアの社員たちに強いているかというと ―― 他社に対して「マウント」を取るためです。

So, why do significant companies force their engineering employees to apply for patents that don't pay well -- to "mount" other companies?

ある特定の技術分野を、沢山の数の特許出願(別に特許査定されていなくてもいい)で埋めつくすことで、「縄張り」を主張するためです。

The purpose is to claim "territory" by filling a particular technical field with many patent applications (even without Patent approval).

「技術フィールドにおける、実効占拠」という感でしょうか。

It may be a sense of "effective occupation of the technological field.

要するに『ここシマに入っているんじゃねーぞ』です。

In short, 'We're in this territory here.'

やっていることは「合法」ですが、その本質は「反社」と同じです。

What they are doing is "legal," but the essence of it is the same as "anti-socialism."

-----

資本主義経済とは、つまるところ「シマ争い」です。

A capitalist economy is, after all, a "territory war.

私もまた、組織の下っ端の構成員として、「チャカ(拳銃)」ではなく、「ネタ(アイデア)」で、組織のシノギを守っている、ということです。

As a lowly member of the organization, I am also protecting the organization's security not with a "Chaka" (gun) but with a "neta" (idea).

愛のある特許出願

2013,江端さんの忘備録

電子メールを使って、特許法の説明をしていたことがあります。

■特許権が発生する為には、「特許出願」という要式行為が必要である(「方式主義」)。

■しかし著作権の場合は、このような行為を行うことなく権利が発生する(「無方式主義」)

という内容を簡単に判って貰う為に、以下のような文章を作成しました。

==========================

(例2)

『結婚は、所定の要件を備えた当事者間の合意で成立する。YesかNoか』

答えは、Noです。

婚姻届けを提出するという手続を行い、登録されないと結婚は成立しません。

結婚とは、法律行為で、かつ、第三者対抗要件だからです。

ちなみに、「結婚」とは実体としての「愛情」やら「経済力」やらを全く規定しておらず、単なる手続としての法律行為のみです。

今更ですが、「愛」がなくても結婚は可能です。

==========================

つまり「愛のない結婚」という言い方は、一般的にはネガティブなイメージがありますが、法律的にはあまり意味のあるフレーズではないのです。

「愛のある結婚」という言い方のほうが、珍しい。

いわば「愛のある特許出願」みたいな違和感です。