2022/04,江端さんの技術メモ

江端家のテレビには、AmazonとNetFlixを視聴する為だけ用のPCが繋っています。
で、昨日、NetFlixを見ようとした嫁さんから「動かない」とクレームを受けました。

「あ、これ、電池切れだ」と当りをつけて、PCの中をのぞいてみました。

で、型番を調べたら、

CR2032でしたが、私の部屋には、その型番のものがなかったので(他の型番はあったのですが)、明日、100均で手に入れようと決めて、別の作業に入りました。
先ずは、Windows10のライセンスキーの購入でした。最近、正規版(リテール版も)が安くなっているようで、私は、https://www.gamivo.com/product/windows-10-professionalから、プロバイダーを一つ選びました。

1500円くらいでした。
VISAカードで支払いを終えたら、直ぐに、ライセンスキーが表示されました。
-----
で、今朝、100均にいってCR2032を3つ/100円を購入して、PCを再起動、
Windows10をインストールして、ライセンスキーを入力して、あとは、あれやこれややって、入れ替えを終えました。
で、そのなんやかんやには、「ライセンス認証を行って下さい」という表示が出てくるなどがありました。

で、電話による認証が必要となりました。
中古ライセンスのリセール品を売りつけられたのかもしれませんが、ともあれ認証されたようです。
以上

2022/04,江端さんの忘備録

いわゆる、世界から注目される著名な人は、厳しい自己批判と反省を続けている ―― らしいです。

So-called prominent people who attract worldwide attention continue to engage in severe self-criticism and reflection -- apparently.

確かに、そのような日々の果てに、世界を動かし、世界を感動させる何かを興すことができるのだと思います。

Indeed, I believe that at the end of such days, they can rise something that moves the world and inspires the world.

しかし、そのような人々には、世界は見えていない ―― 彼らにとって、世界は観客ではありません。

But to such people, the world is invisible -- to them, the world is not a spectator.

彼らにとっての観客は、自分自身です。

For them, the audience is themselves.

-----

その観客(自分)は、自分のパフォーマンスに対して、賞賛の言葉はかけてくれません。

That audience (they) will not offer words of praise for their performance.

それどころか、いつでも、自分のパフォーマンスの欠点を捜し続けて、自分に対して、さらなる高みを要求します。

Instead, they continually search for flaws in their own performance and demand higher and higher from themselves.

そのパフォーマンスは、更に、大きく、高く、磨かれ、誰も追いつくこともできないものになっていきます。

The performance will be even greater, higher, and more polished, and no one will be able to catch up to them.

私たちは、彼らからは一顧だにされない、指を加えて眺めるているだけのモブです。

We are just a mob of people who are not given a second thought by them, just adding their fingers and watching.

-----

尊敬に値する行為だと思いますが ―― 私は、そんな生き方はゴメンです。

I think it's a respectful act, however I'm not going to live that way.

そもそも、そんな生き方して、楽しいか? と思います。

In the first place, do I enjoy living that way? I think.

私は、コラムを書き上げた時、自分の思った通りにプログラムが動いた時、発明が頭の中で図面に落ちた時、

When I finish a column, when a program works the way I want it to, when an invention falls into a detailed drawing in my head.

―― 自分の頭の中の発表会場で、たくさんの自分が一斉に満場総立ちになり、万雷の拍手と歓声の嵐が巻き起こります

In the presentation hall in my own head, all of me are standing at the hall with a storm of thunderous applause and cheers

セルフ・スタンディングオベーションです。

It is the self standing ovation.

私は、厳しい自己研鑽の上で、世界に比類なき何かを目指すよりも、自分の手の届く範囲の高みに手が届く度に、簡単に何度でも満足し続ける「安い」自分が好きです。

I like my "cheap" self to continue to be easily satisfied again and again with the heights within my reach, rather than to aim for something unparalleled in the world, based on rigorous self-improvement.

世界から注目される著名な人と私の共通している点があるとすれば、『世界がどう思おうが、知ったことか』という一点のみです。

If there's one thing that I have in common with the world's most notable personalities, I have only one point: 'I don't care what the world thinks.

-----

本日、私は、自力で、スタッドレスタイヤをノーマルタイヤに交換し終えました。

Today, I finished changing the studless tires to normal tires on my own.

今日も、私は『スタンディングオベーション』です。

Today, too, I am in 'standing ovation'.

2022/04,江端さんの忘備録

β世界線であれば第三次世界大戦が起こる未来に「収束」し、α世界戦であればディストピアに「収束」する。

If it is a beta world line, it "converges" to a future in which World War III occurs, and if it is an alpha world war, it "converges" to a dystopia.

岡部倫太郎が、その「収束」が一切ないシュタインズ・ゲート世界線に到達することで、第3次世界大戦という未来が、阻止されます。

The future of World War III is prevented when Rintaro Okabe reaches the Steins;Gate world line, where there is no such "convergence" at all.

それはさておき。

Aside from that.

-----

今や、現実世界では、本気の第3次世界大戦の危機にあります。

Now, in the real world, we are on the verge of a serious World War III.

これまで人類は世界大戦を2回やってきました。

So far, humanity has fought two world wars.

さらに3回目も「大国のエゴ」で開戦したりしたら、私たち人類は『バカ』の謗りを避けられません。

And if we start another war for the third time because of the "egos of the great powers," we human beings will inevitably be slandered as 'idiots'.

第3次世界大戦は、宇宙戦争すらも超越した、「時空をかけた闘い」の中で語られるべきなのです。

World War III should be told in the context of a "struggle through time and space" that transcends even space wars.

私には、シュタインズゲート・ゼロのオープニングと同じ風景を、現在進行形で地球上に作り出している「あいつ(ら)」を、許す理由はないです。

I have no reason to forgive "those people" who are currently creating the same scenery on earth as the opening of Steins;Gate Zero.

-----

ちなみに「論文が燃えたくらいで、研究がパーになる」てなことは、ないです。

By the way, there is no such thing as "research is not ruined just because a paper is burned".

研究員であれば、自分の論文(or 特許明細書)が、10回燃やされても、11回書き直すことができます。

If you are a researcher, you can rewrite your paper (OR patent specification) 11 times even if it is burned 10 times.

中鉢博士は、自分の娘(牧瀬紅莉栖)の論文の内容の理解はもちろん、剽窃(ひょうせつ)すらできなかった、ということです。

Dr. Nakabachi could not understand or even plagiarize the contents of his daughter's (Kurisu Makise's) paper.

-----

ともあれ、午前0時を過ぎてから、NetFlixから「シュタインズ・ゲート"を"選択」するのは止めましょう。

Anyway, don't "select" Steins;Gate from NetFlix after midnight.

# 「シュタインズ・ゲート"の"選択」ではありません

# It is not Steins;Gate's selection.

結構なディストピア ―― 平日のオールナイト上映会 ―― が待っています。

Quite a dystopia -- all-night weekday screenings -- awaits.

2022/03,江端さんの技術メモ

golangのプログラムの中でブロードキャストするのであれば、

https://github.com/MicrosoftArchive/redis/releases/tag/win-3.2.100

で、redisサーバをインスールして、

https://github.com/gomodule/redigoを使うという手もありますが、

Redigoを使う(6) パブリッシュ/サブスクライブ

のサンプルプログラムで簡単に試すことができます。

 

 

2022/03,江端さんの技術メモ

brian-goo/pubsub-go

(1)redisサーバを援用して、(2)golangをサーバにして、(3)websocketでブロードキャストが実現できて、(4)JavaScriptをクライアントとして使える、(5)OSSを捜し出しました。

理由は、複数のWebに同じ地図と車両の移動をリアルタイムを表示しなればならないのですが、Websocketはユニキャスト通信しかできないので、困っていました(UDPとか使えればいいんですが、スマホでUDPが通るとは思えないので)。

WebSocketでブロードキャストを作るのが辛いので、これを援用したいと思います。

これは、http://localhost:5000 でブラウザを立ち上げると、サーバを介してブラウザ→ブラウザにメッセージがechoされます。

redisサーバを立ち上げておいて、main.goと、js/index.htmlだけで動きます。

上記を改造すれば、サーバからパブ(pub)、webブラウザでサブ(sub)が可能になるはずです ―― 多分


実験した結果、subscribeしたオブジェクトに、過去のデータもpublishされることが分かりました。

subscribe以前のデータを取込むと逆に困る(過去のデータは不要な上に、データの表示もバラバラになる)ので、pubsub-goの採用は見送り、redigoの方を使うことにしました。

redisを前提として、golangでPubSubを実現するプログラム

JavaScriptを直接のクライアントとして使いたかったのですが、redigoと連携するJavaScriptが見つけられなかった(かなり捜したつもり)ので、Golangで立ち上げるハンドルの中で、個別に対処することにしました。

 

 

 

 

 

2022/03,江端さんの技術メモ

C:\Users\ebata\goga\1-10>のI_hate_go_server.md が本体です。

1. Golangのサーバなんか大嫌い

このドキュメントは、絶対的な意味において「無保証」です

Golangで作るサーバは、HandleやらHandlerやら、ハンドル、ハンドルとうるさい! と叫びたくなること、甚しいです。

さすがに、C言語のfork()まで戻りたいとは思えませんが、『あれは、あれで、何をやっているのか分かった』とは言えました。

で、もう正しい理解かどうかは、無視して、もう、誰の話も聞かん! 江端はこういう風に理解すると決めた!! ことを記載しておきます。

2. サーバ側の江端の理解

2.1. http.Handle()は、ブラウザに入力するURLと、index.htmlの場所を教えるものである

http.Handle("/", http.FileServer(http.Dir(".")))

は、https://xxx.xxx/ でアクセスできて(http://xxx.xxx/yyyy のように"yyyy"はない)、index.htmlが、goのサーバのプログラムと同じディレクトリ(".")にいる、と宣言するもの。

http.Handle("/tomo", http.FileServer(http.Dir("./js")))

であれば、https://xxx.xxx/tomo でアクセスできてindex.htmlが、goのサーバのプログラムと同じディレクトリのしたのjs("./js")にいる、と宣言するもの。

2.2. "http.HandleFunc()"は、クライアントがやってくるごにに一つづつ立ち上があるfork()のようなものである→大嘘でした(現在修正検討中) 

具体的には、こちらを読んで頂くと良いと思います。

repeated read on failed websocket connection (一応解決)

要するにwebブラウザ(クライアント)からのアクセスがあれば、この関数がfork()の用に立ち上って、Webブラウザとの面倒を見る。→大嘘でした

面倒見ません。

まず第一に、http.HandleFunc()の誤解がありました。私は、これを、fork()のようにプロセスかスレッドを発生さるものと思っていましたが、これは、一言で言えば、単なるコールバック関数でした。

乱暴に言えば、Webからアクセスがあると、func()というファンクションに吹っ飛ばされる、という現象を発生させる"だけ"で、それ意外のことは何にもしてくれないのです。

これは、index.htmlの内容をクライアントの押しつけるfork()関数と考えれば足る。→大嘘でした

(後で述べるが)これで、

http://localhost:8080 

でアクセスできるようになる

http.ServerFileというのは、実装されているので、わざわざ main.goに書く必要はない。

一方、

http.HandleFunc("/chat", HandleClients)

は、

func HandleClients(w http.ResponseWriter, r *http.Request) { 
    //色々
}

で定義されている、コードをfork()のように立ち上げるものである、と考えれば足る。→大嘘でした(現在修正検討中) 

単にその関数に飛んでいくだけです(但し、ソケット情報を付けてくれます)

"/chat"とは何か?

(後で述べるが)これで、

http://localhost:8080/chat 

でアクセスできるようになる

2.3. "http.ListenAndServe(":8080", nil)"は、「localhost:8080をサーバにするぞ」を実行するものである

上記の関数は、"/"やら、"/chat"やらの(相対的)なパスを指定しているが、これは、サーバのアクセスするアドレスとポートを決定するものである。

err := http.ListenAndServe(":8080", nil)
if err != nil {
	log.Fatal("error starting http server::", err)
	return
}

で、これを宣言することで、サーバとして使えるようになる。

ちなみに、(":8080", nil)の"nil"は、上記のhttp.ServerFile()と、http.HandleFunc()を使うぜ、の意味になる(直接編集することもできるらしい)。

2.4. upgrader.Upgrade(w, r, nil)は、HTTP通信からWebSocket通信に更新してくれるものである

これは"github.com/gorilla/websocket"が提供してくれるもので、HTTP通信(一方通行)からWebSocket通信(相互通行)に更新してくれる便利なものらしい。

websocket, err := upgrader.Upgrade(w, r, nil)
if err != nil {
	log.Fatal("error upgrading GET request to a websocket::", err)
}

こうしてしまえば、websocket.ReadJSON()やら、websocket.WriteHSON()やらが、バカスカ使えるようになる。

2.5. これは何だろう

http.Handle("/static/", http.StripPrefix("/static", http.FileServer(http.Dir("static"))))

まあ、"/static/" は、通信コネクションでいいして、http.StripPrefix("/static", http.FileServer(http.Dir("static")))については、「/static」をhttp.FileServer()が捜索するURLから除く という意味です。

2.6. 乱暴に纏めると

http.HandleFunc()と、http.ListenAndServe()の』2つだけ覚えておけば、いいんじゃない?、と思う。

3. クライアント側の江端の理解

3.1. Dialer構造体のdial関数は、サーバとの接続要求をするものである

一般的にクライアントはWebブラウザなんだけど、これをgolangのプログラムからwebsocketでアクセスしようとする場合は、こんな感じになる。

var addr = flag.String("addr", "0.0.0.0:8080", "http service address")

func bus(bus_num int) {
    var bus BUS

    ///////////// 描画処理ここから ////////////////
    _ = websocket.Upgrader{} // use default options

    flag.Parse()
    log.SetFlags(0)
    u := url.URL{Scheme: "ws", Host: *addr, Path: "/echo2"}
    log.Printf("connecting to %s", u.String())

    c, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
    if err != nil {
        log.Fatal("dial:", err)
    }
    defer c.Close()

まず、グローバルで、以下のようにサーバを場所を書いておく。

var addr = flag.String("addr", "0.0.0.0:8080", "http service address")

(よく分からないんだけど)以下のような書き方でwebsocket(のインスタンス?)が作れるらしい。

 _ = websocket.Upgrader{} // use default options

以下で、/echo2を使うぜ、の宣言

    u := url.URL{Scheme: "ws", Host: *addr, Path: "/echo2"}

で、以下で、websocket用のソケットができるらしい。

    c, _, err := websocket.DefaultDialer.Dial(u.String(), nil)

この後はc.ReadJSON()やら、c.WriteJSON()やらを使い倒す、ことができるようになります。

4. 江端の理解 その他について

4.1. flag.Parse()って何?

var addr = flag.String("addr", "0.0.0.0:8080", "http service address")

を"固定するもの"でいいのかな? → 間違っています。→ golang でコマンドライン引数を使う

4.2. log.SetFlags(0)って何?

import "log"
で、logを使う場合に、logの設定をリセットするもの、で良さそうです。

以上

内容間違っていたら、優しくご指摘下さい。

 

 

2022/03,江端さんの忘備録

最近、読者の方からメールを頂きます。

Recently, I received emails from readers.

多くの場合は、礼儀正しいメールで、嬉しいです(ファンレターが多い)。

Often it's a polite email, and I'm happy to receive it (often fan letters).

ただ、私のコラムに反論する人の中には、「失礼な人」がいます。

However, some of the people who argue with the content of my column are "rude".

-----

私に意見(反論)を行う以上、「立証責任の原則(*1~4)」くらいは守って欲しいです。

As long as you are giving me an opinion (rebuttal), I would like you to at least observe the "principle of burden of proof (*1-4)".

(*1)https://www.kobore.net/diary/?date=20160614

(*2)https://www.kobore.net/diary/?date=20180515

(*3)https://www.kobore.net/diary/?date=20191002

(*4)https://www.kobore.net/diary/?date=20201112

特に、『江端さんのXXXという意見には賛成できません。○○を調べてみて下さい』という数行のメールが、私を激怒させています。

In particular, 'I do not agree with Mr. Ebata's opinion of XXX. Please look into XXX.' A few lines of the e-mail infuriated me.

何度も言います。

I will say it again and again.

『私が、私(江端)の意見を否定する論を作るために、なぜ、私(江端)が汗をかかなればならないのですか?』

"Why should I (Ebata) sweat to make an argument that I (Ebata) disagree with?"

-----

あなたが、私(江端)の論に反論するのであれば、

If you are going to refute my (Ebata's) argument, then

(1)あなたが自力で仮説(江端に論対する反論)を立て、

(1) You formulate a hypothesis (a counterargument to Ebata's argument) on your own, and

(2)あなたが自力で調査し、

(2) You investigate on your own, and

(3)あなたが自力で出典を明らかにして、

(3) You identify the source on your own, and

(4)あなたが自力でデータ収集・分析・解析をして、

(4) You collect, analyze, and analyze the data on your own.

(5)あなたの仮説(江端の論に対する反論)が採用される(棄却されない)旨の論を自力で展開して、

(5) You develop an argument on your own to the effect that your hypothesis (refutation of Ebata's argument) is adopted (not rejected), and

(6)上記(1)~(5)の全てを、あなた自身の言葉で記載する

(6) You describe all of the above (1)-(5) in your own words

このプロセスの全てがメールに記載されていることをもって、「立証責任の原則」が満たされた、と、私は判断します。

I would judge that the "Burden of Proof Principle" has been met, with all of this process being described in the email.

少なくとも、最後の『あなた自身の言葉で記載する』は、絶対です。

At least the last one, 'describe in your own words', is absolute.

-----

私はコラムを執筆する時に、膨大な時間と頭とお金(自腹)を使い、多くの人の協力を得ています。

I spend an enormous amount of time, head and money (my own money) when I write my columns, and I have the cooperation of many people.

私に意見(反論)を試みる方に対して、私は、同程度のコスト(負荷)を要求します。

I demand the same level of cost (load) for those who attempt to give me an opinion (rebuttal).

物量的に言えば「最低でも50行以下のメールということはないだろう」という感じです。

In terms of quantity, it's like, "At the very least, it's not going to be less than 50 lines of mail.

その他、コラムに記載していないメールアドレスを使って、連絡を取ってくる人は、論外です。

Other people who contact you using an e-mail address not listed in the column are out of line.

-----

この程度の礼節は、形式的であったとしても、守って下さい。

Please observe this level of civility, however formal it may be.

私は、いきなり、私を『勉強不足』呼ばわりする人と、コミュニケーションする意思も時間もありません。

I have neither the will nor the time to communicate with someone who suddenly calls me 'unlearned'.

2022/03,江端さんの忘備録

私、今年度、幸運なことに、国際学会で論文賞を頂くことができました。

I was fortunate to receive a best paper award at an international conference this year.

今でも、『騙されているのでないか』と疑うほどの幸運です。

I am so lucky that even now I wonder, 'Were I being cheated?

正直、論文賞どころか、採択すらされないだろう、と思っていたくらいです。

To be honest, I even thought that the paper would not even be accepted, let alone win the best paper award.

というのは、私、この論文、私がいつも書いているようなコラムのノリで執筆したからです。

This is because I wrote this paper in the same style of the columns I usually write.

-----

つまり、怒りや、不満や、後悔や、そして現場で立て続けに発生する不具合、文句、クレームなどを ―― 、赤裸々に 、しかし、論文の体裁を越えない範囲で ―― 書き殴ったものだからです。

In other words, it is a bare-bones description of anger, frustration, regret, problems, complaints, and claims that keep cropping up in the field, without going beyond the style of a thesis statement.

一言で言えば『フィールド(野外)での実証実験の地雷原一覧』のようなもので、『軽々しく"実証実験"を口にする人々』に対する、抗議の集大成のような論文でした。

In a nutshell, the paper was like a "list of minefields for field trials," and was the culmination of a protest against "those who talk about 'field trials' so casually".

今になって思えば、

In hindsight, I think,

―― そこがウケたのかな?

"Was that what they liked about it?"

と思っています。

論文査読者は、フィールド実証実験で『地獄』を見たことのある人だったのかもしれません。

The paper reviewer may have been someone who had seen 'hell' in a field trial.

そのような方であれば、「内容の精査の前に、感情的に、アクセプト(採択)してしまった」という可能性はあります。

If they are such persons, it is possible that they may have "emotionally accepted (adopted) the paper before examining the content carefully".

私がレビューアなら、そうします(断言)。

If I were a reviewer, I would do so(I assure you).

という訳で、あなたが研究員であれば、『感情を、前面かつ全面に押し出す論文』というのを、一度、試みることをお勧めします。

Therefore, if you are a researcher, I recommend that you try to write a paper that puts emotion not only front but also all.

-----

で、できれば、日本語以外での言語での執筆をお勧めします。

If possible, I strongly recommend writing in a language other than Japanese.

『国内での各所からのツッコミが少なくなる』ことは、経験的に知っています。

I know from experience that there will be fewer claims from various parts of the domestic.

2022/03,江端さんの技術メモ

PrumeClusterは、Leafletをベースとして動く、スケーラブルオブジェクトビューアです。1万オブジェクトくらいなら軽く表示できます。

しかし、PrumeClusterは、クライアントのブラウザの中にアイコンのオブジェクトを直接作るので、基本的にはサーバとして使うことができません。クライアントとして使うものであて、描画画面は、常に"1つ"です。

で、私が作ったPrumeMobileもベースは、PrumeClusterなので、サーバとして使うことはできないのですが ―― 今週末、Vue.jpとかでスマホクライアント作ろうかと思ったのですが ――『もう新しいこと覚えるのは嫌だ』と思い知り、PrumeMobileのサーバ化を試みています ――ひとえに、考えうる限り、手を抜きたい、という一心からです。

複数のJavaScriptに対して、PrumeClusterがメッセージをブロードキャスト送付してくれるのか、くれないのか、明日調べよう。