2025年6月4日水曜日

Google検索のAI表示を消したい

現時点(2025/06)では設定ではできなくなくなってしまった。

検索したあとに表示されるurlに「&udm=14」を追加するとAI表示はなくなる。

検索したときに表示されるタブが「すべて」になっているとAI表示も行われてしまうため、これを「ウェッブ」とすることで表示がされなくなる。

アドオンも「&udm=14」で検索すると色々出てくるが、このぐらいならアドオンによるリスクを負わなくてもいいような気もする。

 https://atmarkit.itmedia.co.jp/ait/articles/2411/15/news036.html

スクリプトのテキストファイル形式

ANSIかUTF-8(BOM付き)のどちらか。

Unix系のではテキストファイルはUTF-8(BOM付き)は正しく処理されない。

Visual Studio CodeではテキストファイルはUTF8NoBOMで保存される。Ascii文字以外の文字が含まれると文字がPowerShellは正しく処理されない。

結論として、 

PowerShellスクリプトでAscii文字以外を使用するには、UTF-8(BOM付き)にする必要がある。PowerShellスクリプトファイルはBOMがないファイルはANSIとして処理される。

 

https://learn.microsoft.com/ja-jp/powershell/module/microsoft.powershell.core/about/about_character_encoding?view=powershell-7.5

画面出力

Write-Host 非推奨

Write-Verbose ユーザー側でVerbose パラメーターで出力を指定できる。

Write-Output 出力される。 

https://learn.microsoft.com/ja-jp/powershell/utility-modules/psscriptanalyzer/rules/avoidusingwritehost?view=ps-modules

文字列の分割

構文

-split <String>
-split (<String[]>)
<String> -split <Delimiter>[,<Max-substrings>[,"<Options>"]]
<String> -split {<ScriptBlock>} [,<Max-substrings>]
Max-substrings

PowerShell 7以降:マイナス指定で末尾から数えて処理される。

 

https://learn.microsoft.com/ja-jp/powershell/module/microsoft.powershell.core/about/about_split?view=powershell-7.5

2022年10月30日日曜日

スコープ

 

関数呼び出し元の参照
(thisは省略可能)
戻り値用途
applythis呼び出し元のインスタンスプロパティ設定
alsoit呼び出し元のインスタンスプロパティ設定
letitラムダの結果メソッドの実行 nullチェック
runthisラムダの結果メソッドの実行
withthisラムダの結果メソッドの実行

[Kotlin]スコープ関数 apply,also,let,run,withの使い分け https://pouhon.net/kotlin-sfunction/1392/

2022年10月3日月曜日

プロパティーの初期化

初期化タイミングを変数を初めて使用する時に初期化する

lateinit、by lazy

プリミティブ型には使用できない。

varで宣言する必要がある。

必ずnon-nullとなる。

class MainActivity : AppCompatActivity() {

private lateinit var textView: TextView

override fun onCreate(saveInstanceState: Bundle?) {

super.onCreate(saveInstanceState)

textView = findViewById(R.id.text_view) // ここで初めて初期化される

}

// …

}

varで宣言するので、再代入には注意すること。

by lazy

型の制限はない。

valで宣言する必要がある。

nullable / nun-nullどちらでも可能

対象のプロパティが初めて呼び出されたときに初期化される。

初期化されたら必ず同じ値を返す。

class MainActivity : AppCompatActivity() {

private val userData: User? by lazy { fetchUserData() }

override fun onCreate(saveInstanceState: Bundle?) {

super.onCreate(saveInstanceState)

userData?.let { showUserData(it) } // ここで初めて初期化される

}

// …

}

ビューをlazyで初期化した場合、変更を加えても反映されない。

プロパティーにnullが入る可能性がある場合はlazyを使う必要がある。

by lazyは初期化処理を記述する必要があるので、記述上各メソッドの処理はスッキリさせることができる。


Qiita 【Android】lateinitとby lazyの使い分け【Kotlin】 https://qiita.com/u-dai/items/a31c5c2a7d5c7ed2cc47

2022年4月2日土曜日

motion いつの間にか落ちてる ffmpeg_put_frame: Error while writing video frame / event_ffmpeg_put: Error encoding image

トリガー条件不明。

motionはカメラから画像が指定したFPS以下の場合、不足したフレームを複製させてパディングするようなパラメータがあるが、実際のところ不足しているフレームは単純に抜け落ちるだけで保管もされない。

そのために落ちているのかもしれないが、よくわからない。

が、実際にこのエラーが表示されている状態でもファイル出力がされていたので、無視していいのかもしれない。

なお、部屋を暗くしたらこれが発生して落ちていた。

状況としては動作検知後、録画し始めて19時17分22秒あと、1分程度経ってからエラーが出始め、落ちていた。 

[1:ml1:F] [NTC] [EVT] [Apr 02 19:17:22] event_newfile: File of type 8 saved to: /tmp/motion/C270_2/20220402191722F-10.mp4
[1:ml1:F] [NTC] [ALL] [Apr 02 19:17:22] create_path: creating directory /tmp/motion/C270_2
[1:ml1:F] [NTC] [EVT] [Apr 02 19:17:22] event_create_extpipe: pipe: ffmpeg
[1:ml1:F] [NTC] [EVT] [Apr 02 19:17:22] event_create_extpipe: cnt->moviefps: 10
[1:ml1:F] [NTC] [EVT] [Apr 02 19:17:22] event_newfile: File of type 8 saved to: /tmp/motion/C270_2/20220402191722F-10
[1:ml1:F] [NTC] [ALL] [Apr 02 19:17:22] motion_detected: Motion detected - starting event 10
[1:ml1:F] [ERR] [ENC] [Apr 02 19:18:52] ffmpeg_put_frame: Error while writing video frame
[1:ml1:F] [ERR] [EVT] [Apr 02 19:18:52] event_ffmpeg_put: Error encoding image
[1:ml1:F] [ERR] [ENC] [Apr 02 19:18:52] ffmpeg_put_frame: Error while writing video frame
[1:ml1:F] [ERR] [EVT] [Apr 02 19:18:52] event_ffmpeg_put: Error encoding image
[1:ml1:F] [ERR] [ENC] [Apr 02 19:18:52] ffmpeg_put_frame: Error while writing video frame

[1:ml1:F] [ERR] [ENC] [Apr 02 19:20:02] ffmpeg_put_frame: Error while writing video frame
[1:ml1:F] [ERR] [EVT] [Apr 02 19:20:02] event_ffmpeg_put: Error encoding image
[1:ml1:F] [NTC] [ALL] [Apr 02 19:20:22] preview_save: different filename or picture only!

ログの抜粋はこんな感じ

作られたファイルとログは矛盾点はなかった。

もしかすると、pipeで渡しているフォーマットがまずいのかもしれないが、出力され始めるタイミングがずれているのと、フレームレートは10FPSと低めにしているのでそれなりなはずなのだが…