Saturday, September 10, 2011

OS X AppleScriptでスクリンロック

出かけ用のノートをマックにしてから色々便利ではあるが、やっぱりショートカットの足りなさにはどうしようもない。例えば、スクリンロックとか。

で、Google神に祈ってみた。

Lock Screen?

神様に感謝。

要はAppleScriptでスクリンロックできるってこと。ってか、ScreenSaverEngineを実行させるスクリプトを書けばいいってことかな。その中でもkaiという人が書いた方法が一番シンプルでしっかりと動いてくれた。

Note that, if the user attempts to dismiss the screen saver immediately after the activate command has been sent, a Process Manager error number -609 [connectionInvalid] may occur: "ScreenSaverEngine got an error: Connection is invalid."

This can usually be avoided by using the launch command, instead:
launch application "ScreenSaverEngine"
けど、このまま入れるとScreenSaverEngineを参照できないというエラーが起きるので、絶対パスを指定する。

launch application /System/Library/Frameworks/Screensaver.framework/Versions/A/Resources/ScreenSaverEngine.app
これを名前を付けてアプリケーションとして保存。勝手にソースを開かれるのを防ぐにはバイナリにしてもいいだろう。後はSpotlightで実行可能だ。自分は重複してもしょうがないと思いつつ、Lockという名前にしちゃった。だってすぐ忘れちゃうしな。

別の方法としてはサービスとして登録する方法があった。けど、こちらは格アプリケーションと相性が悪いのか、ショートカットが効かなかったりするのでパス。

Sunday, August 7, 2011

adb devices "no permissions"

When you using hardware devices to debug android applications, sometimes your machine may cannot found or initialize the hardware.

$ adb devices
List of devices attached
emulator-5554    device
????????????    no permissions

What happened?

1. Your machine does not have udev rules.
2. adb does not have a permission

How to

1. See this page and create the rules.
2. Kill adb server then restart it as root permission.
$ adb kill-server
$ sudo adb start-server
$ adb devices
List of devices attached
353019043208217    device

Sunday, April 24, 2011

Parrot support on Exuberant Ctags

Parrot and Ctags


As you know, parrot itself has very common editors support. Some common settings, syntax, color scheme and even tags file can generated with running "make" on parrot_src/editor directory.
$ make vi-tags
$ make vi
But, unfortunately, that tags files can do resolve to c source files that make parrot itself, so any languages wrote in parrot features such like 'pir' doesn't understand how to works with it.

So, I added parrot.c to Exuberant Ctags and published on my github.

*This is a very basic support for parrot ctags, yet*
$ git clone git://github.com/lateau/exuberant-ctags.git
$ cd exuberant-ctags
$ ./configure
$ make -j
$ su -c 'make install'     # install if you want
$ ./ctags --list-languages
...
parrot
...
$./ctags --list-kinds=parrot
s subroutine
r rule
t token
Supported files:
*.pir
*.pasm
*.pg
Kinds:
s subroutine
r rule
t token
Usage:
$ cd rakudo
$ ctags -R -exclude=.git --lang-map=parrot:+.pir.pasm.pg

How to use with tlist.vim


You can also enable TagList in vim. Just add bellow code to taglist.vim around line 430.
" parrot
s:tlist_def_parrot_settings = \
   'parrot;s:subroutine;r:rule;t:token'