Automatorでテキストからアドレス抽出
あるテキスト中のメールアドレス宛全員にメールを送りたいなという時に,一々コピー&ペーストか右クリック→アドレスコピーするのがすごく面倒でした.
ということでAutomatorで何とかできないかと思っていたら,かなり簡単にできたので載せておきます.
使い方
全てのプログラムで使用できるようにしているので,例えばSafari中に アドレスを含むテキスト を選択し,メニュー[Safari]-[サービス]-[保存したサービス名(例: "アドレス抽出")]を選択すると,アドレスのみクリップボードにコピーされる.
あとは必要なところにペーストして使用.
問題点
エンター区切りなのがどう災いするかが問題.カンマ区切りとかバリエーションできないだろうか…
Safari: 設定とかTipsとか
バニラ状態でも比較的サクサク動くので満足しているのだが,さらに快適性を増すことができないかトライ.
ショートカットなど
新規タブ
一々"戻る"のも面倒なのでよく新規タブを作っている.Safari環境設定の[タブ]でショートカットを"若干"変更できる.今のところ下の設定が便利である.
Glims
[Ref] http://wakabamac.blog95.fc2.com/blog-entry-665.html
検索,タブ,ブックマークに関するプラグイン
以前から入れていたはずなのだがSafariが6に更新された際に消えていた模様.再インストールがてら設定.
検索拡張
[一般]で[検索エンジンを追加]していると,検索エンジン変更のアイコンが追加される.もちろん検索エンジンの追加も可能で,Google Scholarでの検索の場合は以下のとおり.
ショートカットでもいいのだが,キーワードを登録して検索エンジンを指定する方が便利.上の例だと
s applied physics
とするとGoogle Scholarで"applied physics"を検索する.
ブックマーク
"ここにブックマークを追加" の追加が地味に便利.
タブグループ
Safari TabGroups Organizer
FireFoxほどの機能はないが,複数タブの保存/呼び出しという点では十分使えるのでは?と思われる拡張機能.
mi.appをgnuplotに連携
せっかくTeXで便利なミミカキエディット(mi.app)があるので,gnuplotのプロットファイルを編集しながらすぐにプロット確認できないか試してみた.
MacでWindowsのアプリケーションを実行/インストール
Wineを使ったMac上でのWindowsアプリケーション実行に関するメモ.
最近はかなり便利なアプリが出てきたので敷居が低いようです.
しかもWine 1.5くらいからX11を使用しないらしいので,(多分)さらに便利に.
使えるソフトについてはこちらをどうぞ (まだ全然書いていませんが)
概略
Windowsで動く実行ファイル(拡張子.exe)はMac上では実行することができませんが,Wine というソフト(環境) を使うと Mac OS X でもwindows実行ファイルを実行することができたりします.
ここではWineをさらに使いやすくしたソフト2つについて紹介します.
- 「環境をインストールするのは面倒」or「インストール形式のwindowsソフトを使えるようにしたい」 → WineBottler
- 「Macのアプリのようにダブルクリックですぐ使えるようにしたい」 → NXWine
※注) 全てのソフトが使えるとは限りませんし,実行したことにより不具合が起きる可能性もあるのでご注意ください.
WineBottler
OS X 10.6時代よりあるMac用バンドル済みWineと,バンドル化appを作成するアプリ.
ソフトの導入
Wine.appとWineBottler.appをアプリケーションフォルダに入れるだけ.
Windowsアプリのインストール
- WineBottlerを起動
- Advancesからインストールしたいexeを選択,"This is an installer" を選択して実行.
- appの保存先を指定すると完了
インストール後はデスクトップにリンクができるので便利.
スタンドアロンアプリの実行
Wine.appを一度実行しておく.(少しだけ時間かかる)
exeファイルをWine.appから開く(プログラムから開く で選択するか,D'n'D)
NXWine
Mac用バンドル済みWineとWine内の設定などに便利.
バンドル化はしないが,MacにWindows環境があるような感じで簡単に使える.
和製なので日本語との相性も良い.
(注意: NXWineダウンロードで4sharedを経由するが,広告に注意.4sharedのアカウントもしくはGoogleのアカウントなどでログインしないとダウンロードできないっぽい.)
導入方法
- NXWineをインストール
- [Wine設定]などを実行して,初期設定(prefix)を終わらせておく (少し時間がかかる)
- 一旦ダイアログが表示されたら終了させる.
使用方法
所望のexeをダブルクリックするだけで実行可能です.
一応インストーラからインストールもできますが,インストール先は /Users/(ユーザ名)/Library/NXWine/prefixes/default/drive_c/Program Files/ 下なので若干面倒です.
14-09-26 追記
gnuplot小ネタ
2014/3/25 追記
gnuplotでフィッティング
[書式] > fit 範囲 関数 データファイル 列指定 変数指定 [例] fit [0:10] a+b*x "data.txt" u 1:2 via a,b #0から10の範囲で1次関数フィッティング fit f(x,a,b,c) "data2.txt" u ($1*10):($2/$3) via a,b,c # データの1列目を10倍したものをx, 2列目を3列目で割ったものをyとしてフィッティング
- 範囲は指定しなくてもよい
- 関数を前もって f(x)=.. と定義して使用可能
y軸目盛を2種類使用
y2軸 (y2range, y2tics) を使う.plot 関数で axes を指定.
[例] set xrange [-1:1] set yrange [-1:1] set y2range [0:5] set y2tics set ytics nomirror #右側にy1軸の目盛を表示しない plot sin(x), exp(x) axes x1y2
線分/点のスタイル設定
http://www.gnuplot-cmd.com/style/style-line.html
set style linelt 1 lc 1 lw 1 pt 1 ps 1
: linestyle (ls) で設定する線の番号. - lt: ライン種.破線が使用できるなら破線など
- lc: 色.数字を指定すると各terminalで設定された色が出るほか,rgb "#ff0000" などで直接設定できる.
- lw: ライン幅
- pt: 点種
- ps: 点サイズ
出力端末ごとのライン種/点種一覧は,test から確認できる.
Octave事始め(プロット,ファイル,フィッティング)
HomebrewでインストールしたOctaveの使用例を3つほど.
プロット
記法
plot(x,y) plot(x,y,fmt) plot(x1,y1,fmt1,x2,…)
xyプロット.x,yはそれぞれ配列(行ベクトル).
fmt にプロット方法のオプションが指定できる.
'-' | ライン(デフォルト) |
'@' | 打点(記号) |
'-@' | ラインと打点 |
'n' | 色の指定(n=1~9) |
'+' '*' 'o' 'x' | それぞれの記号で打点 |
';str;' | strを凡例タイトルに表示する |
例
x = [0:0.1:pi]; plot(x,sin(x))
ファイル
関数ファイル
ファイル名は 関数名.m .コメント以外の書き出しが function 戻り値 = 関数名(引数) .octaveが読んでくるディレクトリもしくはカレントディレクトリに関数ファイルがあれば,関数を指定するだけで自動的に読み込んでくれる(らしい).
スクリプトファイル
拡張子が .m であれば任意.書き出しが function
以外であることに注意.ファイル名(.m省く)を指定すると自動的に初めの行から実行される.なお,ターミナルで
octave -qf ファイル名(.m付き)
でも実行できる.(qfオプションにより,起動時の表示を消せる.)
変数ファイル
ファイル名は任意.load ファイル名 で読み出し,拡張子を除いたファイル名が変数となる.
例
> test.txt 0 1.5 1 5.2 2 8.1 3 4.8 5 6.4 > octave load test.txt
変数ファイルの書き出しに,コメントで
# name: test # type: matrix # rows: 10 # columns: 2
などと記載すると,その変数で読まれる.(octave上で save ファイル名 変数名 で変数ファイルを保存した場合のフォーマット)
文字列変数に入っているファイル名を使って読み書きする場合,
> load (filename)
とすると読み出せる.(平文で書くと filename という名前のファイルを読もうとしてしまう.)
フィッティング
octaveの optim パッケージ内の leasqr 関数を使用.
パッケージインストール方法
octave上で
> pkg install -forge パッケージファイル名
でインストール可能.ローカルに保存してあれば -forge オプション無しでOK.
パッケージ一覧は こちら
なお,依存関係があるので,optim の場合 miscellaneous(要general) と struct が必要.
トラブルシューティング
miscellaneousインストール時にエラーが発生.
> mkoctfile -p CC clang
の場合になることがあるらしい.一度octaveから出て,ターミナルで
$ export CC=llvm-gcc-4.2 $ export CXX=llvm-g++-4.2
としてからoctaveの追加パッケージインストール
をすると成功した.
パッケージ利用方法
パッケージ内の関数を使用する場合,
> pkg load optim
としないといけない.
備考
最小二乗フィッティングなら gnuplotの方が楽かも…
http://activecontour.blog63.fc2.com/blog-entry-14.html
Octave
Matlabのスクリプトも扱える,GNU系フリー数値計算ソフト.
Ref
インストール方法(Homebrew)
# brew tap homebrew/science # brew update && brew upgrade # brew install gfortran # brew install octave
しかしエラー.
Trouble Shooting
エラー内容
==> Installing octave ==> Using Homebrew-provided fortran compiler. This may be changed by setting the FC environment variable. ==> Building with an alternative Fortran compiler This is unsupported. ==> Building with an alternative Fortran compiler This is unsupported. ==> Downloading http://ftpmirror.gnu.org/octave/octave-3.6.4.tar.bz2 ###################################################### 76.0% curl: (18) transfer closed with 3756305 bytes remaining to read Trying a mirror... ==> Downloading http://ftp.gnu.org/gnu/octave/octave-3.6.4.tar.bz2 ######################################################################## 100.0% ==> Downloading patches ######################################################################## 100.0% ==> Patching patching file configure.ac Hunk #1 succeeded at 1605 (offset 2 lines). ==> autoreconf -ivf ==> ./configure --prefix=/usr/local/Cellar/octave/3.6.4 --with-blas=-Wl,-framewo ==> make all ==> make install ./plot.texi:3957: warning: node `Multiple Plot Windows' is prev for `Printing and Saving Plots' in menu but not in sectioning make[3]: *** [octave.info] Error 1 make[2]: *** [install-recursive] Error 1 make[1]: *** [install-recursive] Error 1 make: *** [install] Error 2 READ THIS: https://github.com/mxcl/homebrew/wiki/troubleshooting If reporting this issue please do so at (not mxcl/homebrew): https://github.com/homebrew/homebrew-science/issues
brew doctor
Warning: Some directories in /usr/local/share/man aren't writable. This can happen if you "sudo make install" software that isn't managed by Homebrew. If a brew tries to add locale information to one of these directories, then the install will fail during the link step. You should probably `chown` them: /usr/local/share/man/de /usr/local/share/man/de/man1 Warning: Broken symlinks were found. Remove them with `brew prune`: /usr/local/share/ghostscript/9.02/Resource/CIDFont/LiHeiPro Warning: Your XQuartz (2.7.4) is outdated Please install XQuartz 2.7.5: https://xquartz.macosforge.org Warning: Unbrewed dylibs were found in /usr/local/lib. If you didn't put them there on purpose they could cause problems when building Homebrew formulae, and may need to be deleted. Unexpected dylibs: /usr/local/lib/liblkdynam.dylib /usr/local/lib/liblkrealt.dylib /usr/local/lib/liblksec.dylib /usr/local/lib/liblksock.dylib /usr/local/lib/libosxfuse_i32.2.dylib /usr/local/lib/libosxfuse_i64.2.dylib Warning: Unbrewed .la files were found in /usr/local/lib. If you didn't put them there on purpose they could cause problems when building Homebrew formulae, and may need to be deleted. Unexpected .la files: /usr/local/lib/libosxfuse_i32.la /usr/local/lib/libosxfuse_i64.la Warning: Unbrewed .pc files were found in /usr/local/lib/pkgconfig. If you didn't put them there on purpose they could cause problems when building Homebrew formulae, and may need to be deleted. Unexpected .pc files: /usr/local/lib/pkgconfig/osxfuse.pc Warning: Your compilers are different from the standard versions for your Xcode. If you have Xcode 4.3 or newer, you should install the Command Line Tools for Xcode from within Xcode's Download preferences. Otherwise, you should reinstall Xcode.
対処
$ sudo chown tomkimra:admin /usr/local/share/man/de $ sudo chown tomkimra:admin /usr/local/share/man/de/man1
- Xcodeのcommand line toolsをインストール(してなかったのか..)
- Xquartzをアップグレード
- でもインストールできず.
- Ref: https://gist.github.com/myobie/1860902
- /Users/tomkimra/Library/Logs/Homebrew/octave/ にログが残るらしい.
- こっちのエントリに似てる?
- これでもダメだった
- --withouth-fltkオプション付きでもダメ
- https://github.com/Homebrew/homebrew-science/pull/512 と http://qiita.com/semind/items/f8f647e757842f08b9ec を参考に,GLPKを4.48でinstallした上で, https://github.com/Homebrew/homebrew-science/issues/444 のようにoctaveのformulaを変更して brew install
- 何とかインストール完了.
- octaveのformulaは https://github.com/Homebrew/homebrew-science/issues/423 でも行けるかも.GLPKのおかげなのかformulaのおかげなのか…
- プロットできず.
configure: WARNING: I didn't find ghostscript, so reconstructing figures for the manual will fail, and saving graphics in some output formats will fail when using Octave configure: WARNING: building documentation disabled; make dist will fail configure: WARNING: configure: WARNING: I didn't find gnuplot. Plotting commands will use the configure: WARNING: native graphics toolkit. configure: WARNING: configure: WARNING: If gnuplot is installed, but isn't in your path, you can configure: WARNING: tell Octave where to find it by using the gnuplot_binary configure: WARNING: function. For example, configure: WARNING: configure: WARNING: gnuplot_binary ("/full/path/and/name/of/gnuplot/binary") configure: WARNING: configure: WARNING: at the Octave prompt. configure: WARNING: configure: WARNING: Setting default value to gnuplot configure: WARNING: configure: configure: NOTE: libraries may be skipped if a library is not found OR configure: NOTE: if the library on your system is missing required features.