ときどきの雑記帖 RE* (新南口)
遊星より愛をこめて
jq
6/25新刊:ISBN978-4-87783-491-3 カットシステム『jqハンドブック NetOps/DevOps必携のJSONパーザ』豊沢聡著 10冊入荷 pic.twitter.com/TIjvkg7fEF
— ジュンク堂書店池袋本店 PC書担当 (@junkudo_ike_pc) June 25, 2021
jq の本が出る(出ていた)とは。 どんな本か興味があるけど、出版社が出版社なのでかなり身構える:)
その辺の話は前世紀に始まるものなのでここでは書かない (つーても「エピソード」がたくさんあるわけではない)。
google spreadsheet
前回書き忘れていた。
locale (言語と地域)は英語になっていました。 とくにそうした覚えはないんですが、 gmailを英語設定にしているからかな。
いずれにしてもスッキリしました。
記号の話
むかーしむかしのPascalの本を見るとポインターに使っている記号が ^
ではなく、
↑
だったりする(正確にはそういう字形のもの、であって後代のJISにあったそれじゃあないので念のため)。
というところか話を始めようと思ったのだけど以下略。
gcal
posix-commands/013-cal.md at master · EzoeRyou/posix-commands でcalの話題を見かけ、その流れでcal を見ていたら次のような記述を発見。
The cal utility shall write a calendar to standard output using the Julian calendar for dates from January 1, 1 through September 2, 1752 and the Gregorian calendar for dates from September 14, 1752 through December 31, 9999 as though the Gregorian calendar had been adopted on September 14, 1752.
なるほど。
といいつつも、
紀元前45年にカエサルがこの暦法を導入した際に閏年は4年に1回と決められたが、直後の紀元前44年にカエサルが暗殺された後、 誤って3年に1回ずつ閏日が挿入された。この誤りを修正するため、ローマ皇帝アウグストゥスは、 紀元前6年から紀元後7年までの13年間にわたって、3回分(紀元前5年、紀元前1年、紀元4年)の閏年を停止した[注釈 5]。 紀元8年からは正しく4年ごとに閏日を挿入している。
この辺はどうしてんですかね(明記されてないんだから「処理系依存」?)。
あとこういうのも。
FUTURE DIRECTIONS
A future version of this standard may support locale-specific recognition of the date of adoption of the Gregorian calendar.
gcal
そう言えばGNUではなんかなかったろうかと思い出して(探して)みると そのものズバリ GNU gcal - GNU Project - Free Software Foundation があった。まあshell utils でも text utils でもないものなあ。
Gcal is a program for calculating and printing calendars. Gcal displays hybrid and proleptic Julian and Gregorian calendar sheets, respectively for one month, three months, or a whole year. It also displays eternal holiday lists for many countries around the globe, and features a very powerful creation of fixed date liststhat can be used for reminding purposes. Gcal can calculate various astronomical data and times of the Sun and the Moon for pleasure at any location, precisely enough for most civil purposes. Gcal supports some other calendar systems, for example, the Chinese and Japanese calendars, the Hebrew calendar, and the civil Islamic calendar, too.
かなり機能が豊富そうですな。
で、それを反映してかGNU gcal - GNU Project - Free Software Foundation をみると本当にたくさんのオプションがある。 眺めていくと興味深いものがちらほらあるのでいくつか紹介する。
–japanese-flexible-holidays
Provide the eternal holiday list additionally with Japanese holidays, that are determined in a flexible manner (only for dates after AD 1644). See Calendar option –time-offset=argument, how to change the timezone for which the Japanese holidays are calculated in a flexible manner.
–japanese-holidays
Provide the eternal holiday list additionally with Japanese holidays (only for dates after AD 1644). For dates until AD 1887 all computations done are depending fixed on Beijing local time, for later dates fixed on the timezone GMT-9.
–gregorian-reform=1582|1700|1752|1753|argument
Set the period which was skipped during the Gregorian Reformation. By default, Gcal runs in the hybrid calendar mode, i.e. Gcal automatically changes from the Julian calendar system to the Gregorian calendar system if output is related to dates after the Gregorian Reformation has happened. See Aspects in Internationalization, for more details. Actually, four fixed default periods are supported, and that of the year 1582, of the year 1700, of the year 1752 and of the year 1753.
–gregorian-reform=1802,4,7,17
Gcal is able to represent so-called proleptic calendars of a definite calendar system. This means, Gcal only uses a definite calendar system during a definite period, although there was a change to another calendar system in the historic reality during this definite period. The following proleptic calendar systems are actually supported by Gcal:
Proleptic Gregorian calendars can be created from AD 302 until AD 9999 if –gregorian-reform=301,12,31,31 is used. Unfortunately, Gcal actually cannot represent years before AD 302 in a proleptic-Gregorian manner.
Appendix A Genesis of the Gregorian Calendar
Appendix A Genesis of the Gregorian Calendar にもなかなか面白い話があるので一読をお勧め。
But this Gregorian calendar was accepted very slowly by others. Catholic countries adopted the Gregorian calendar almost immediately. Most Protestant countries on the Continent adopted the new calendar around 1700. England and the American colonies changed in 1752, by act of Parliament. Orthodox Christian countries adopted the Gregorian calendar later. Russia was the last European country to do so, after the communist revolution of 1917. As a result, the former U.S.S.R. celebrated the October Revolution (happened on October 25th, 1917) in the old style calendar on November 7th.
The era of a world wide uniform calendar is already part of history today. The Iran returned to the traditional Mohammedan lunar calendar in 1979 after removal of the Shah reign. There are some efforts to improve our currently valid Gregorian calendar. Its disadvantages are the reason why an appointed day is not always on the same week day. Besides, the month lengths are not equal and the holidays, which have relations to the feast of Easter, are moved within the calendar from one year to another. A very sophisticated suggestion was proposed by the United Nations, but the international establishment of this suggestions has failed, since it was resisted by some countries as well as the churches.
gcal 2 4
ということで先ほどの、西暦の初めの頃の日付を試してみた。
kbk@toybox4:/mnt/c/Users/kbk$ gcal --version
gcal (GNU cal) 3.6.3
Copyright (c) 1994, 95, 96, 1997, 2000 Thomas Esken
Copyright (c) 2010, 2011, 2012 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty, without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
apt で入れたのだけどずいぶん前のバージョンぽい?
Index of /gnu/gcalをみるに、 2015年6月の時点でメジャーバージョンで一つ上がってる(3.6.3→4.0)。
が、その辺の理由は追いかけずに実行。
kbk@toybox4:/mnt/c/Users/kbk$ gcal 2 4
February 0004
Sunday 3 10 17 24
Monday 4 11 18 25
Tuesday 5 12 19 26
Wednesday 6 13 20 27
Thursday 7 14 21 28
Friday 1 8 15 22
Saturday 2 9 16 23
kbk@toybox4:/mnt/c/Users/kbk$ gcal 2 8
February 0008
Sunday 5 12 19 26
Monday 6 13 20 27
Tuesday 7 14 21 28
Wednesday 1 8 15 22 29
Thursday 2 9 16 23
Friday 3 10 17 24
Saturday 4 11 18 25
kbk@toybox4:/mnt/c/Users/kbk$ gcal 2 12
February 0012
Sunday 7 14 21 28
Monday 1 8 15 22 29
Tuesday 2 9 16 23
Wednesday 3 10 17 24
Thursday 4 11 18 25
Friday 5 12 19 26
Saturday 6 13 20 27
ふむ (そういや出力フォーマットの縦横が変わってんですね。変えられないのかな?)。
追記
出力フォーマットについて続きを書いた
GNU indent
GNU indent のソースコードをちょっと眺めてみたけど、
オプションハンドリングはgetopt(getopt_long)を使わずに独自の実装で行っていた。
そして、最新バージョンでも+
もーー
と同様に
ロングオプションの開始とみなしていた。
git
ソースコード読みしばらくやってねー。
wsl のパスワード忘れた
しばらく入力する機会がなかったので忘れてしまった(笑) ということで、そういう場合の対処法のメモ。
- WSLでLinuxのパスワードを忘れてしまった場合の対処法 | LFI
- wsl でパスワードを忘れてしまった際の対処 - Qiita
- WSLでパスワードを忘れた場合【WSL】 - なんちゃってプログラマーの備忘録
簡単には、cmd.exe (コマンドプロンプトの画面) から wsl -u root
を実行し、そこからpasswd root
で再設定。