All posts by Kenji

FreeMind のファイル(.mm) を一括検索するツール


FreeMind の内部の文字を検索するツールを作りました。昔は ozFreeMindSearcher 0.9.0 RC3 というツールが公開されていたらしいのですが、今はダウンロードできないということで、作ってしまいました。職場で活用されています。

肝心のソースはgithubに上げております。

FreeMindSearcher

2012/05/06 時点での機能

指定されたディレクトリ以下にある、拡張子が”.mm”のファイルをすべて取得して、その中の単語を検索する→単語が見つかった場合、そのノードとファイル名、ディレクトリ名をDataGridView に出力する、といった単純なものです。

AND 検索 、OR 検索 はできません。

アプリケーションだけほしい人は、release フォルダの中の FreeMindSearcher.exe を持っていってください。 動かすには .Net Framework 2.0 が必要です。 32bit アプリケーション です。

やっていることの説明

FreeMind のファイルを見るとわかるのですが、形式は XML になっていて、それぞれのノードは node タグ になっています。そして、テキスト部分は TEXT 属性 なので、TEXT 属性 を検索するようにします。ただし、TEXT 属性の値は HTMLエンコード (漢字5文字ぐらいでなんか言い方があったはず) されていますので、検索前に検索文字列を HTMLエンコード しています。

Search ボタン をクリックすると、まず、検索する語句がHTMLエンコードされます。 次に、getMMFiles が指定ディレクトリ以下のマインドマップのファイルパスを再帰的に取得します。最後に searchFile がファイルの中を 検索して、ヒットしたものを DataGridView に出力します。searchFile は単一のファイルについての処理なので、一つ一つのファイルについて searchFile を実行しています。

処理部分のコード

Visual C++ 2005 で作りましたが、 Windows でしか使えないので少し後悔しています。

きれいじゃないのは本人が一番よく分かっています。

DataGridView に表示するところは、HTMLのデコードをしなくても表示されました。自動でデコードされるんでしょうか。 DataGridView の各種プロパティなどは結構手を抜いています。


000webhost : prevent inserting no use additional backslash


At 000webhost, backslash is inserted where it should not be, when you insert data to database with php.

You can prevent it by adding some setting.

make magic_quotes_gpc off when you make a file “.htaccess” in the directory where you want to do it and write

You can check magic_quotes_gpc in php code by executing get_magic_quotes_gpc


Fixing the default of the .Net Label’s AutoSize property


This is a story about creating form applications using Visual Basic and Visual C#.

Have you ever wished that the default for the AutoSize property of labels was False? While there might be cases where you create them with AutoSize = True, in my company, we use AutoSize = False. However, it’s cumbersome to set the property every time you paste a label. So, the idea behind this code is to create labels with the AutoSize default value set to False. This has been confirmed using Visual Studio 2010 and Visual Basic.

In Visual Studio Professional Edition, you can create inherited controls. In the Express Edition, you couldn’t create inherited controls from the start, as far as I recall. In that case, you first create an inherited class.

The class to inherit is System.Windows.Forms.Label. A common approach here is to use the property window of the control’s designer screen to set AutoSize to False (though nothing appears in the designer screen, the property window is usable). However, for the Label control, things get tricky, as it reverts to AutoSize = True when actually pasted onto a form. To tackle this, display the code and add the following snippet.

Continue reading Fixing the default of the .Net Label’s AutoSize property

How to Convert Numeric Dates to Date Format in Crystal Reports


This is a guide on how to convert numeric date values to a year-month-day format in CrypstalReports. This code is useful when you have date data stored as 8-digit numeric values representing the year, month, and day.

First, create a formula field. Within it, write the following expression. To edit the expression, right-click and select “Edit Formula.”

With this, you can convert the numeric value to a date. Replace {DBColumn} with the name of your database field.

However, this will still display in the format 1986/01/06. To change the date format, you’ll need to set the properties of this formula field.

For DateFirstSeparator, DateSecondSeparator, and DateSuffixSeparator, input “年” (for year), “月” (for month), and “日” (for day), respectively. This will display the date as 1986年01月06日.