bar_1

contents_map

2014年5月28日水曜日

voidptrjp.blogspot.jp コンテンツ・マップ

ここに、当ブログのとくにめぼしいコンテンツについて、まとめて記述して行こうと思います。

Markdown Here (MDH) 2.11.0 に更新した時の注意点

Firefox のアドオン Markdown Here 2.11.0 へのバージョンアップでの注意点。リッチテキストエディタを使って Markdown でブログなどの記述している方向け。

2014年5月26日月曜日

というわけで voidptrjp.blogspot.jp での投稿を始めてみます

しばらくためして、Seesaa.net より blogspot.jp (Blogger.com) のほうが良さ気なら移行してしまおうかと思います。
が。
現時点で気づいた点。Blogger は Google にインデックス化されるのが遅くないか?
http://voitptr.seesaa.net/ では、投稿した途端に検索できるようになってました。遅くとも2,3時間経てばほぼ確実に。

2014年5月19日月曜日

brew のバージョンに関する部分のソースを読んでみた

前回の記事 を書くにあたって CLT のバージョンの調べ方について調査し、パッケージ管理ツールのひとつである Homebrew による CLT バージョンの取得方法について、github のソースを探索したときのログです。
String#[/re/], extend を使ったモジュールのメソッド定義、定数のエイリアスといった、ちょっとおもしろい記述方法を見つけました。

2014年5月18日日曜日

Mac にインストールされている Command Line Tools (CLT) のバージョンを調べるには


Mac にインストールされている Command Line Tools (Command Line Developer Tools; CLT) のバージョンを調べるにはどうしたらいいだろうか?


  • pkgutil を使う方法

  • brew を使う方法

の 2 つの方法についてここでは説明しよう。




pkgutil を使う方法


パッケージ ID を指定して、pkgutil コマンドを実行する:

$ pkgutil --pkg-info=com.apple.pkg.CLTools_Executables
package-id: com.apple.pkg.CLTools_Executables
version: 5.1.0.0.1.1396320587
volume: /
location: /
install-time: 1399979620
groups: com.apple.FindSystemFiles.pkg-group com.apple.DevToolsBoth.pkg-
group com.apple.DevToolsNonRelocatableShared.pkg-group

ちなみに、バージョンの末尾の 1396320587 という値は、

$ ruby -e 'p Time.at(1396320587)'
2014-04-01 11:49:47 +0900

というふうに、日付と時刻を意味する。

詳細を知りたい場合は、pkgutil(1) (すなわち man -S 1 pkgutil を実行) を読んでみるといい。

brew を使う方法


brew --config でもいい。CLT 以外の情報を調べるのにも使える。

$ brew --config
HOMEBREW_VERSION: 0.9.5
ORIGIN: https://github.com/Homebrew/homebrew.git
HEAD: 14c59f40e95f1766f7d067287e821bd66112911e
HOMEBREW_PREFIX: /usr/local
HOMEBREW_CELLAR: /usr/local/Cellar
CPU: dual-core 64-bit penryn
OS X: 10.9.2-x86_64
Xcode: 5.0.2
CLT: 5.1.0.0.1.1396320587
GCC-4.2: build 5666
Clang: 5.0 build 500
X11: 2.7.5 => /opt/X11
System Ruby: 1.8.7-358
Perl: /usr/bin/perl
Python: /usr/bin/python
Ruby: /Users/honyarara/.rbenv/shims/ruby

内部では pkgutil を実行しています。

最新の CLT を使っているにもかかわらず、brew のワーニング “A newer Command Line Tools release is available” が出たときはどうするか? → brew update を何回か実行すればいい。


2014年5月17日土曜日

作図エディタDiaの環境構築(2014年更新版)

以前 Dia について書いた記事を更新しようとしたところ、Markdown Here で書いたあとに保存すると、なぜか br タグがつきまくって、レイアウトがめちゃくちゃになってしまいます。
仕方なく、新記事としました。サイトURLの変更とバージョンが上がっている点に関しては、修正しています。
TeX で図を描きたいときにどうしようかと、ドロー系の作図ツールを探していた。TeX と言えば tgif という先入観からそれ系のを探していたが、そういえば Dia があったのだった。Dia はドロー系 (Draw) 作図エディタソフトウェア。検索していたところ、Microsoft Visio とよく比較されているようだ。

本記事では、以下のものを取り扱う:
nameDia for Windows
descDiaは構造的な図を描くためのプログラム
sitehttps://wiki.gnome.org/Apps/Dia
downloadhttps://wiki.gnome.org/Apps/Dia/Download (http://dia-installer.de/index.html.en)
version0.97.2 (2011年)
licenseGNU General Public License
faq.
doc.
nameDiashapes 0.3.0 (Windows/Mac)
descDiashapes は、Dia シンボルの追加のためのダウンロードとインストールを簡単に出来るようにする。Mac 版は先にMONOランタイムのインストール要とのこと。サイトを参照。
sitehttp://dia-installer.de/diashapes/index.html.en
downloadhttp://dia-installer.de/diashapes/index.html.en
version0.3.0
licenseGNU General Public License
faq.
doc.
また、後述の理由により、Python 2.3.X が必須とされる。
namePython 2.3
descPython script language
sitehttp://python.org/download/releases/2.3.5/
downloadhttp://python.org/ftp/python/2.3.5/Python-2.3.5.exe
version2.3.5
license
faq
doc.

どのような図が描けるか

インストールしたままだと、Dia は以下のような36種類の図を描くことができる:
  1. 基本図形
  2. フローチャート
  3. UML
  4. BPMN
  5. Cisco - コンピュータ
  6. Cisco - スイッチ
  7. Cisco - その他
  8. Cisco - ネットワーク
  9. Cisco - 電話
  10. ER
  11. FS
  12. GRAFCET
  13. Lights
  14. MSE
  15. RE-i*
  16. RE-Jackson
  17. RE-KAOS
  18. SADT/IDEF0
  19. SDL
  20. Sybase
  21. UML
  22. クロノグラフ
  23. サイバネティックス
  24. ジグゾー
  25. その他
  26. データベース
  27. ネットワーク
  28. ラダー回路
  29. 化学工学
  30. 回路
  31. 気学と水力学
  32. 構造化分析と設計
  33. 地図(Isometric)
  34. 電気回路
  35. 土木
  36. 論理回路

データ形式

Dia は、独自のファイル形式 (Dia Native Diagram Files) で、情報を落とさない形式 (ロスレス) で、データを扱うことができる。(8.2.1)
またヘルプドキュメントによれば、ファイルの入出力データの形式は、以下のようなフォーマットを扱うことができる:
  • 出力 (Export)
    1. Computer Graphics Metafile (.cgm)
    2. Dia Native Diagram (.dia)
    3. Dia Shape File (.shape)
    4. AutoCad Drawing eXchange Format (.dxf)
    5. HP Graphics Language (.plt, .hpgl)
    6. Encapsulated Postscript (.eps, .epsi)
    7. Portable Network Graphics (.png)
    8. Scalable Vector Graphics (.svg)
    9. Scalable Vector Graphics gzip compressed (.svgz)
    10. TeX Metapost macros (.mp)
    11. TeX PSTricks macros (.tex)
    12. WordPerfect Graphics (.wpg)
    13. XFig format (.fig)
    14. XSLT (eXtensible Stylesheet Language Transformation) (.code)
(以上14種類のフォーマット。“8.2.3 Exporting: Support for Other Formats”より)
  • 入力 (Import)
    1. Scalable Vector Graphics (.svg)
    2. AutoCad Drawing eXchange Format (.dxf)
    3. XFig File Format (.fig)
    4. GdkPixbuf bitmap graphics (.bmp, .gif, .jpg, .png, .pnm, .ras, .tif)
(以上10種類のフォーマット。“8.2.2 Import Formats”より)

インストール方法

Windows環境においては、Python 2.3 を、最初にインストールする必要がある。Dia はプラグインとして Python の形式を採用している (信じられないことだが(!)、プラグイン無しのDiaでは、図形の回転ができないのである (なぜ、このようなトチ狂った仕様にしてしまったのか、私には理解できない……)。

Dia のインストーラは、Python 2.3がインストールされているか否かを検知するため、インストールは以下の順番で行わなければならない:

  1. Python 2.3
  2. Dia
  3. PyCairo
  4. PyGtk
  5. Store the rotation script (dia_rotate.py) into Dia installation folder(ex. C:\Program Files\Dia)
  6. Diashapes
ただ、ほとんどの図形は、dia_rotate.py をインストールしても、回転できないのであった。。。
Dia, Diashapes ともに、インストールには、ダウンロードしたexeファイルを、実行するだけである。
Diashapes でダウンロードしたデータは、フォルダ:C:\Documents and Settings\Winユーザ名\.dia\ 配下に格納される。

While the GDK rendering engine provides support for rotated text, having rotated text is only part of the problem. We also need infrastructure so that handles, connection points, bounding boxes etc. are rotated along with the object. Help on this would be appreciated.
GDK のレンダリング・エンジンはテキストの回転をサポートしているものの、テキストの回転は問題の一部分にすぎない。われわれはまた、操作、コネクションポイント、バウンディングボックスなどといった回転したオブジェクトの基板的な機能を必要としている。これについて協力していただけると嬉しい。



> 2014-05-17修正: 引用文について更新した。

附言

OpenOffice の Draw か、Inkscape を使うべきなのかも知れない。。。

References


2014年5月16日金曜日

2014年5月16日の朝方の日経Web刊のトップ


2014年5月16日の朝方の日経Web刊のトップ以下のような記事でした:


日経のマーケット::トップは以下のような記事:


トップと同じですね。この記事は、今朝方の東京株式市場の大幅下落を述べています。


前日比の下げ幅は一時200円を超え、230円安の1万4067円まで下落した。


(ちょっと、日本語の表現が変に思いますが。230円安まであったのに、「一時200円を超え」……。なぜ素直に一時230円を超えた、としないのでしょうか。)

この事象の原因について、記事は、前日のアメリカの株式市場の大幅下落に起因し、運用リスクを回避するためとしています。



「ザ・ハフィントン・ポスト」日本版 / 「子供を襲った犬」を猫が撃退【動画】 という記事


昨日、ハフィントン・ポスト のニュースでこんな記事を知りました。


アメリカはカリフォルニア州のベーカーズフィールドであったできごとで、子供が犬に襲われているところを、その子供の家の飼猫のタラ(♀)が助けています。

猫にも、義侠心のようなものがあるんでしょうかね。
自分の身体の何倍もある相手に立ち向かっていくなんて、すごいです。





2014年5月15日木曜日

Google の検索欄で Emacs キーバインドが使えるようになってたゾ

ぼくが知らなかっただけ? Google の検索欄 (検索の \

2014年5月14日水曜日

Mac の GIMP 2.8.10 に G'MIC プラグインをインストールするには


Mac の GIMP 2.8.10 (gimp.org からダウンロードした本家版GIMP.app。LisaNet 版 Gimp on OS X にあらず) に、有名な画像処理のプラグイン G’MIC をインストールしようと試みたが、GIMP が認識してくれない状態だった。原因は、おそらく G’MIC のビルド上のバグで、ライブラリ libpng の配置に問題があり、読み込むことができないためである。

この問題は、簡単なワークアラウンドで回避可能で、無事インストールでき、フィルターメニューやプラグインブラウザで表示されるようになり、実際に使うことができた

GIMP.app, which is distributed from gimp.org for Mac OS X 10.9 (Mavericks), cannot detect the G’MIC for GIMP plugin. The cause of this is that gmic_gimp tried to load libpng from strange location. This article proposes a work around for this issue.




環境


試したのは以下のような環境です:


解析


通常、GIMP に、プラグインをインストールする場合は、所定の場所にバイナリを入れてやるだけでいい。たとえば、Mac OS X 10.9.x (Mavericks) の場合、


  • /Applications/GIMP.app/Contents/Resources/lib/gimp/2.0/plug-ins/

  • ~/Library/Application\ Support/GIMP/2.8/plug-ins/

のいずれかになる。

ところが G’MIC をインストールしようとしたところ、なぜか GIMP が認識してくれない。GIMP 起動時のスプラッシュ画面をみるに、いちおう探してはいてくれるようなのだが。

そこでデバッグオプションをつけてコマンドラインから調べたところ、G’MIC for GIMP (gmic_gimp) は、変な場所からライブラリ libpng15.15.dylib をロードしようとしていた (dyld: Library no loaded: の行):

$ /Applications/GIMP.app/Contents/MacOS/GIMP -c --debug-handlers
Setting up environment...
Enabling internal python...
Locale black magic...
Launching GIMP...
Cannot spawn a message bus without a machine-id: Unable to load /var/lib/dbus/machine-id or /etc/machine-id:
Failed to open file '/var/lib/dbus/machine-id': No such file or directory
dyld: Library not loaded: /tmp/skl/Gimp.app/Contents/Resources/lib/libpng15.15.dylib
Referenced from: /Users/honyarara/Library/Application Support/GIMP/2.8/plug-ins/gmic_gimp
Reason: image not found
(GIMP-bin:36253): LibGimpBase-WARNING **: GIMP-bin: gimp_wire_read(): error

解決方法 (ワークアラウンド)


これは G’MIC のビルド上のバグだが、以下のようなワークアラウンドとして回避できる:


  • libpng15.15.dylib をコピーなりシンボリックリンクを張るなりして、/tmp/skl/Gimp.app/Contents/Resources/lib/libpng15.15.dylib を作る。

libpng15.15.dylib 自体は、自分で用意するしかない。わたしの場合は、たまたま以前 brew したものが、/usr/local/Cellar/libpng/1.5.17/lib/libpng15.15.dylib に残っていたので、これを利用した:

$ mkdir -p /tmp/skl/Gimp.app/Contents/Resources/lib
$ cd !$
$ ln -s /usr/local/Cellar/libpng/1.5.17/lib/libpng15.15.dylib .

こうしておいて GIMP を起動してあげると、フィルターの最後に灰色で G'MIC が表示されるし、プラグインブラウザで G'MIC を検索することができた。

めでたしめでたし。ヽ(´∀`)ノ


2014年5月13日火曜日

Ruby OptionParser クラスのリファレンス

ruby 2.0.0-p247 環境で、ri OptionParser | col -bx したものの日本語訳です。
以前 (2008年3月16日)、Ruby: OptionParser (optparse.rb) の使い方 にて、OptionParser の記事を書きましたが、もっと完全なドキュメントが身近にありました。OptionParser のすべての機能について網羅した、こちらの説明のほうがよいでしょう。

OptionParser < Object

(from ruby core)

OptionParser

イントロダクション Introduction

OptionParser はコマンドラインオプション分析のためのクラスです。GetoptLong より、ずっと先進的で、にも関わらず使うのがより簡単、またいっそう Ruby 指向のソリューションです。

仕様 Features

  1. 引数指定とそれを処理するコードは、同じ場所に書かれます。
  2. オプションの要約を出力することができます; この要約文を別々にメンテする必要は、ありません。
  3. 選択的や必須の引数を、非常に優雅に指定されます。
  4. 引数たちを、自動で、指定のクラスに変換することができます。
  5. 引数たちを、適切なセットに制限することができます。
これらの仕様すべて、下記の例にデモしてあります。完全なドキュメントは、#make_switch を見よ。

必要最小限の例 Minimal example

  require 'optparse'
options = {}
OptionParser.new do |opts|
opts.banner = "Usage: example.rb [options]"
opts.on("-v", "--[no-]verbose", "Run verbosely") do |v|
options[:verbose] = v
end
end.parse!
p options
p ARGV

完全な記述例 Complete example

下記の例は、完全な Ruby のプログラムです。あなたは実行できますし、さまざまなオプションを指定してみることで、影響をみれます。おそらくこれは optparse の仕様を学ぶのにベストな方法でしょう。
  require 'optparse'
require 'optparse/time'
require 'ostruct'
require 'pp'
class OptparseExample
CODES = %w[iso-2022-jp shift_jis euc-jp utf8 binary]
CODE_ALIASES = { "jis" => "iso-2022-jp", "sjis" => "shift_jis" }
#
# オプションたちの構造記述を返す。
# Return a structure describing the options.
#
def self.parse(args)
# コマンドラインで指定されたオプションたちは、*options* の中に集められる
# われわれはここではデフォルトの値をセットする。
# The options specified on the command line will be collected in *options*.
# We set default values here.
options = OpenStruct.new
options.library = []
options.inplace = false
options.encoding = "utf8"
options.transfer_type = :auto
options.verbose = false
opt_parser = OptionParser.new do |opts|
opts.banner = "Usage: example.rb [options]"
opts.separator ""
opts.separator "Specific options:"
# 必須の引数。
# Mandatory argument.
opts.on("-r", "--require LIBRARY",
"Require the LIBRARY before executing your script") do |lib|
options.library << lib
end
# 選択的な引数; 複数行による記述。
# Optional argument; multi-line description.
opts.on("-i", "--inplace [EXTENSION]",
"Edit ARGV files in place",
"  (make backup if EXTENSION supplied)") do |ext|
options.inplace = true
options.extension = ext || ''
options.extension.sub!(/\A\.?(?=.)/, ".")  # Ensure extension begins with dot.
end
# 引数 'delay' を Float 型に制約する。
# Cast 'delay' argument to a Float.
opts.on("--delay N", Float, "Delay N seconds before executing") do |n|
options.delay = n
end
# 引数 'time' を Time オブジェクトに制限する。
# Cast 'time' argument to a Time object.
opts.on("-t", "--time [TIME]", Time, "Begin execution at given time") do |time|
options.time = time
end
# 8 進数の整数に制限する。
# Cast to octal integer.
opts.on("-F", "--irs [OCTAL]", OptionParser::OctalInteger,
"Specify record separator (default \\0)") do |rs|
options.record_separator = rs
end
# 列挙 (リスト) の引数。
# List of arguments.
opts.on("--list x,y,z", Array, "Example 'list' of arguments") do |list|
options.list = list
end
# キーワード補完。われわれは、特定の引数セットを指定している (CODES
# と CODE_ALIASES - 文字はハッシュであることに注目), そしてユーザは
# もっとも短いあいまいなテキストを使うかもしれない。
# Keyword completion.  We are specifying a specific set of arguments (CODES
# and CODE_ALIASES - notice the latter is a Hash), and the user may provide
# the shortest unambiguous text.
code_list = (CODE_ALIASES.keys + CODES).join(',')
opts.on("--code CODE", CODES, CODE_ALIASES, "Select encoding",
"  (#{code_list})") do |encoding|
options.encoding = encoding
end
# キーワード補完を使った選択的な引数。
# Optional argument with keyword completion.
opts.on("--type [TYPE]", [:text, :binary, :auto],
"Select transfer type (text, binary, auto)") do |t|
options.transfer_type = t
end
# ブーリアン・スイッチ。
# Boolean switch.
opts.on("-v", "--[no-]verbose", "Run verbosely") do |v|
options.verbose = v
end
opts.separator ""
opts.separator "Common options:"
# 引数なしで、tail での表示。これはオプションたちのサマリーをプリントする。
# やってみて!
# No argument, shows at tail.  This will print an options summary.
# Try it and see!
opts.on_tail("-h", "--help", "Show this message") do
puts opts
exit
end
# もうひとつの典型的なスイッチ (バージョンを表示)。
# Another typical switch to print the version.
opts.on_tail("--version", "Show version") do
puts OptionParser::Version.join('.')
exit
end
end
opt_parser.parse!(args)
options
end  # parse()
end  # class OptparseExample
options = OptparseExample.parse(ARGV)
pp options
pp ARGV

シェル補完 Shell Completion

For modern shells (e.g. bash, zsh, etc.), you can use shell completion for command line options.
モダンなシェル (e.g. bash, zsh, など) では、コマンドライン・オプションの ためにシェルの補完が使えます。

さらなるドキュメント Further documentation

上述した例はこのクラスをどのように使うかについて学ぶに十分でしょう。もしなんらかの疑問があれば、http://bugs.ruby-lang.org にチケットを切ってください。

定数 Constants:

  • DecimalInteger 10進数整数形式、Integer 型にコンバートするためのもの。
  • DecimalNumeric
    10進数の整数/浮動小数形式、整数を Integer に, 浮動小数を Float に 変換するためのもの。
  • OctalInteger Ruby/C ライクな 8進数/16進数/2進数 整数形式、Integer 型に変換する ためのもの。
  • SPLAT_PROC [not documented]

クラスメソッド Class methods:

  accept
each_const
getopts
inc
new
reject
search_const
show_version
terminate
top
with

インスタンスメソッド Instance methods:

  abort
accept
banner
base
candidate
complete
def_head_option
def_option
def_tail_option
default_argv
define
define_head
define_tail
environment
getopts
help
inc
load
make_switch
new
notwice
on
on_head
on_tail
order
order!
parse
parse!
permute
permute!
program_name
reject
release
remove
search
separator
set_banner
set_program_name
set_summary_indent
set_summary_width
summarize
summary_indent
summary_width
terminate
to_a
to_s
top
ver
version
visit
warn

属性 Attributes:

  attr_accessor default_argv
attr_accessor set_summary_indent
attr_accessor set_summary_width
attr_accessor summary_indent
attr_accessor summary_width
attr_writer banner
attr_writer program_name
attr_writer release
attr_writer set_banner
attr_writer set_program_name
attr_writer version