.htaccessを使ってリダイレクトをする際の注意

サイトを移転する際、.htaccessに301 (moved permanently)を指定してリダイレクトをさせたくなる。

しかし、多くのブラウザはHTTPステータスコード301を受け取ると、その移転先をキャッシュし、二度と古いサイトの.htaccessを読まなくなる。

これにより、移転のテストなどで.htaccessを何度か書き換えても、最初に読み込まれた内容のみが有効となり、後から書き換えたり、.htaccessを消したりしても、ブラウザは旧アドレスを自動で新アドレスに解釈してしまう。ブラウザによってはこのキャッシュは明示的に消せないこともあるようだ。

そこで、テスト時は307 (Temporary Redirect)にしておいて、問題のないことを確認してから301に書き換える、という作業が必要。

create_makefileが作るMakefileのCFLAGSをいじる

Cで書いたRuby用外部ライブラリのビルドで、コンパイルオプションを指定したかった。具体的には-DHOGEみたいなのをつけたかったのだが、これはcreate_makefileの直前にグローバル変数$CFLAGSをいじればできるようだ。

$CFLAGS += ' -DHOGE'
create_makefile('hoge')

こうすると、create_makefileが吐くMakefileのCFLAGSに-DHOGEが追加される。CPPFLAGSやLDFLAGSも同様にいじれる模様。

PowerPointのコピペの不具合

Mavericksになってから、PowerPointのコピペ関連がおかしくなり、以下のような症状が出ていた。

  • 「テキスト入力可能なオブジェクト」を単独でコピーできない。テキストボックスだけでなく、四角などの図形もダメ。
  • 「Command+A」による全体選択ができない。テキストボックス内にフォーカスがある時には、テキストの全体選択はできる。
  • 「二つ以上のオブジェクトを選択した状態」であればコピーができる。
  • 「テキスト入力不可能なオブジェクト」であればコピーできる。

ちなみにOfficeのバージョンは2008。Macは10.9.4。

いろいろやってもなかなか解決しなかったが、入力ソースを「ことえり」から「Google IME」に変えたら解決した。「ことえり」にしたら再発したので、問題が「Mavericks+ことえり」にあるのは間違いなさそう。

Cygwinのコマンドプロンプトからサクラエディタを使う

Cygwinで、関連付けされていないファイルをサクラエディタで開きたい場合、.bashrcにこう書く。

alias np=" cygstart /cygdrive/c/Program\ Files\ \(x86\)/sakura/sakura.exe $1"

これで、Cygwinコマンドプロンプト

$ np test.txt

とかやればサクラエディタが起動し、test.txtを開く。

関連付けしてあればcygstart ファイル名で開くが、HTMLやTeXなど、関連付けは別のものにしておきたいが、エディタで開きたい、という時に便利。

[Vim] vim-rubyが入らない

CentOS 6.2で最新のVimを入れようとして、configureで--enable-rubyinterpをつけたのに、vim --versionで+Rubyにならない。configureのログを見ると

checking Ruby header files... not found; disabling Ruby

と言われている。yumruby-develを入れてから./configureしてmake、make installすればOK。

$ sudo yum install ruby-devel

yum update でconflict

CentOS 6.2でyum updateしようとしたらconflictした。こんな感じ。

Transaction Check Error:
  file /usr/share/fonts/opensymbol/opens___.ttf from install of libreoffice-opensymbol-fonts-1:4.0.4.2-9.el6.noarch conflicts with file from package openoffice.org-opensymbol-fonts-1:3.2.1-19.6.el6_0.5.noarch
  file /usr/bin/unopkg from install of libreoffice-core-1:4.0.4.2-9.el6.x86_64 conflicts with file from package openoffice.org-core-1:3.2.1-19.6.el6_0.5.x86_64
  file /usr/bin/ooffice from install of libreoffice-core-1:4.0.4.2-9.el6.x86_64 conflicts with file from package openoffice.org-brand-1:3.2.1-19.6.el6_0.5.x86_64
  file /usr/bin/ooviewdoc from install of libreoffice-core-1:4.0.4.2-9.el6.x86_64 conflicts with file from package openoffice.org-brand-1:3.2.1-19.6.el6_0.5.x86_64
  file /usr/bin/openoffice.org from install of libreoffice-core-1:4.0.4.2-9.el6.x86_64 conflicts with file from package openoffice.org-brand-1:3.2.1-19.6.el6_0.5.x86_64
  file /usr/bin/openoffice.org-1.9 from install of libreoffice-core-1:4.0.4.2-9.el6.x86_64 conflicts with file from package openoffice.org-brand-1:3.2.1-19.6.el6_0.5.x86_64
  file /usr/bin/openoffice.org-2.0 from install of libreoffice-core-1:4.0.4.2-9.el6.x86_64 conflicts with file from package openoffice.org-brand-1:3.2.1-19.6.el6_0.5.x86_64
  file /usr/bin/soffice from install of libreoffice-core-1:4.0.4.2-9.el6.x86_64 conflicts with file from package openoffice.org-brand-1:3.2.1-19.6.el6_0.5.x86_64
  file /usr/bin/oowriter from install of libreoffice-writer-1:4.0.4.2-9.el6.x86_64 conflicts with file from package openoffice.org-writer-1:3.2.1-19.6.el6_0.5.x86_64

Error Summary
                        • -

どうやらOpenOfficeLibreOfficeというものがぶつかっているらしい。とりあえずOpenOfficeを削除する。

$ sudo yum remove openoffice.org-core.x86_64
$ sudo yum remove openoffice.org-opensymbol-fonts.noarch openoffice.org-ure.x86_64 # なんかcoreを削除しても残った

このあと、

$  yum list installed |grep openoffice

で、openoffice関連が残っていないことを確認したあと、yum updateしたらうまくいった。

LibreOfficeをいれたつもりはないのだが、エラーを見るに、他のインストール済みソフトがLibreOfficeのフォントか何かを利用しているのかな。

unite.vimプラグインでのエラー

なんかググってもヒットせずに苦労したので覚書。

unite.vimで「:Unite file」ディレクトリを触ろうとすると、こんなエラーが出る。

function unite#action#do..91..unite#start_temporary..unite#start#temporary..unit
e#start#standard..unite#init#_unite_buffer, line 27
Vim(setlocal):E518: Unknown option: nocursorbind
Error occured while executing action!
Action name is narrow
Press ENTER or type command to continue

日本語表記だとこんなの。

function unite#action#do..91..unite#start_temporary..unite#start#temporary..unit
e#start#standard..unite#init#_unite_buffer, 行 27
Vim(setlocal):E518: 未知のオプションです: nocursorbind
Error occured while executing action!
Action name is narrow
続けるにはENTERを押すかコマンドを入力してください

原因はvimにcursorbindオプションがないから(多分)。

$ vim --version | grep cursorbind

とかやって、出てこなければcursorbindオプションが有効になっていない。

コンパイルしなおすなり、新しいvimを入れるなりして、

$ vim --version |grep cursorbind
 +cursorbind +listcmds +quickfix +wildignore

みたいに「+cursorbind」が出てくれれば大丈夫。このエラーはでなくなる(少なくとも手元の環境では出なくなった)。