Lazy Diary @ Hatena Blog

PowerShell / Java / miscellaneous things about software development, Tips & Gochas. CC BY-SA 4.0/Apache License 2.0

Entries from 2021-09-01 to 1 month

CyberChefではANSIエスケープシーケンスの削除はできない

Eclipseのコンソールの内容をクリップボードにコピーしようとした際、ANSIエスケープシーケンスが付いてくることがある*1。テキストエディタなどでは^[[2mのようにに表示される(最初の^[ はASCIIのESC)。ANSIエスケープシーケンスについてはTeraTermのペー…

バイナリファイルをアップロードするときのエンコーディング

Q: ブラウザからバイナリファイルをPOSTリクエストでアップロードするとき、HTTPリクエストボディ上ではどういう見た目になるんだっけ? URLエンコードされる?Base64になる? A: バイナリがそのまま渡される。ChromeのAdvanced REST Clientで確認。こんな感…

Spring Frameworkのmax-file-sizeによるアップロードファイルサイズ制限のまとめ

satob.hatenablog.com application.propertiesにspring.servlet.multipart.max-file-size=100のように設定することでサイズ制限設定可能。 Spring Frameworkのファイルアップロード機能は、Webコンテナが持っているmultipartリクエストの処理機能をそのまま…

Spring Frameworkのアップロードファイルサイズ制限のテスト

spring.servlet.multipart.max-file-size=100を設定した状態で、以下のようなControllerに様々なmultipart/form-dataリクエストを送信して結果を比較した。 @PostMapping("/upload") public String handleFileUpload(@RequestParam("file") MultipartFile fi…

Validate memory consumption in a JUnit test case

For load test If you want to run a load test in a JUnit test case and get maximum memory consumption or GC count as a Java variable, the way to do it doesn't seem to be. For memory consumption of whole Java VM If you want to run some tests…

文化的まちがいさがし - 上棟式の餅まき有無

(A) 上棟式(建前)のときに餅まきをする。 (B) 上棟式(建前)のときに餅まきをしない。 有無には地域差が確実にあるはずで、国交省から新設住宅着工戸数も数値が出てるからどこかで集計とかしてないかな……と思ったんだけど、そもそも国交省のデータは県ご…

テストデータに使う電話番号の作りかたの案

ダメだぞ、03-1100-xxxx とか 03-1199-xxxx みたいな番号を例に使ったら。 https://t.co/BEAaGJatJZ— AoiMoe a.k.aしお兄P (@AoiMoe) 2021年9月23日 example.com のような例示用番号というのが明確には存在しないようなので。テストエース*1とかどうしてるん…

マークアップ言語に対する静的解析

JSPやXMLなどのマークアップ言語に対して、たとえば JSPで<form:password>タグのshowPassword属性はtrueにしたらダメ JETTでxlsxファイルに<jt:comment>タグは使ったらダメ Apache FOPで<fo:external-graphic>タグのsrc属性に#や%や空白が入っていたらダメ myBatisのMapper XMLでLEFT OUTER JOINのOUTERを省略</fo:external-graphic></jt:comment></form:password>…

textlintとRedpenの比較

Googleで検索すると"redpen vs textlint"とかが検索候補に挙がるのだけれど、詳細な比較は以下くらいしか見あたらなかった。 A comparison of open-source linters · GitHub インターネットへのアクセスにある程度制限がかかっている環境下で英語論文を書く…

英日翻訳時に技術用語をどうするか

IT用語の中でどうにかできないかと思っているものがたくさんある。例えば「アタッチ」とか「フェッチ」とか。これらの言葉、いきなり言われても何のことかさっぱりわからないよ。こういう用語は最初に日本に導入した人は適切に和訳して使ってもらいたかった…

Record the mouse position and the top window title to Windows Event Log

Requirement Record the user activity to Windows Event Logs. The mouse position*1 and top window title *2 are used to indicate the activity. Solution Run the following PowerShell script every 5 minutes from the Task Scheduler. Add-Type -Ass…

Record a Windows Event Log with a custom application/source and appropriate message

Requirement You want to record an event on Windows Event Log. The log should be recorded with a custom application and source. The message of the event should be recorded appropriately. The message should not contain the warning like The d…

You cannot show fullscreen message and log-off after a time-out with shutdown.exe

Background You can log off from Windows with shutdown.exe. Requirement You want to log off from Windows at the specified time. It should not be shut down after the log-off. You want to show a fullscreen message 5 minutes before the log-off…

Windows Event Viewer Category Correspondence Table

I couldn't find the correspondence table between the value of the -Category argument (Int16) of Write-EventLog cmdlet and the category shown in Event Viewer from Microsoft. I have run this command and viewed the result in the Event Viewer …