Lazy Diary @ Hatena Blog

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

Entries from 2019-01-01 to 1 year

Amazon Kindle Paperwhiteが4G回線で見られるのはWikipediaだけ

Amazon Kindle Paperwhite (4th Gen)は 内蔵のブラウザでWebサイトが(いちおう)見られる 4Gモデルの通信料はAmazon持ち と聞いていたので、「TwitterとかをKindleで見るようにすれば通信料が節約できるかも!」と思ったのですが、そうではありませんでした…

Use Enum defined in classes from PowerShell

If you have an enum like this: namespace Foo { public class Bar { public enum Baz { A = 0, B = 1, C = 2 } } } You can use this enum from PowerShell with [FQCN+Enum] notation like this: Add-Type @" namespace Foo { public class Bar { public …

Change culture (locale) of current PowerShell process

You can change culture (locale) into English with chcp 437 in Windows 7. In contrast, You cannot change culture with chcp in Windows 10. In Windows 10, if you want to execute single PowerShell script in another culture, you can execute the…

Import assemblies for C# embedded in PowerShell

You can import assemblies (.NET DLLs) in PowerShell like this: [void][reflection.assembly]::LoadWithPartialName("System.Drawing") New-Object System.Drawing.Drawing2D.GraphicsPath But you will get an error when you tring to use these assemb…

mvn command results in error in Windows

You will get error when you run following Maven command from Windows PowerShell: PS C:\workspace> mvn -B archetype:generate -DgroupId=com.example -DartifactId=hajiboot -Dversion=1.0.0-SNAPSHOT -DarchetypeArtifactId=maven-archetype-quicksta…

「大規模システム」の指す範囲

「100万行オーバーのモノリシックRailsアプリをマイクロサービス化したクックパッドの手順」*1では、100万行弱のコード(うちテストコードが約51万行、実行環境で動作していたのは約41万行)をもって「世界一のモノリシック」「巨大すぎる」と形容している。…

Difference of Invoke-Expression and '&' in PowerShell

# Command Result 1 Invoke-Expression 'Get-Process' OK 2 & 'Get-Process' OK 3 Invoke-Expression 'Get-Process explorer' OK 4 & 'Get-Process explorer' NG #4 causes the following error: & : 用語 'Get-Process explorer' は、コマンドレット、関数…

新幹線の「〇〇新聞ニュース」

新幹線のドアの下に流れてる「〇〇新聞ニュース」が、同じ内容を2度流すのは、 (A) 一度目に流れていた内容を途中から読んだ人でも、そのまま見続けていれば読めなかった内容が読めるから。 (B) 文字の流れが速すぎて、一度では読めないから。 (A)とばかり思…

普段着と寝間着の出番

- (A) (B) (C) かしこまった席で着る服 よそいき よそいき よそいき 学校などの日常的な場で着る服 普段着 普段着 普段着 外出しない日中に着る服 普段着 寝間着 部屋着 寝るときに着る服 寝間着 寝間着 寝間着 この「部屋着」という文化がいつ、どこから来…

rsyncでページキャッシュを汚さない方法

rsyncは大量のファイルを走査するため、普通に実行するとページキャッシュに乗ったファイルが追い出されてしまう。 Linuxの場合、nocacheコマンド*1を利用することでページキャッシュを汚さずにrsyncを実行できる。リモートでもrsyncが実行されるので、以下…

康煕字典体から常用漢字へ変換するコマンドレット

変換対照の文字は、文化庁 常用漢字表*1で康煕字典体が示されているものを対照とした。常用漢字表のPDFの内容をテキストファイルへダンプし、以下のスクリプトで常用漢字とカッコ書きの康煕字典体とのペアを抽出した*2。 > Get-Content .\常用漢字表.txt | W…

ソフトウェア考古学論考 (2)

どっちかもいうとこっちが本題。 さて、ソフトウェア考古学の目的としては、 レガシーシステムの保守開発の効率化 システムの仕様理解の補助 の他にも、poorly-documentedなレガシーシステムのソースコードから、その仕様(あるいは意図)を読み解き復元し、…

ソフトウェア考古学論考 (1)

ソフトウェア考古学(Software Archaeology)という考え方は、OOPSLA 2001で提唱されたのが始まりのようです *1。 Wikipediaにある通り *2 、poorly-documentedなレガシーシステムのソースコードやドキュメントをどう読み解くか?というところから始まったよ…

How to separate a string into codepoint-wise characters with PowerShell

Context: You have a Unicode string that contain non-ASCII characters as well as ASCII characters. You want to separate that string into characters. Problem: If you split the string with the code below: $TemporaryArray = $InputString -split…

Difference of behavior of String#split() in Java and -split operator in PowerShell

Both of String#split() in Java and -split operator in PowerShell take regex as argument, and split string into a list or an array, but there is some difference in behavior when you pass an empty string as argument. In Java: System.out.prin…

労働と挨拶のどちらが大切か

(A) 挨拶より労働の方が大切。 (B) 挨拶と労働が同じくらい大切。 (C) 労働より挨拶よ方が大切。 中井久夫「治療文化論」p.104より引用。 東京においては「あいさつ」のできることが、「はたらくこと」と並んでかなり重要であり、名古屋においては「あいさつ…

How to extract non-MS932 (Shift_JIS) compliant characters from string

function Get-NonMS932CompliantCharacter { Param( [Parameter(ValueFromPipeline=$true,Mandatory=$true)] [string] $TargetString ) process { $TargetStringBytes = [Text.Encoding]::UTF32.GetBytes($TargetString); for ($i=0; $i -lt $TargetStringBy…

tr equivalent in PowerShell (Unicode surrogate pair-aware)

There is no straightforward tr equivalent in Windows, so I made an cmdlet that you can use like tr command. This tr cmdlet is aware of Unicode characters including surrogate pairs. function tr { Param( [Parameter(ValueFromPipeline=$true,Ma…

EC-Council ECH (Certified Ethical Hacker)合格後のECEクレジットにカウントできたイベント

CEH

EC-Council CEH (Certified Ethical Hacker)試験に合格すると*1、以下のようなイベントが待っています。 ECE Membership Fee ($80/year)の支払い(1年間の猶予あり) ECEクレジットの登録(120ポイント/3年) ECEクレジットというのは、CISSPのCPEクレジット…

Bad designs in EC-Council ASPEN

CEH

Some of EC-Council ASPEN page designs are very annoying... "Reset Password" screen Detail: The instruction says: "Password length should be 8-20, should consist a lower case letter(a-z), an uppercase letter(A-Z), a number(0-9) and a specia…

java.text.BreakIteratorによる文字数(grapheme)カウント

JIS X 0213など、シフトJISやマイクロソフト コードページ932以外の文字をプログラム上で紙に印刷する場合には、入力された文字列を枠内に確実に収めるため、文字数を正しくカウントする必要があります。 JIS X 0213では複数のコードポイントで1文字を表す文…

学校で習う漢字の書き順はどう決まったのか

私の母は「自分(母)が学校で習った内容とは、漢字の書き順からして違ってたから、変なこと教えちゃいけないと思って」私に勉強を教えることはなかった。じゃぁ学校で習う漢字の書き順はどう決まったのか?という話。 学校で習う漢字の書き順は、文部省「筆…

「おサイダー」の話

「日本人の知らない日本語」に、外来語の名詞で頭に「お」がついて丁寧語になるもの……と聞かれて「おビール」と答えるくだりがあった。「おビール」は水商売でよく使う言葉だからやめなさい……みたいな話だったと記憶している。妻に同じ質問をしてみて、帰っ…

カール・ワイクとトム・ケリーの「ヴュジャデ」

ジェームズ・R・チャイルズ「最悪の事故が起こるまで人は何をしていたのか」には、カール・ワイクが提示した「ヴュジャデ」という語が出てくる。体感すると「巨大で意味のない恐怖におそわれる」らしい。 調べたところ、Karl E. Weick,“The Collapse of Sens…

robocopy finished with no error, with erroneous result on OneDrive for Business

Background: You are using OneDrive for Bueiness. You are trying to copy files to OneDrive with robocopy. Problem: robocopy had finished with no error (with ERRORLEVEL 0), but the the size of the files on OneDrive is 0byte. Cause: It seems …

Linux system clock does not sync to hardware clock on Hyper-V

Background: You are running Linux on Hyper-V guest VM. Your host machine has scheduled downtime (i.e. is not 24/7 system). Problem: When you booted up the host machine, the system clock of guest VM (Linux) will be set to the time you had s…

howmメモのタイムスタンプを補正する

リモートのサーバ等からタイムスタンプを保存せずに持ってきてしまったhowmメモファイルのタイムスタンプを、ファイル名に合わせて修正する。ファイル名は「./2019/12/2019-12-31-235959.txt」形式を想定。 $ for i in `find . -name "*.txt"`; do yyyy=$(ec…

There is no way to show SSL certificate in Safari on iOS

Problem: There is no way to show SSL certificate in Safari on iOS. Reason: It seems to be by design. Solution: Use Chrome for iOS. Note: You can view SSL certificate on https://www.digicert.com/help or other SSL diagnostics services, only …

「クラウド」と「情報流出」の区別がつかない人

「クラウド」と「情報流出」ってどう違うの? どちらも、自分だけしか持ってちゃいけない情報が、誰かのところに行っちゃってるじゃない。 みたいな話をされたわけですよ。 この発言をした人は、スタンドアロンで動くアプリケーションと、ネットワーク上で動…

夢占い募集

今からそう遠くない未来。人気YouTuberが、高速走行する自動車の後部座席から車内の様子をリアルタイム配信している。視聴者数も増えてきたまさにその瞬間、運転席にいた男の頭が弾け、そのまま車はクラッシュ!車は大破、同乗者は全員死亡した。 車がクラッ…