ときどきの雑記帖 RE* (新南口)
バランサー
Walter Bright
C to Rust
LLM-driven C-to-Rust. Not just a good idea, a genie eager to escape • The Register
少し前に話題になっていた(?)件の関連記事
- [B! rust] 米国防総省DARPA、C言語のコードからRustへの自動変換実現を目指す「TRACTOR」プログラム開始
- 米国防総省DARPA、C言語のコードからRustへの自動変換実現を目指す「TRACTOR」プログラム開始 - Publickey
- Translating All C to Rust (TRACTOR) | Hacker News
- DARPA: Translating All C to Rust (Tractor) : r/programming
- Translating All C to Rust
はてブのコメントは相変わらずはてブだねえ…
マジンガーZ@MX
次回最終回
ところでグレートに続くんだろうか?
新宿
新宿(にいじゅく)と新宿(しんじゅく)を間違えたフリして、両方行ったらめちゃくちゃ楽しかった! 新宿最高ッ!! | ロケットニュース24
「にいじゅく」は以前から知っていたけど つい最近「しんしゅく」もあるのを知った
「あらじゅく」もあるらしい
Excel
ずっと昔から気になっていたことをふと思い出したんですが、Excelで個人用マクロブックを使用していると、Excelを異なるプロセスとして開く(Altを押しながらExcel起動)すると2つめが立ち上がるときに図のような警告が出ますよね。
— ちゅん🐤 (@KotorinChunChun) August 11, 2024
これ出ないようにする方法はないかなー pic.twitter.com/Mrg3bMidvv
たまにこの現象に遭遇して困っていたのだけど そういう原因(理由)で出てたのか。
とある事情でこれが出ると困るので マクロブック使わないことで回避してるんだけど、 ちと不便
PEP 750
メモ。
- PEP 750: Tag Strings for Writing Domain-Specific Languages | Hacker News
- PEP 750: Tag Strings For Writing Domain-Specific Languages - PEPs - Discussions on Python.org
どんなんだろうと見てみると
name = "World"
greeting = greet"hello {name}"
assert greeting == "Hello WORLD!"
のように使うもので、定義は次のようにすると
def greet(*args):
"""Tag function to return a greeting with an upper-case recipient."""
salutation, recipient, *_ = args
_, getvalue = recipient
return f"{salutation.title().strip()} {getvalue().upper()}!"
JavaScriptに同様の機能があるということなのだけど
Template literals (Template strings) - JavaScript | MDN
const person = "Mike";
const age = 28;
function myTag(strings, personExp, ageExp) {
const str0 = strings[0]; // "That "
const str1 = strings[1]; // " is a "
const str2 = strings[2]; // "."
const ageStr = ageExp < 100 ? "youngster" : "centenarian";
// We can even return a string built using a template literal
return `${str0}${personExp}${str1}${ageStr}${str2}`;
}
const output = myTag`That ${person} is a ${age}.`;
console.log(output);
// That Mike is a youngster.
知らなかった。これ。
operator precedence
つづき。
>type hoge.c
int main()
{
int v;
0==v=1;
}
>gcc -c hoge.c
hoge.c: In function 'main':
hoge.c:4:6: error: lvalue required as left operand of assignment
0==v=1;
^
C(gcc)はさすがにこうなった一方で、Rubyは
>ruby -e "puts 0==v=1"
false
こう。 LL(とはほとんど聞かなくなりましたな)の類は どれもこっちかなと思っていたら
>perl -e "print 0==$v=1" Can't modify numeric eq (==) in scalar assignment at -e line 1, at EOF Execution of -e aborted due to compilation errors.
Perlはこうなった。 構文定義はどうなっているのかと確かめてみると
/* Binary operators between terms */
termbinop: term[lhs] PLUGIN_HIGH_OP[op] term[rhs]
{ $$ = build_infix_plugin($lhs, $rhs, $op); }
| term[lhs] ASSIGNOP term[rhs] /* $x = $y, $x += $y */
{ $$ = newASSIGNOP(OPf_STACKED, $lhs, $ASSIGNOP, $rhs); }
...
| termrelop %prec PREC_LOW /* $x > $y, etc. */
{ $$ = $termrelop; }
| termeqop %prec PREC_LOW /* $x == $y, $x cmp $y */
{ $$ = $termeqop; }
termrelop: relopchain %prec PREC_LOW
{ $$ = cmpchain_finish($relopchain); }
| term[lhs] NCRELOP term[rhs]
{ $$ = newBINOP($NCRELOP, 0, scalar($lhs), scalar($rhs)); }
| termrelop NCRELOP
{ yyerror("syntax error"); YYERROR; }
| termrelop CHRELOP
{ yyerror("syntax error"); YYERROR; }
| term[lhs] PLUGIN_REL_OP[op] term[rhs]
{ $$ = build_infix_plugin($lhs, $rhs, $op); }
;
relopchain: term[lhs] CHRELOP term[rhs]
{ $$ = cmpchain_start($CHRELOP, $lhs, $rhs); }
| relopchain[lhs] CHRELOP term[rhs]
{ $$ = cmpchain_extend($CHRELOP, $lhs, $rhs); }
;
なるほど。
新刊近刊
second edition of Clean Code
Uncle Bob Martin: “I am in the midst of writing the second edition of Clean Code.
I am in the midst of writing the second edition of Clean Code. It’s a complete rewrite, and it’s coming out very different from the first. Oh, the message is the same. But the presentation is entirely different.
宇宙技芸
山水画は描かれていないものを感じ取らせようとする、つまり”道”(ダオ)を。『易経』や『老子』、山水画の理論書などの文章を再解釈し、再帰的で対立的連続性を特徴とする「道家の論理」を形式化し、線形的な論理とは別の可能性を提示する。
— 春秋社 (@shunjusha) July 30, 2024
よくわからないが気になる
awk
open groupのawkのページ でこんな記述があるのに気がついた。
RATIONALE
In the context of the getline function, equally good arguments for different precedences of the | and < operators can be made. Historical practice has been that:
getline < "a" "b"
is parsed as:
( getline < "a" ) "b"
although many would argue that the intent was that the file ab should be read. However:
getline < "x" + 1
parses as:
getline < ( "x" + 1 )
Similar problems occur with the | version of getline, particularly in combination with $. For example:
$"echo hi" | getline
(This situation is particularly problematic when used in a print statement, where the |getline part might be a redirection of the print.)
最新のもの The Open Group Base Specifications Issue 8 でも同じ
FORTRAN Compiler on IBM 704
Hugo メモ
さらに新しいのが出てしまったけど
0.132
新バージョン対応
[以前書いた]http://www.kt.rim.or.jp/~kbk/zakkicho/post/2024/03/16/#hugo-メモ
今回のサイトのビルドができなくなった件とは関係ないのだけど、 警告が出ていたのを見逃がしていたので原因を追いかけた
この辺り、時間も経ったしなにか情報が出てないか探してみたところ
Hugoのバージョンアップで発生したエラーを修正する - タカツのサイト
- 変更前 : v0.92.2+extended(wsl)
- 変更後 : V0.125.7+extended(win10)
- hugoのテーマ : Mainroad
というのが見つかったのだけど
Googleアナリティクス用のテンプレートが廃止なったことにより、エラーがでました。 _internal/google_analytics_async.html は layouts/_default/baseof.html で読み込んでいることがわかったので、以下のように変更して解決しました。
layouts/_default/baseof.html の以下の部分を削除。
<!-- -->
でコメントアウトだとエラー回避できないので、必ず「削除」してください。{{- if not .Site.IsServer }} {{- if hasPrefix .Site.GoogleAnalytics "G-" }} {{ template "_internal/google_analytics.html" . }} {{- else }} {{ template "_internal/google_analytics_async.html" . }} {{- end }} {{- end }}
これだと google analyticsが有効にならないのでは…
さらに探すと
Use this instead:
{{ template "_internal/google_analytics.html" . }}
というのが見つかった。
ここに書かれている通り
_internal/google_analytics_async.html
を
_internal/google_analytics.html
に書き換えて解決(たぶん)
もうひとつ、ツイート貼り付けで
ERROR failed to fetch remote resource: Forbidden
これが発生する件。
エラーが起きる箇所をとりあえずチカラワザで ひとつひとつ潰していったのだけど、 以前はエラーにならなかったが今回はエラーになってしまったものが 複数あった。
ちょいと調べたところでは、 貼り付けたツイートのツイート主が凍結されたり 鍵付きになったりするとエラーになるようだ。
とすると、この先もどこかでさらに エラーのもとが増える可能性があり、 それならせめてエラーの原因がある 具体的な場所、最低でもファイルの名前だけでも わかるようにできないものかと
hugo/tpl/tplimpl/embedded/templates/shortcodes/twitter.html at master · gohugoio/hugo を再度見てみた
{{- $pc := .Page.Site.Config.Privacy.Twitter -}}
{{- if not $pc.Disable -}}
{{- if $pc.Simple -}}
{{- template "_internal/shortcodes/twitter_simple.html" . -}}
{{- else -}}
{{- $id := or (.Get "id") "" -}}
{{- $user := or (.Get "user") "" -}}
{{- if and $id $user -}}
{{- template "render-tweet" (dict "id" $id "user" $user "dnt" $pc.EnableDNT "name" .Name "position" .Position) -}}
{{- else -}}
{{- errorf "The %q shortcode requires two named parameters: user and id. See %s" .Name .Position -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- define "render-tweet" -}}
{{- $url := printf "https://twitter.com/%v/status/%v" .user .id -}}
{{- $query := querify "url" $url "dnt" .dnt -}}
{{- $request := printf "https://publish.twitter.com/oembed?%s" $query -}}
{{- with resources.GetRemote $request -}}
{{- with .Err -}}
{{- errorf "%s" . -}}
{{- else -}}
{{- (. | transform.Unmarshal).html | safeHTML -}}
{{- end -}}
{{- else -}}
{{- warnidf "shortcode-twitter-getremote" "The %q shortcode was unable to retrieve the remote data. See %s" .name .position -}}
{{- end -}}
{{- end -}}
現状``{{- errorf “%s” . -}}` となっているところを ファイル名やファイル内での位置が出るようにすれば よさそう。 んが、内部的に抱えているものだから 後から上書きとかできるんだろうか?(要調査)
hugo/tpl/tplimpl/embedded/templates/shortcodes/twitter_simple.html at master · gohugoio/hugo
{{- $pc := .Page.Site.Config.Privacy.Twitter -}}
{{- $sc := .Page.Site.Config.Services.Twitter -}}
{{- if not $pc.Disable -}}
{{- $id := or (.Get "id") "" -}}
{{- $user := or (.Get "user") "" -}}
{{- if and $id $user -}}
{{- template "render-simple-tweet" (dict "id" $id "user" $user "dnt" $pc.EnableDNT "name" .Name "position" .Position) -}}
{{- else -}}
{{- errorf "The %q shortcode requires two named parameters: user and id. See %s" .Name .Position -}}
{{- end -}}
{{- end -}}
{{- define "render-simple-tweet" -}}
{{- $url := printf "https://twitter.com/%v/status/%v" .user .id -}}
{{- $query := querify "url" $url "dnt" .dnt "omit_script" true -}}
{{- $request := printf "https://publish.twitter.com/oembed?%s" $query -}}
{{- with resources.GetRemote $request -}}
{{- with .Err -}}
{{- errorf "%s" . -}}
{{- else -}}
{{- (. | transform.Unmarshal).html | safeHTML -}}
{{- end -}}
{{- else -}}
{{- warnidf "shortcode-twitter-simple-getremote" "The %q shortcode was unable to retrieve the remote data. See %s" .name .position -}}
{{- end -}}
{{- end -}}
{{- define "__h_simple_twitter_css" -}}
{{- if not (.Page.Scratch.Get "__h_simple_twitter_css") -}}
{{/* Only include once */}}
{{- .Page.Scratch.Set "__h_simple_twitter_css" true -}}
<style type="text/css">
.twitter-tweet {
font: 14px/1.45 -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen-Sans,Ubuntu,Cantarell,"Helvetica Neue",sans-serif;
border-left: 4px solid #2b7bb9;
padding-left: 1.5em;
color: #555;
}
.twitter-tweet a {
color: #2b7bb9;
text-decoration: none;
}
blockquote.twitter-tweet a:hover,
blockquote.twitter-tweet a:focus {
text-decoration: underline;
}
</style>
{{- end -}}
{{- end -}}
ところで
ここでの名前はtwitter
なのに
shortcodeを使うときはtweet
なのは
どうなってんの?
と思ったが
var embeddedTemplatesAliases = map[string][]string{
"shortcodes/twitter.html": {"shortcodes/tweet.html"},
}
ここで解決している模様
BGM
ミナッサーン、ヨリコンデクダサーイ!
— 奉力萬 (@BURRIKIMAN) August 12, 2024
『伝説巨神イデオン 』の第17話あたりまで、戦闘場面を中心に収録曲が多数流用されたPiero Umilianiのライブラリ音楽アルバム「guerra e distruzione」 (LIUTO RECORDS/伊 1972)がついに再発です!
(単品の再発はアナログ盤のみ)https://t.co/j5c6WRePK6 pic.twitter.com/XSHS4UR3KO
また、ライブラリ音楽レーベルLiutoのアルバムをまとめて復刻したCD-BOXが9月に発売され、「guerra e distruzione」 が初CD化となります。https://t.co/Y54Z3S45Bu
— 奉力萬 (@BURRIKIMAN) August 12, 2024
2010年に『イデオン 』流用曲の出自が判明してから14年。まさに感無量です。 pic.twitter.com/POHdpLzZ2s
おお、これは と思ったものの結構なお値段すねえ (まあBOXだし)
THE COMPLETE LIUTO RECORDS HERITAGE (19CD)
gcc
役に立たないgcc豆知識
— Kazumoto Kojima (@1gkojima) August 13, 2024
* -dp や -dP オプションでアセンブラ出力が賑やかになる
-dp 出力サンプル pic.twitter.com/wETakPSTy7
— Kazumoto Kojima (@1gkojima) August 14, 2024
関数内関数
標準Cは関数の中に関数を作らず#seccamp pic.twitter.com/jHVIqtlf0n
— PG_MANA (@PG_MANA_) August 14, 2024
勧進帳
これが「勧進帳」と言われてて笑う。 https://t.co/xoqTxiIKQR
— 近藤史恵 (@kondofumie) August 11, 2024