ゆう's Blog
viewBox

「viewBoxの後ろ2つは座標じゃなくて幅と高さ」

viewBox="min-x min-y width height"

一般的には body に id を振らない

JavaScript から body 要素を取得する専用の方法があるためです。

document.body

例えば背景色を変えるなら、

document.body.style.backgroundColor = 'black';

ページ内リンク

リンク元:<a href="#target">…</a> リンク先:<div id="target">…</div>

ページトップへ

<html id="top"> <a href="#top">ページトップへ</a>

CSSの優先順位

同じ要素で、同じプロパティで、同じ詳細度なら後勝ち。

CSSは単純に「下に書いた方が勝つ」ではなく、
① 要素自身に指定がある?
↓
② その指定同士で詳細度を比較
↓
③ 同じ強さ(詳細度)なら下が勝つ
↓
④ 指定がなければ親から継承
の順に考えます。

CentOS Stream 10 : Node.js + opentype.js( text→path )

① Node.js をインストール

sudo dnf install nodejs

バージョン確認

node -v npm -v

② opentype.js の導入(npm)

Web サーバーの任意のディレクトリで:

npm init -y npm install opentype.js

関数から複数の値を return する

オブジェクトで返す

function calc(a, b) { return { sum: a + b, diff: a - b }; } const result = calc(10, 3); console.log(result.sum); // 13 console.log(result.diff); // 7

function calc(a, b) { const sum = a + b; const diff = a - b; return { sum, diff }; }

これは return { sum: sum, diff: diff } の省略記法です。
オブジェクトのキー名と変数名が同じなら短く書ける。

文字列のバイト数を調べる

UTF‑8 のバイト数を調べる

function byteLength(str) { return new TextEncoder().encode(str).length; } console.log(byteLength("あ")); // 3 console.log(byteLength("A")); // 1 console.log(byteLength("😊")); // 4

特定の文字列が含まれているか

const text = "Hello World"; console.log(text.includes("World")); // true console.log(text.includes("world")); // false(大文字小文字は区別される)

Cockpit を使わないなら

1. firewalld で 9090 を閉じる

~]# firewall-cmd --permanent --remove-service=cockpit ~]# firewall-cmd --reload

2. Cockpit を完全に無効化する

~]# systemctl disable --now cockpit.socket

もし Cockpit を使いたくなる場面が将来出たら
9090 を閉じたまま SSH トンネル経由でのみアクセスが最も安全。

~]$ ssh -L 9090:localhost:9090 user@server

一文字アイコン用

<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 200 200"> <rect x="5" y="5" rx="15%" ry="15%" width="190" height="190" stroke="black" stroke-width="10" fill="green"/> <text x="50%" y="50%" text-anchor="middle" dominant-baseline="middle" dy="15" font-size="150" fill="white"> A </text> </svg>

A