[設定] > [一般] >[転送または iPhone をリセット] > [リセット] > [キーボードの変換学習をリセット]

ずいぶん怖いところにありますね。
[設定] > [一般] >[転送または iPhone をリセット] > [リセット] > [キーボードの変換学習をリセット]

ずいぶん怖いところにありますね。
自作のアプリに不具合があったという話です。
GitHub にコードおいて作っているこのアプリです。作っている、というよりずいぶん前に軽く書いてずっと使っていた簡易スクリプトめいたプログラムです。
画像にグレーの枠を付けます。それだけです。
白い背景の画面をスクリーンショット取って、白い背景のブログページに載せると、画像の境界が見えずわかりにくい記事になることの対策アプリです。
画像自体に枠を付けてしまえばどこに行っても見やすいです。動画に文字入れするときに映像に埋もれないように縁取りをした文字を入れるのと同じです。
プログラムが出力した画像が、サムネイルが正方形になります。また、フォトで開いた際にも一度正方形に表示された後、正しい画角の表示になる。
そんなことが起きていました。

ファイル事態とファイル名の拡張子が崩れていました。
前述例の画像は、 .bmp ファイルを読み込んで拡張子が .bmp の画像ファイルを作成していたのですが、
ファイルの中身は .png でした。
ファイルと拡張子がずれていても動いてくれるんものなんですね。画像ふぁいるというのは。
こんなコードでした。
var name = args.FirstOrDefault() ?? string.Empty; if (string.IsNullOrWhiteSpace(name)) return; if (System.IO.Directory.Exists(name)) foreach (var file in System.IO.Directory.GetFiles(name)) B(file); if (System.IO.File.Exists(name)) B(name); static void B(string name) { var extension = System.IO.Path.GetExtension(name); if (!new[] { ".jpg", ".bmp", ".png" }.Contains(extension)) return; var nameWithoutExtension = System.IO.Path.GetFileNameWithoutExtension(name); var directoryName = System.IO.Path.GetDirectoryName(name); var fileName = System.IO.Path.Combine(directoryName, $"_2_{nameWithoutExtension}{extension}"); if (System.IO.File.Exists(fileName)) return; using var img = System.Drawing.Image.FromFile(name); using var bmp = new System.Drawing.Bitmap(img.Width + 2, img.Height + 2); bmp.SetResolution(img.HorizontalResolution, img.VerticalResolution); ; using var g = System.Drawing.Graphics.FromImage(bmp); g.FillRectangle(new System.Drawing.SolidBrush(System.Drawing.Color.FromArgb(255, 127, 127, 127)), 0, 0, bmp.Width, bmp.Height); g.DrawImage(img, 1, 1, img.Width, img.Height); bmp.Save(fileName); }
ここがダメです。ここで、出力画像ファイルの指定をしないと、出力は常に .png ファイルになるとのことです。にも書かかわらずファイル名は指定した fileName。拡張子も含めて。
bmp.Save(fileName);
例えば、.bmp ファイルを読み込んだ場合、読み込んだファイルのファイル名を元に出力ファイルを作るので、拡張子 .bmp で出力していました。しかし中身は .png ファイルという状態。
ずっと .png ファイルでばかり作業していたからです。最近 .bmp や .jpg を扱うようになり要約気が付きました。
var name = args.FirstOrDefault() ?? string.Empty; if (string.IsNullOrWhiteSpace(name)) return; if (System.IO.Directory.Exists(name)) foreach (var file in System.IO.Directory.GetFiles(name)) B(file); if (System.IO.File.Exists(name)) B(name); static void B(string name) { var extension = System.IO.Path.GetExtension(name); if (!new[] { ".jpg", ".bmp", ".png" }.Contains(extension)) return; var nameWithoutExtension = System.IO.Path.GetFileNameWithoutExtension(name); var directoryName = System.IO.Path.GetDirectoryName(name); var fileName = System.IO.Path.Combine(directoryName, $"_2_{nameWithoutExtension}{extension}"); if (System.IO.File.Exists(fileName)) return; using var img = System.Drawing.Image.FromFile(name); using var bmp = new System.Drawing.Bitmap(img.Width + 2, img.Height + 2); bmp.SetResolution(img.HorizontalResolution, img.VerticalResolution); ; using var g = System.Drawing.Graphics.FromImage(bmp); g.FillRectangle(new System.Drawing.SolidBrush(System.Drawing.Color.FromArgb(255, 127, 127, 127)), 0, 0, bmp.Width, bmp.Height); g.DrawImage(img, 1, 1, img.Width, img.Height); bmp.Save(fileName, extension switch { ".jpg" => System.Drawing.Imaging.ImageFormat.Jpeg, ".bmp" => System.Drawing.Imaging.ImageFormat.Bmp, ".png" => System.Drawing.Imaging.ImageFormat.Png, _ => throw new NotImplementedException() } ); }
bmp.Save(fileName,
extension switch
{
".jpg" => System.Drawing.Imaging.ImageFormat.Jpeg,
".bmp" => System.Drawing.Imaging.ImageFormat.Bmp,
".png" => System.Drawing.Imaging.ImageFormat.Png,
_ => throw new NotImplementedException()
}
);
正しいファイルを出力するようになりました。

はてなブログの記事を pptx にする方法をいろいろ模索しています。
rksoftware.hatenablog.com rksoftware.hatenablog.com
ブログ記事を Markdown。
Markdown を Marp で pptx にする。
そもそもブログ記事を Markdown で書いていたので、実は Markdown 化する必要なかった。
など。
そんないろいろと試してきましたが、結論です。
ブログ記事内のセクションを、コピーして......


pptx ファイルに貼り付け!

あとは手で調整。これが一番早いです。
出来上がったものは素晴らしいですが、時間がかかりすぎます。
ここまで時間がかかるなら、手で貼り付けるという選択肢もありです。 どうせ、見た目等手でいじることを考えたら、最初から全部手でやるのもありです。
これも素晴らしいものができます。しかし出来上がったファイルは、文字も含めすべてが画像になっていて、その画像が背景になっているだけのスライドです。


出した pptx は素晴らしいですがそのまま使えるはずはなく、手で一切編集できないのであれば選択肢になりませんでした。無念。
ブログ記事内のセクションを、コピーして pptx に貼り付けて手で編集する。
早さだけでなく、作りたい pptx ファイルを作れるという点でこれが結論になりました。
iPhone の集中モードが勝手に ON になったり OFF になったりする問題に悩まされていました。
iPhone の集中モードの設定で「デバイス間で共有」を OFF にします。

iPhone の受ける通知は通常はまあ、全部受けておくのが良いです。
しかしその通知の大半はアプリで、別のスマートフォンでも同様の通知を受けるものです。
そして、複数所有しているスマートフォンのうちのどれを持ち歩いているかはその日次第です。
持ち歩いていないスマートフォンで通知を受けていると、自身がいない場で通知がなりつつけることになります。 本人不在の場でなり続ける通知はその場の人に与えるストレスはかなりのものです。
しかし、すべての通知を OFF にするのも良くない。アプリ通話など、緊急性のあるものは通知されるようにしておきたい。
機内モードなどではこの課題を解決できません。
そこで集中モードなのです。
iPhone の集中モードが勝手に ON になったり OFF になったりする問題に悩まされていました。
ある時実験すると、iPhone A で集中モードにすると、iPhone B も集中モードになり、iPhone B で集中モードを解除すると、iPhone A でも集中モードが解除される挙動が確認できました。
驚くべきことに、複数の iPhone で集中モードの ON / OFF が同期するという信じられない挙動が確認されました。
だえがうれしい機能なのか、想像することが全くできませんが、実際そのように動作していました。
冒頭に書いているとおりです。
iPhone は使うのが非常に難しい機械で、何をするにも難しいです。しかし便利な道具でもあることも確かです。使いこなしていきましょう。
ブログ記事を半自動で素早く pptx にする試みを続けています。
前回、プレーンな pptx にするところまでできたので、自分ブランドのスライドの色やフォントで pptx を作る試みを始めました。

完全に壊れましたが、色など、自分ブランドの雰囲気は出ました。
今後、このまま進めていこうと思います。
自分の既存のスライドを画像で GitHub Copilot に貼り付け。
Marp 用の CSS にしてと依頼。
生まれた css を 現行の Markdown に組み込みを依頼。
たったこれだけです。これだけでここまで近づきました。
こんな感じになっています。ここからは人の出番だと思うので、ちゃんと把握しながら作っていこうと思います。
---
marp: true
paginate: true
---
<style>
@charset "UTF-8";
:root {
--cover-blue: #0d76bf;
--cover-text: #ffffff;
--cover-line: rgba(255, 255, 255, 0.9);
}
section {
font-family: "Yu Gothic", "Hiragino Sans", "Meiryo", sans-serif;
}
section:first-of-type {
background: var(--cover-blue);
color: var(--cover-text);
padding: 5.2rem 5.6rem 4.2rem;
display: flex;
flex-direction: column;
justify-content: center;
align-items: flex-start;
}
section:first-of-type h1 {
margin: 0;
max-width: 12ch;
font-size: 4.45rem;
line-height: 1.05;
font-weight: 300;
letter-spacing: 0.01em;
}
section:first-of-type h1::after {
content: "";
display: block;
width: min(100%, 15.8em);
height: 1px;
margin-top: 1.35rem;
background: var(--cover-line);
}
section:first-of-type p {
margin: 1.4rem 0 0;
font-size: 1.7rem;
line-height: 1.25;
letter-spacing: 0.02em;
}
section:first-of-type p strong {
font-weight: 700;
}
section:first-of-type::after {
display: none;
}
section:has(> h1):not(:first-of-type):not(:has(> :is(p, ul, ol, pre, blockquote, table, figure, img))) {
background: var(--cover-blue);
color: var(--cover-text);
padding: 5.2rem 5.6rem 4.2rem;
display: flex;
flex-direction: column;
justify-content: center;
align-items: flex-start;
}
section:has(> h1):not(:first-of-type):not(:has(> :is(p, ul, ol, pre, blockquote, table, figure, img))) h1 {
margin: 0;
max-width: 16ch;
font-size: 3.2rem;
line-height: 1.16;
font-weight: 300;
letter-spacing: 0.01em;
}
section:has(> h1):not(:first-of-type):not(:has(> :is(p, ul, ol, pre, blockquote, table, figure, img))) h1::after {
content: "";
display: block;
width: min(100%, 15.8em);
height: 1px;
margin-top: 1.25rem;
background: var(--cover-line);
}
section:not(:first-of-type) {
background: #ffffff;
color: #444444;
padding: 3.8rem 4.2rem 3rem;
display: flex;
flex-direction: column;
font-family: "Yu Gothic", "Hiragino Sans", "Meiryo", sans-serif;
}
section:not(:first-of-type):has(> h1):has(> :is(p, ul, ol, pre, blockquote, table, figure, img)) h1 {
margin: 0;
color: #0d76bf;
font-size: 2.7rem;
line-height: 1.15;
font-weight: 300;
letter-spacing: 0.01em;
}
section:not(:first-of-type):has(> h1):has(> :is(p, ul, ol, pre, blockquote, table, figure, img)) h1::after {
content: "";
display: block;
width: 100%;
height: 1px;
margin-top: 0.45rem;
background: rgba(0, 0, 0, 0.28);
}
section:not(:first-of-type) > :is(p, ul, ol, pre, blockquote, table, figure) {
background: #d9d9d9;
margin: 1.35rem 0 0;
padding: 0.9rem 1.1rem;
box-sizing: border-box;
}
section:not(:first-of-type) > :is(ul, ol) {
padding-left: 3rem;
padding-top: 1rem;
padding-bottom: 1rem;
margin-left: 0;
}
section:not(:first-of-type) > ul {
list-style: disc;
list-style-position: outside;
}
section:not(:first-of-type) > ul li::marker,
section:not(:first-of-type) > ol li::marker {
color: #1ea1dc;
}
section:not(:first-of-type) > :is(p, ul, ol, pre, blockquote, table, figure):first-of-type {
margin-top: 1.7rem;
}
section:not(:first-of-type) strong {
font-weight: 700;
}
section:not(:first-of-type) em {
font-style: normal;
color: #d60000;
font-weight: 700;
}
section:not(:first-of-type) img {
display: block;
max-width: 100%;
height: auto;
background: transparent;
padding: 0;
margin: 0;
}
</style>
# ポスト AI Credits 時代の救世主? BYOK で C# コードを書いてみる
時は GitHub Copilot の AI Credits 時代。誰もが AI Credits を節約したいと、日々過酷な修行を行っていました。
---
# ■ Visual Studio Code の BYOK とは
これまで、ブログ記事を pptx にする ~それも高速に~できるだけ手をかけず~ ことを模索してきました。
rksoftware.hatenablog.com
rksoftware.hatenablog.com
rksoftware.hatenablog.com
ある程度光明も見えていましたが、一つ重大なことを忘れていました。
実は、はてなブログの記事を別で使える Markdown にするために書いた C#/.NET アプリがありました。
github.com
これは、はてなブログの記事を Markdown で書いている場合の、記事ソースの Markdown 内の画像のタグを、http~に書き換えるアプリでした。
つまりこのアプリを使えば、Marp にインプットできる Markdown が得られます.Pandoc 要らなかった。
記事のソースの Markdown をローカルファイルに保存。
記事の編集画面を Ctrl+A ⇒ Ctrl+C ⇒ Ctrl+V で。
そしてアプリ実行。引数はローカルファイルに保存したファイルです。

#### Azure で「リソースの追加」 [f:id:rksoftware:20260705122625p:plain]

#### Azure で「リソースの追加」 
計画通り! 変換できています。
画像がきちんと表示されています。
いいね!
さて、Markdown を Marp に入れるためには、ページ区切りを手動で入れて小おかなければなりません。
そんな時は惜しみなく GitHub Copilot です。
この Markdown を Marp で pptx にしたいです。ページ区切りを入れてください

計画通り! 区切り線が入りました。
Marp で Markdown を pptx にします。詳細は、この記事トップのリンクから参照してください。

見事、ちゃんと pptx になりました。

あとは、pptx のテーマ的な css を作れば完璧ですね。 10秒程度で、ブログ記事を pptx にできるようになりました。
C# は # のコードを書いた .cs ファイルをそのまま dotnet コマンドで実行できます。
通常はビルドしたバイナリを実行すればよいのですが、exe ファイルをいろいろなところに置くのも少し違和感もあり、.cs ファイルをリポジトリに入れて、クローンするとプロジェクト内の提携処理を行う .cs ファイルも入ってて使えるというのはシンプルでわかりやすいです。

これまではちょっとしたことは GitHub Copilot でやらせていたのですが、これからはちょっとしたことはちょっとしたスクリプトを描いておいて繰り返し使う時代という気もします。
試しにしばらく使ってみたいと思います。