2023,江端さんの技術メモ

strconv.FormatFloatだの、strconv.FormatIntだの、色々あるけど、

fmt.Sprint(x)  xは、整数でも実数でも可

で十分だと思う。

2023,江端さんの忘備録

今年の下半期からの忙しさは凄かったと思います。

I think I have been very busy since the second half of this year.

それでも、なんとか凌げていたので『なんとかなるもんだなぁ』とか思っていました。

Still, I managed to get by, so I thought, 'I guess I can get by'.

しかし、歯痛→腰痛→風邪による全身疲労が、ここ2週間くらい立て続けで発生し、予定通りに物事が進んでいません。

However, things have not been going as planned due to a series of dental pain, back pain, and general fatigue caused by a cold that has been occurring in rapid succession for the past two weeks.

「パフォーマンスが発揮できない」 → 「予定した仕事が進まない」 → 「焦る」 という段階までは、よくあるのですが、今は、

I have often experienced the "I can't perform" → "I can't get the work done" → "I'm in a hurry" phase. However Now the situation is as follows.

『何か考えようとすると、吐き気がする』

'I get nauseous when I try to think about anything'

という状況です。

こうなると、もう、何もできなくなります

When this happens, there is nothing more that can be done.

こういう状況になって、普段の自分を俯瞰すると、

In situations like this, when I look down on my normal,

―― 私、一体、何のために、毎日あんなに頑張っていたんだっけ?

"What in the world was I working so hard every day for?"

という気持ちになってきます。

This is the feeling I have now

-----

多分、私は、この状態が回復したら、こんなことを忘れたかのように、自分のことや、他人のことを言い始めると思います。

Maybe when I recover from this condition, I will start talking about myself and others as if I have forgotten all this.

しかし、今の『弱っていて、何もできないこの状態の自分がデフォルト』である、ということを覚えておくために、この日記を残しておきます。

However, I leave this diary to remember that I am now 'weak and unable to do anything about this situation', which is my default.

被災して、罹患して、心が壊れて、疲れ果てて、立ち上がることもできない人々に、『がんばれ』とだけ言い放つ人間にだけは決してなるまい、と、再度、自分に言い聞かせるためにも。

To remind myself once again that I will never make me a person who only says, "Hang in there," to people who have been affected by the disaster, who have been afflicted, who are broken, exhausted, and unable to stand up.

今は頑張らなくていいんですよ

 

2011,江端さんの忘備録

命からがら逃げてきて、今日の命を生きているのがやっとの人たちに、

電気があって、御飯が食べられて、ゆっくり寝られる人達が、

よくもまあ、あれほど簡単に、

「がんばれ」

を連発できるものだと思っています。

「かならず復興する。日本人は強い。信じている」

復興する為に、被災地の人は、がんばらなければならないのか?

アンタが信じていたら、それが一体何の役に立つというのか?

-----

違うだろう。

「がんばる」のは被災地の人ではない。

幸いにして被災地にいなかった人だ。

『いままで本当に大変でしたね。当面、私達にやらせて下さい。今は頑張らなくていいんですよ』

『もう帰ってこない人もいて辛いと思うけど、でも、できるだけ早く、また同じように生活できるように、私達ができることはするから。途中で逃げたりしないから』

と、なぜ言ってあげられない。

-----

13年前、私が被災地に入って、ほんの少し(3日間)だけボランティアで働かせて貰った時のことです。

被災地のレポートを開示したのですが、その時に貰ったリプライへの「すさまじい違和感」を今でも覚えています。

例えば、――『被災地のハザードマップを組み込んだGPSを開発して、被災地に送ってはどうか』

あるいは、―― 『通信インフラを確保する、自律型の通信中継器を開発して、提供してはどうか』

この意見は、誠に建設的かつ実用的、加えて有用な提言ではありますし、私も、被災地に出かけていかなかったら、間違いなく同じことを言っていたと思うのです。

でも違うんです。

-----

『違うんだ!今、本当に必要なのは、「水」「食い物」そして「屋根」だ!』

と、叫びそうになって ―― でも、黙っていましたけど。

そんなことを言ったら、誰もが萎縮してしまって、何も言わなくなってしまうと思ってしまったからです。

それは良くないことだと思いました。

-----

そして、残念ながら、今私が毎日書いている日記が、上記と同じような、的外れなことを言っているのだろうことを――

そして、また、命を守る為の日々を生き、また、命を賭けて闘っている最前線の多くの人を、無造作に傷つけているのだろうことを――

どこに向かって申し上げれば良いのか分からないまま、今、天を仰いで、お詫びしたい、と思っています。

2023,江端さんの忘備録

■日中、倦怠感でだるさを感じる

- Feels tired throughout the day

■夜中に咳で目がさめる。

- Wake up at night with a cough.

■喉にタンが絡む。タンを切る時に痛みがある

- Phlegm in throat. Pain when cutting phlegm.

■夜寝る前に猛烈な悪寒がある

- Violent chills before going to bed at night.

■夜中にぐっしょりの汗をかく

- Sweating profusely at night

■水は定期的に摂取している。

- Water is consumed regularly.

■市販薬は、「改源」と「コンタックEX」を摂取したが、改善は見られない

- Over-the-counter medications were ingested "Kaigen" and "Contac EX", but no improvement was seen

-----

というメモを作って、本日クリニックに行ってきました。

I went to the clinic today after making the note.

コロナかインフルエンザか、とも思ったのですが、熱が36.6度なので、どっちでもないだろうなと思いました。

I thought it might be corona or influenza, but since my fever was 36.6 degrees, I thought it could be neither.

それでも、発熱者扱いとして、診察室の外で待たされました ―― 窓が開けっぱなしの廊下は寒かったです。

Still, I was treated as a fever patient and made to wait outside the examination room -- it was cold in the hallway with the windows left open.

-----

薬を貰って、早速飲みました。

I got the medicine and took it immediately.

その一時間後ですが、さっきまで指一本動かせない倦怠感の中にいたのですが、、現在は、この文章を書ける状態になっています(まだ、倦怠感はあります)。

An hour later, I was in a state of fatigue where I could not move a finger, but now I am able to write this sentence (I still have the fatigue).

やっぱり処方薬は凄いなぁ、と思いました、

I knew that prescription drugs were great.

2023,江端さんの忘備録

■自分の魅力や能力を、過去の実績で語っても無駄

- Talking about one's attractiveness and abilities in terms of past achievements is useless.

■自分の魅力や能力をを主張したいのであれば、まさに"今"の、"現在進行形"の自分の仕事や学業で見(魅)せなければならない

- If you want to assert your attractiveness and abilities, you must show them through your work and studies in the "present" and "ongoing" state.

―― と。

以前、私の娘に、自分の過去の経歴をメールで送ってきたおっさん(定年後)のことを思い出していました。

I was reminded of an old man (retired) who once emailed my daughter about his past career.

仕事やら海外赴任や自分の職歴やらの情報が書かれていて ―― この私ですら、その内容に"ドン引き"しました。

It contained information about my job, overseas assignments, his work history, etc. - even I was "taken aback" by the contents.

本件、娘から相談されたので、私が穏便な対応策(個人情報保護に関する事項)を娘にアドバイスして、事なきに至ったようですが。

Since my daughter consulted me on this matter, I advised her on how to deal with the matter (matters related to the protection of personal information) in a calm manner. After that it seemed to be resolved.

シニアの『"昔の武勇伝"ハラスメント』を叩き壊すのに、十分な、脅威(恐怖)だっただろうと思います。

-----

―― 自分のシニアを放置し続けると、どんどん自分を見苦しくすることになる

"If you continue to neglect "your old", you will make yourself look worse and worse"

ということを、私に実感させてくれた事件でした。

This was an matter who made me realize that.

しかし、『シニアになると、ジュニアの頃のパフォーマンス』が発揮できなくなるのは、本当です。

However, it is true that 'as you become a senior, you cannot perform as well as you did as a junior.

ですから、『過去の自分の栄光にすがりつきたい』『他の人に、過去の自分のスゴさを理解して貰いたい』というシニアの気持ちは、よく分かるのです。

Therefore, I understand the senior's desire to 'hang on to his past glory' and 'have others understand how great he was in the past.

-----

その点、私は、コラムなどで『過去の自分の栄光』を語れるフィールドがあって、かなり幸せだなぁ、と思っています。

In that respect, I am quite happy to have a field where I can talk about my 'past glory' in my columns and so on.

故に、今、私は、最大の感謝と忖度(そんたく)を込めて叫びます。

Therefore, I now want to exclaim with the utmost gratitude and condescension.

『EE Times Japan 編集部 万歳 !』

"Long live the editors of EE Times Japan!"

2023,江端さんの忘備録

私が自分のブログで、頻繁に、短いプログラムをアップロードしているのは、マニュアル読んだって、APIの使い方が分からないからです。

I frequently upload short programs on my blog because I don't know how to use the API even after reading the manual.

このようなマニュアル読んでもさっぱり分からないし、サンプルプログラムは、私のやりたいこととズレています。

I have no idea what I'm doing by reading these manuals, and the sample programs are out of sync with what I want to do.

ですので、以下のように、

So, as shown in the following

golangによるcsvファイルのライン単位での書き出し方法

実際に、自分で書いて動いたコードを、小まめに残するようにしています。

In reality, I try to keep a small code that I have written and worked with.

他の人の役に立つかどうかは、二の次です。

Whether it is useful to others is secondary.

この方法に名前をつけるとすれば「具体例ベース」というのかもしれません。

If I had to give a name to this method, it might be called "concrete example-based".

それはさておき。

Aside from that.

-----

イベントの招待状などで、『平服にてご参加下さい』という文言が入っていることがありますが ――

In invitations to events, you may see the phrase, "Please attend in plain clothes.

私に言われれば、これは、最低最悪のホスピタリティです。

If you ask me, this is hospitality at its worst.

つまり『礼服はやめてね』と言っているだけで、カジュアルのレベルの判断をゲストに押しつける、無責任極まりない要求であるからです。

In other words, he/she is simply saying, 'Please don't wear formal wear,' and you are forced to judge the level of casual wear. This is an extremely irresponsible request.

ゲスト(招待客)は、カジュアルのレベルを間違えて、会場で恥しい思いをするかもしれません ―― しかし、そういう配慮をするホスト(主催者)には、滅多にお目にかかることができません。

Guests (invitees) may be embarrassed at the venue because of the wrong level of casualness -- but I rarely see a host (organizer) who takes such considerations into account.

-----

先日、父と母の納骨供養の案内を出しました。

I recently sent out information about the event laying their ashes to rest for my father and mother.

江端一夫・瑤子 納骨供養のご案内(公開版)

その中で、私は、ドレスコードを以下のような文章で、正確に規定しました。

In it, I have defined the dress code precisely in the following sentence.

『ご都合がよろしければ、平服にて御気軽にお立ち寄りをご検討頂ければ幸いです』

I hope you will consider stopping by in plain clothes if it is convenient for you.

『(私(智一)は、ジーパンとスニーカーと数珠持参で参加予定です)』

I (Tomoichi) will wear jeans, sneakers and prayer beads.

このように、ホストが、ホスト自身のドレスコードを具体的に提示することで、ゲストの負担を減らすことができます。

In this way, the host can reduce the burden on the guests by providing them with a specific dress code for themselves.

これが、「具体例ベース」です。

It is "concrete example-based".

-----

今後、「平服」を具体例で示さないホストには、このブログのURLをメールで送りつけようと考えています。

In the future, I will email the URL of this blog to hosts who do not provide specific examples of "plain clothes".

2023,江端さんの技術メモ

Keyword: golang csv write 書き出し ライン

package main

import (
	"database/sql"
	"encoding/csv"
	"fmt"
	"log"
	"os"

	_ "github.com/lib/pq"
)

func main() {
	file, err := os.Open("yamaguchi_area.csv")
	if err != nil {
		log.Fatal(err)
	}
	defer file.Close()

	r := csv.NewReader(file)
	rows, err := r.ReadAll() // csvを一度に全て読み込む
	if err != nil {
		log.Fatal(err)
	}

	str := "SELECT ST_Covers(st_geomfromtext('POLYGON(("

	// 行ごとに
	for i, row := range rows {
		if i == 0 {
			continue // CSVのヘッダー行を無視
		}

		str += row[1] + " " + row[2] + ", " // rowのままで取り出せば、文字列になっている

	}
	str1 := str[:len(str)-2] + "))'),st_geomfromtext('LINESTRING(" // 上記の最後の", "を削除して、文字列を追加

	dbMap, err := sql.Open("postgres",
		"user=postgres password=password host=192.168.0.23 port=15432 dbname=yama_db sslmode=disable")
	log.Println("------------------ map db open ------------------")
	if err != nil {
		log.Fatal("OpenError: ", err)
	}
	defer dbMap.Close()

	///////////////////////////////////////

	file2, err2 := os.Open("20220518weekday.csv")
	if err2 != nil {
		log.Fatal(err2)
	}
	defer file2.Close()

	r2 := csv.NewReader(file2)
	rows2, err2 := r2.ReadAll() // csvを一度に全て読み込む
	if err != nil {
		log.Fatal(err2)
	}

	file3, err3 := os.Create("testtest.csv")
	if err3 != nil {
		panic(err)
	}
	w := csv.NewWriter(file3)

	for _, row := range rows2 {
		//if i == 0 {
		//	continue // CSVのヘッダー行を無視
		//}

		str2 := str1 + row[0] + " " + row[1] + ", " + row[2] + " " + row[3]

		str2 += ")'))"

		//fmt.Println(str2)

		rows1, err := dbMap.Query(str2)
		if err != nil {
			log.Fatal(err)
		}
		defer rows1.Close()

		//var dt string
		var dt bool

		for rows1.Next() {
			if err := rows1.Scan(&dt); err != nil {
				fmt.Println(err)
			}
			// fmt.Println(dt)
			if dt {
				output := []string{row[0], row[1], row[2], row[3], row[4]}
				//fmt.Println("output:", output)

				if err = w.Write(output); err != nil {
					log.Fatal(err)
				}
			}
		}

		err = rows1.Err()
		if err != nil {
			panic(err)
		}

		defer w.Flush()

		if err := w.Error(); err != nil {
			log.Fatal(err)
		}

	}
}

重要なのは、以下のコード

file3, err3 := os.Create("testtest.csv")
if err3 != nil {
panic(err)
}

w := csv.NewWriter(file3)

output := []string{row[0], row[1], row[2], row[3], row[4]}
//fmt.Println("output:", output)

if err = w.Write(output); err != nil {
log.Fatal(err)
}

defer w.Flush()

2023,江端さんの忘備録

江端家では、テレビの音声を手元に届ける為に、FMトランスミッタ + ラジオを使ったシステムを使っています。

The Ebata family uses an FM transmitter + radio system to bring the TV sound to their hands.

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

上記の「豊作ラジオ」は、江端家で2台稼動中ですが、

Two of the above "bumper radios" are now in operation in the Ebata household.

下記の、固定局FMトランスミッタ(車載用を除く)は、販売されていないようです。

However, the following, fixed station FM transmitters (except for in-vehicle use) do not appear to be available for sale.

まあ、江端家では、まだ2台、予備の在庫を確保しているので大丈夫なのですが(先日、実家の一台を回収しました)。

Well, the Ebata family still has two of them in reserve, so we are fine (we recently retrieved one from my parents' house).

-----

最近、音声を認識できなくなることで、認知障害が進行しやすくなる、という研究結果のニュースを見ました。

I recently saw a news story about a study that found that the inability to recognize speech sounds can lead to progressive cognitive impairment.

「補聴器」の早期着用が推奨されていましたが、こういうラジオを使ったシステムも有効だと思います。

Early wearing of "hearing aids" was recommended, but I think this kind of radio-based system is also effective.

ラジオをどこに運んでも、音声が聞こえるのは、嬉しいです(例えば、私は2Fの書斎で、NHKスペシャルを「聞きながら」、プログラミングをしています)。

It is nice to be able to hear the audio wherever I carry the radio (for example, I am programming in my study on the 2nd floor while "listening" to the NHK special).

-----

ただ、そういう製品、結構販売されているようですので、無理して、このようなシステムを作る必要はないのかもしれません。

However, such products seem to be sold quite well, so there may be no need to force the creation of such a system.

しかし、「送信機(FMトランスミッタ)」だけ販売してで、どんなラジオでも対応O.K.というのは、結構「美味しい」と思うのですが、案外、一体型の方が、高齢者のニーズに合っているのかもしれません。

However, I think it is quite "good" to sell only a "transmitter (FM transmitter)" and any radio can be used with it, but perhaps the integrated type is better suited to the needs of the elderly.

-----

私は、ラジオの電池にも工夫しています。

I am also creative with my radio batteries.

電池2個だけで動くようにしたり、と、いろいろとチマチマとした省エネ対策しています。

I am taking various chiseled energy-saving measures, such as making it work with only two batteries.

2023,江端さんの技術メモ

簡単にできるみたいです。

package main

import (
	"fmt"
	"os"
)

func main() {
	//fmt.Printf("args count: %d\n", len(os.Args))
	//fmt.Printf("args : %#v\n", os.Args)

	// これでも拾えるし
	for i, v := range os.Args {
		fmt.Printf("args[%d] -> %s\n", i, v)
	}

	// こんな風にダイレクトにも取れる
	fmt.Println(os.Args[1])
	fmt.Println(os.Args[2])

}

出力結果

PS C:\Users\ebata\yamaguchi\src_try1\others> go run main7.go test1 test2
args[0] -> C:\Users\ebata\AppData\Local\Temp\go-build2152603201\b001\exe\main7.exe
args[1] -> test1
args[2] -> test2
test1
test2

2023,江端さんの忘備録

昨日の日記の中で紹介した私のコラムは、私が人生最初に公開したものです。

My column, published yesterday, was the first one I published in my life.

江端さんのひとりごと'94 「渋谷駅の惨劇」

これを、私、社内の同期のメーリングリストに流して、仲間から絶賛されたことで ―― 調子に乗りました。

I put this out to a mailing list of my peers in the company, and after receiving rave reviews from my peers -- I was in a good mood.

で、その後、ずーーーーーーと、文章を書き続けています。

And then, I've been writing ever since.

つまり、『調子に乗る』とか『いい気になる』ということが、人生のターニングポイントになることがある、ということです。

In other words, 'getting on a roll' or 'feeling good' can be a turning point in one's life.

-----

当然ですが、こんなこと(他人から絶賛されること)は、連続して続くことはありません。

Of course, this kind of thing (being praised by others) does not last continuously.

いずれ絶賛されなくなり、さらには、批判されるようになります。

Eventually, they will stop being acclaimed and even criticized.

すると、凹みます ―― 誰だってそうです。

Then you get depressed -- everyone does.

-----

この現象は、二次創作の小説などで、顕著に見られます。

This phenomenon is most noticeable in secondary novels.

私の知っている範囲で、二次創作の小説の中で、最後まで完遂しているものは、全体の1~2%程度です。

As far as I know, only 1-2% of all second novels are completed to the end.

途中で創作を投げ出してしまう人が、本当に多い。

There are so many people who give up creating in the middle of the process.

もちろん、二次創作者は、『自己満足』で『自分の娯楽』で、そして『無償』で行われているものです。

Of course, the secondary creators are 'self-satisfied', 'for their own amusement', and done 'for free'.

これを他人(読者)が批判するのは『酷』 ―― というよりは『不当』で『非礼』ですらあるとすら思います。

I think it is "harsh" -- or even "unfair" and "impolite" -- for others (readers) to criticize this.

それでも、壮大な伏線で物語を始めておいて、それを回収せず、完遂もしないのは、「作品に対して気の毒だ」とは思います。

Still, I do feel "sorry for the work" if you start a story with grand foreshadowing and never retrieve it or complete it.

-----

チヤホヤされなければ、書き続けることができない ―― 私は、この気持ちを『支持』します。

They can't keep writing if they don't get cheesed off -- I 'support' this sentiment.

しかし、しょせん他人は他人。他人は気紛れです。

But, after all, strangers are strangers. Strangers are freaks.

定常的に、自分をチヤホヤし続けてくれる人は、ほとんどいません(というか「いません」)。

There are few (or rather, "no") people who will keep you constantly cheer for you.

それ故、

Hence,

―― 私(江端)だけは、いつまでも私(江端)自身をチヤホヤし続けること

"I will continue to cheer myself forever"

は、とても大切なことなのです。

is very important for me.

-----

(以下、「日本最高峰のブロックチェーンは、世界最長を誇るあのシステムだった」より抜粋)

(The following is an excerpt from "Japan's highest blockchain was that system that boasts of being the world's longest.)

江端:「別にいいんだ。私の書いたコラムは、『たった一人の読者に届けばいい』って思っているから」

Ebata: "It doesn't matter. I just want my columns to reach just one reader."

後輩:「何ですかそれ、初めて聞きましたよ。その意味深な言葉。江端さんが、その”思い”を伝えたいたった一人の方って、一体誰です?」

Junior: "What is that? I've never heard that before. That's the first time I've heard such a meaningful word. Who is the one person to whom you want to convey your "feelings"?"

江端:「“私”」

Ebata: "It's me"

後輩:「……は?」

Juniors: "What?"

江端:「だから、“私”。私、自分のコラム読み返すのが好きなんだよねー。読み直す度に『あの時の私って、すごいこと考えていたんだなぁ』とか、『ああ、こういう考え方、いいわー、合うわー、この人好きだわー』って思うもん』

Ebata: "So, "It is me". I like to reread my columns. Every time I reread it, I think, 'I was thinking such great things at that time,' or 'Oh, I like this way of thinking, it fits well, I like this person.