最終更新日:2013/12/27

小ネタのメモ - 単独ページを作る程じゃないネタ

CUI版mplayerのビルド方法 @ 2011/08版

gitとsvnを入れた状態でターミナルで下記コマンドを実行。カレントディレクトリに今日の日付のフォルダが作られてそこにソースをダウンロードしてビルドします。ビルドが終わると最後にパスワードの入力が求められるので入力するとインストールします。

f=`date '+mplayer%Y%m%d_%H%M'`;mkdir ${f}; svn checkout svn://svn.mplayerhq.hu/mplayer/trunk ${f}; cd ${f}; git clone git://git.videolan.org/ffmpeg.git ffmpeg; ./configure; make ;sudo make install

2013/09にGCC4.2の10.6.8でmplayerのメニューを有効にしてビルド

  1. libiconvを入れる。
  2. f=`date '+mplayer%Y%m%d_%H%M'`;mkdir ${f}; svn checkout svn://svn.mplayerhq.hu/mplayer/trunk ${f}; cd ${f}; git clone git://git.videolan.org/ffmpeg.git ffmpeg;
  3. gccが古くてffmpegの_Pragma部分のビルドでエラーになるのでffmpeg/libavutil/internal.hの
    #if HAVE_PRAGMA_DEPRECATED
    #    define FF_DISABLE_DEPRECATION_WARNINGS _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
    #    define FF_ENABLE_DEPRECATION_WARNINGS  _Pragma("GCC diagnostic warning \"-Wdeprecated-declarations\"")
    #else
    #    define FF_DISABLE_DEPRECATION_WARNINGS
    #    define FF_ENABLE_DEPRECATION_WARNINGS
    #endif
    を次のようにする。
    #if HAVE_PRAGMA_DEPRECATED
    #    define FF_DISABLE_DEPRECATION_WARNINGS 
    #    define FF_ENABLE_DEPRECATION_WARNINGS  
    #else
    #    define FF_DISABLE_DEPRECATION_WARNINGS
    #    define FF_ENABLE_DEPRECATION_WARNINGS
    #endif
  4. configureのiconvのチェックに失敗するので次のように強制的にOKにしました
    	ld_iconv="-L/usr/local/lib -liconv"
    	_iconv=yes
    
    を下記の直前に入れる。
    fi
    if test "$_iconv" = yes ; then
      def_iconv='#define CONFIG_ICONV 1'
    else
      def_iconv='#undef CONFIG_ICONV'
    fi
    echores "$_iconv"
    
    メニュー表示にFontConfigとFreeTypeが必要なのですが、これで両方ともチェックOKになりました。
  5. ここでconfigure
  6. ./configure --enable-menu
  7. 次にビルドのiconvのリンク時にエラーになるのでconfig.makのEXTRALIBS、EXTRALIBS_MENCODERの最後に-liconvを追加。自分の場合は末尾が下記のようになりました。
     -lx264 -lmp3lame -liconv
  8. 上記全てをやってから下記のいつものコマンドでいけると思います。足りない物は自分はMac Portsで入れています。
  9. make ;sudo make install
  10. make中にsudoが必要になったらsudoして再度makeしてください。

LionとSIMBL

追記

EasySIMBLというものがあるのでそれで解決できます。

AXWebAreaのテキストを取得する

テスト環境:10.6.8

なかなか資料が無くて今までずっと謎だったAXWebAreaのAXTextMarkerRange、AXTextMarkerの使い方が参考になるソースをついに見かけてやっとわかったのでメモしておきます。コードが無くて文章だけでわかりにくいかもしれません。

AXWebAreaは下記属性をAXUIElementCopyParameterizedAttributeValueで取得できます。AXTextMarkerが位置、AXTextMarkerRangeが範囲です。これはAXUIElementCopyParameterizedAttributeNamesで取得、確認できます。

{"AXUIElementForTextMarker", "AXTextMarkerRangeForUIElement", "AXLineForTextMarker", "AXTextMarkerRangeForLine", "AXStringForTextMarkerRange", "AXTextMarkerForPosition", "AXBoundsForTextMarkerRange", "AXAttributedStringForTextMarkerRange", "AXTextMarkerRangeForUnorderedTextMarkers", "AXNextTextMarkerForTextMarker", "AXPreviousTextMarkerForTextMarker", "AXLeftWordTextMarkerRangeForTextMarker", "AXRightWordTextMarkerRangeForTextMarker", "AXLeftLineTextMarkerRangeForTextMarker", "AXRightLineTextMarkerRangeForTextMarker", "AXSentenceTextMarkerRangeForTextMarker", "AXParagraphTextMarkerRangeForTextMarker", "AXNextWordEndTextMarkerForTextMarker", "AXPreviousWordStartTextMarkerForTextMarker", "AXNextLineEndTextMarkerForTextMarker", "AXPreviousLineStartTextMarkerForTextMarker", "AXNextSentenceEndTextMarkerForTextMarker", "AXPreviousSentenceStartTextMarkerForTextMarker", "AXNextParagraphEndTextMarkerForTextMarker", "AXPreviousParagraphStartTextMarkerForTextMarker", "AXStyleTextMarkerRangeForTextMarker", "AXLengthForTextMarkerRange", "AXBoundsForRange", "AXStringForRange"}

UIElementをAXWebArea、parameterをAXWebAreaの属性のAXSelectedTextMarkerRangeで取得したAXTextMarkerRangeにしてAXUIElementCopyParameterizedAttributeValueで属性AXStringForTextMarkerRangeを取得すると選択しているテキストを取得できます。

AXUIElementCopyParameterizedAttributeValue( webAreaElement, @"AXStringForTextMarkerRange" , selectedTextMarkerRange, &valueRef);

AXWebAreaの全体のテキストを取る方法は、AXTextMarkerRangeForUIElementをAXWebAreaをパラメータにして実行して全体のAXTextMarkerRangeを取得してAXStringForTextMarkerRangeを実行します。

AXUIElementCopyParameterizedAttributeValue( webAreaElement, @"AXTextMarkerRangeForUIElement" , webAreaElement, &valueRef);

もう一つはAXWebAreaの属性のAXStartTextMarkerとAXEndTextMarkerから全体のAXTextMarkerRangeを作ってAXStringForTextMarkerRangeを実行する方法があります。AXTextMarkerRangeを作るにはAXTextMarkerRangeForUnorderedTextMarkersを使います。これにAXStartTextMarkerとAXEndTextMarkerが入ったNSArrayをパラメータとして渡すと、AXTextMarkerRangeが取得できます。

Evernoteなど編集可能なAXWebAreaのカーソル位置のテキストはAXSelectedTextMarkerRangeからちょっと強引に取得できます。開発用にはAXStartTextMarkerForTextMarkerRangeとAXEndTextMarkerForTextMarkerRangeという、AXTextMarkerRangeから開始と終了を取得するものがあるようなのですが、OSXに含まれているWebKitでは使えないようです。その為、AXBoundsForTextMarkerRangeでAXSelectedTextMarkerRangeの位置を取得して、AXTextMarkerForPositionでカーソル位置のAXTextMarkerを取得(Boundsのx,yをそのまま渡す。画面外のx,yでも動く)、そこからAXLeftWordTextMarkerRangeForTextMarkerで左にある単語(単語がカーソル位置まで来ていたらカーソル位置や右側も含む)をできました。テキストを選択している場合、x,yが選択範囲の端にならない場合があるので選択している場合は使えません。全体のテキストの何文字目かを調べるには上で取得したカーソル位置のAXTextMarkerとAXWebAreaのAXStartTextMarkerからAXTextMarkerRangeForUnorderedTextMarkersでAXTextMarkerRangeを作り、AXStringForTextMarkerRangeでカーソル位置の前までのテキストを取得して調べる方法で可能です。

まとめ

MenuBarAppleScriptのAppleScriptでのスクリプト

MenuBarAppleScriptのAppleScriptの命令では次のようにして取得できます。

«event UIElVal_» {"AXTextMarkerRangeForUIElement", "UIEl", "AllTextMarkerRange"}
set theAllText to «event UIElVal_» {"AXStringForTextMarkerRange", "AllTextMarkerRange", ""}

«event UIElVal_» {"AXStartTextMarker", "", "StartTextMarker"}
«event UIElVal_» {"AXSelectedTextMarkerRange", "", "SelectedTextMarkerRange"}
set theSelectedText to «event UIElVal_» {"AXStringForTextMarkerRange", "SelectedTextMarkerRange", ""}

set theBounds to «event UIElVal_» {"AXBoundsForTextMarkerRange", "SelectedTextMarkerRange", ""} -- ,
if theBounds is not missing value then
	set {theX, theY, theWidth, theHeight} to «event TextRE__» {"capture", theBounds, "x=(-?\\d+) y=(-?\\d+) w=(-?\\d+) h=(=?\\d+)", {1, 2, 3, 4}}
	
	«event UIElVal_» {"AXTextMarkerForPosition", "x=" & theX & " y=" & theY, "StartSelectionTextMarker"}
	
	«event UIElVal_» {"AXTextMarkerRangeForUnorderedTextMarkers", {"StartTextMarker", "StartSelectionTextMarker"}, "StartToStartSelectionMarkerRange"} -- ,
	
	set StartToStartSelectionText to «event UIElVal_» {"AXStringForTextMarkerRange", "StartToStartSelectionMarkerRange", ""}
	set theSelectedRangeList to {1 + (count of StartToStartSelectionText), count of theSelectedText}
else
	set theSelectedRangeList to missing value
end if

Seagate LAPTOP SSHD ST1000LM014のベンチマーク

「Seagate LAPTOP SSHD 2.5インチ SATA3.0 1TB 64MBキャッシュ 5400rpm ST1000LM014」のベンチマークです。

[SEAGATE] 2.5inch 1TB ハイブリッドドライブ Hybrid Drive(HDD/SSD) ST1000LM014

価格: 12,980円
(2013/04/12 00:10時点 )

ファイルのコピー時間

ターミナルのcpで1244ファイル 755.5MBのファイルのコピーにかかる時間を比べてみました。

各テスト間に10秒ぐらい休憩を入れました。

1秒程度の誤差はあると思います。

ST750LX003は1年ぐらい使った状態。ST1000LM014はST750LX003からファイルを全部コピーした直後の状態。

なお、OSXはOSがファイルをキャッシュするらしいですが2回目以降速いのをOSかSSHDのどっちがキャッシュしているかはわかりません。

回数ST1000LM014ST750LX003
1回目19秒27秒
2回目8秒9秒
3回目7秒8秒

起動時間計測

OSは10.6.8です。

ST1000LM014はST750LX003からOSを含めファイルを全部コピーした直後の状態。

デスクトップにFinderのメニューバーが表示されるまでの時間。多少の誤差はあると思います。

ST750LX003の時間を測っておくのを忘れたのですが、ST1000LM014より早かったような、きのせいなような。

回数起動時間コメント
1回目2分15秒コピー後最初の起動なので何かしてたのかな?
2回目1分18秒
3回目1分10秒
4回目1分4秒これの計測後2時間30分ほど普通に使用
5回目57秒
6回目47秒この辺ぐらいまで再起動
7回目53秒ここぐらいからシステム終了してから電源オンにするようにした
8回目50秒
9回目52秒あまり変わらなくなったのでとりあえず終了
約一ヶ月ぶりに計測(5/10)40秒久しぶりに測ったら10秒早くなってました!

Xbench

あまり参考にならないとも聞いたことのあるXbench

ST750LX003は1年ぐらい使った状態。ST1000LM014はST750LX003からファイルを全部コピーした直後の状態。

ST1000LM014

ST750LX003

リンク

MacBook Pro 15 early 2011のバッテリーの充電をソフトウェア制御でオン・オフする

MacBook Pro 15 early 2011のバッテリーの充電をソフトウェア制御でオン・オフするに移動しました。

東芝のSSHD MQ01ABD100HのOS別起動時間

作業用にMQ01ABD100HにOSをいろいろ入れたので記念にOS別起動時間の記録を取っておきました。

ハードウェア

パーティションマップ

124GBで8個に切ってあります。

計測方法

結果

単位は秒です

OS 1回目 2回目 3回目 4回目 5回目 6回目
10.9.1 37.3 34.3 32.8 32.5 32.3 32.3
10.8.5 32.6 37.2 30.8 28.9 29.9 28.9
10.7.5 34.9 33.5 26.4 26.6 26.7 -
10.6.8 24.8 22.8 22.3 22.6 22.5 -

まとめ