ちょっと調べたところMacにはミドルクリックと言う概念がないらしい。標準で Doshboardが開きだす。うーさすがちょっと前までマウスが1ボタンだった文化だ。もとWindows害的に面倒なんでなんとかしてみた。

基本は、middleclickをcmdキー+rightクリックに変換すればいいらしい。Logicoolのマウスとかは独自のユーティリテーで変更できるみたい。が、残念ながらー今無名1000円マウスしかないので、多分これは使えない。

そこでSynergy。基本的に2代以上のPCのキーボードとマウスを共有するためのソフトなんだけど。キーストロークの変更機能とかついてるんで、それを利用する。(この時点で大半の人には無用のポストだなw)

キーボードとマウスはWindowsについでサーバーにする。 コンフィグのGUIのHot Keysをクリック。 左側の+をクリックして出てきたダイアログでミドルクリックを押す。 右側のアクションの+を押して、同様のダイアログでMac側でcmdに当たるキーを押しながらright click。 OK.終了。

Hot keys: mousebutton(2) Action: A mousebutton(Super+2)

とかなってると思う(Superの部分は違うかも)。 まぁこれで、FirefoxだろうがSafariだろうがリンクを新規タブで開ける。 はぁ、ここにたどり着くまで、かなり苦労したんだけど。純正マカーの人とかはどうしているんだろう?

posted by Png bopper on Tue 27 Oct 2009 at 22:09

I was struggling to build collada-dom on Linux machine for a while. But the task turned out simple after I found the right solution.

The solution is here;

   1  $ make os=linux

That's too simple compared with my time spent for it :'-(

posted by Png takiuchi on Tue 27 Oct 2009 at 15:44

cmakeをbuildするときはbootstrapファイルを実行しますが、prefixを指定する場合は以下の部分を書き換えます。

   1      cmake_default_prefix="c:/Program Files/CMake"
   2    fi
   3  else
   4    cmake_default_prefix="/usr/local" # <= ここ
   5  fi

あとは make install すればok.

posted by Png takiuchi on Tue 27 Oct 2009 at 09:16

メール送信時、長い件名の場合は複数行に分割する

RFC2047によれば、「76文字以内で」複数行に分割すべき
http://www.securehtml.jp/utf-8/long_subject.html

全然知らなかったのですが、分割する必要があるそうです。

全角チルダ(〜)などはdataUsingEncoding:NSISO2022JPStringEncodingで変換できない

NSStringの下記の関数を使って、ISO-2202-JPの文字列を作るのですが、全角チルダ(〜)などがあるとnilが返ってきてしまいます:

  • (NSData *)dataUsingEncoding:(NSStringEncoding)encoding

そういう場合はallowLossyConversion:YESにして、該当の文字を「?」で置き換える必要があります:

  • (NSData *)dataUsingEncoding:(NSStringEncoding)encoding allowLossyConversion:(BOOL)flag

その他

色々調べている間に便利そうだったサイト。メモメモ。

Convert NSData to NSString or vise versa:
http://homepage.mac.com/mnishikata/objective-c_memo/convert_nsdata_to_nsstring_.html

特殊記号の読み方:
http://www1.odn.ne.jp/haru/data-list/mark.html

Unicode版 文字コード表:
http://www.m-hoz.com/jsp/unicode.jsp?Bgn=0&End=65536

NSString encoding problem with extended characters ( AKA : converting NSString to std::string)
http://lists.apple.com/archives/Syncservices-dev/2007/Mar/msg00020.html

[Perl]Perlで日本語(ISO-2022-JP)メールを送信(まとめ):
http://d.hatena.ne.jp/kopug/20060903

posted by Png satoko on Mon 26 Oct 2009 at 06:02

From this post, I will introduce topics on compiling Lisp programs with ECL, Embeddable Common Lisp. ECL is an implementation of Common Lisp, and it is especially powerful on combining lisp programs with C programs. You can embed ECL as a lisp engine in C programs, or call C functions via ffi. In a series of posts, several ways to compile lisp programs and use them from C programs are introduced. As a starter, I explain file types generated by some compilation approaches. I suppose GNU/Linux system and gcc as a development environment.

Overview

You can generate following files with ECL.

  • Object file (.o)
  • Fasl file (.fas)
  • Static library (.a)
  • Shared library (.so)
  • Executable file

Relations among them are depicted below:

file-type-relations.png

Object file

As you can see, object file works as an intermediate file format. If you want to compile more than two lisp files, you might better to compile with a :system-p t option, which generates object files.

On linux systems, ECL invokes gcc -c for generating object files.

An object file consists of some functions in C:

  • Functions corresponding to Lisp functions
  • The initialization function which registers defined functions on the lisp environment

Consider the example below.

   1  (defun say-hello ()
   2    (print "Hello, world"))

During compilation, This simple lisp program is translated into the C program, and then compiled into the object file. The C program contains two functions:

  • static cl_object L1say_hello: corresponding to 'say-hello' function
  • ECL_DLLEXPORT void _eclwm2nNauJEfEnD_CLSxi0z(cl_object flag): initialization function

In order to use these object files from your C program, you have to call initialization functions before using lisp functions (such like 'say-hello'). However the name of an init function is seemed to be randomized and not user-friendly. This is because object files are not intended to be used directly. ECL provides some user-friendly ways to generate compiled lisp programs(as static/shared libraries or executable), and in each approach, object files act as intermediate files.

Fasl file

If you want to make a library which is loaded dynamically from lisp program, you should choose fasl file format.

In current ECL(9.10.2), a fasl file is just a shared library file. This means you can load fasl files with dlopen and initialize it by calling a init function from C programs, but this is not an intended usage. Recommended usage is loading fasl files by calling load lisp function.

Creating a fasl file from one lisp file is very easy.

   1  (compile-file "hello.lsp")

To create a fasl file from some lisp files, firstly you have to compile each lisp file into object file, and then combine them with c:build-fasl.

   1  ;; generates hello.o
   2  (compile-file "hello.lsp" :system-p t)
   3  ;; generates goodbye.o
   4  (compile-file "goodbye.lsp" :system-p t)
   5  
   6  ;; generates hello-goodbye.fas
   7  (c:build-fasl "hello-goodbye"
   8                :lisp-files '("hello.o" "goodbye.o"))

Static library

ECL can compile lisp programs to static libraries, which can be linked with C programs. A static library is created by c:build-static-library with some compiled object files.

   1  ;; generates hello.o
   2  (compile-file "hello.lsp" :system-p t)
   3  ;; generates goodbye.o
   4  (compile-file "goodbye.lsp" :system-p t)
   5  
   6  ;; generates libhello-goodbye.a
   7  (c:build-static-library "hello-goodbye"
   8                :lisp-files '("hello.o" "goodbye.o")
   9                :init-name "init_hello_goodbye")

When you use static/shared library, you have to call init functions. The name of the function is specified by :init-name option. In this example, "init_hello_goodbye" is it. The usage of this function is shown below:

   1  #include <ecl/ecl.h>
   2  extern void init_hello_goodbye(cl_object cblock);
   3  
   4  int
   5  main(int argc, char **argv)
   6  {
   7      // setup the lisp runtime
   8      cl_boot(argc, argv);
   9      
  10      // call the init function via read_VV
  11      read_VV(OBJNULL, init_hello_goodbye);
  12      
  13      ...
  14          
  15      // shutdown the lisp runtime
  16      cl_shutdown();
  17  
  18      return 0;
  19  }

Because the program itself does not know the type of the init function, a prototype declaration is inserted. After booting up the lisp environment, invoke init_hello_goodbye via read_VV. init_hello_goodbye takes a argument, and read_VV supplies an appropriate one. Now that the initialization is finished, we can use functions and other stuffs defined in the library.

Shared library

Almost the same as the case of static library.

Executable file

Some of you might want to create a standalone executable from lisp programs. ECL supports executable file generation. First, compile all lisp files to object files. After that, calling c:build-program does the job.

   1  ;; generates hello.o
   2  (compile-file "hello.lsp" :system-p t)
   3  ;; generates goodbye.o
   4  (compile-file "goodbye.lsp" :system-p t)
   5  
   6  ;; generates hello-goodbye
   7  (c:build-program "hello-goodbye"
   8                :lisp-files '("hello.o" "goodbye.o"))

Summary

In this post, some file types that can be compiled to with ECL were introduced. Each file type has adequate purpose:

  • Object file: intermediate file format for others
  • Fasl file: loaded dynamically via load lisp function
  • Static library: linked with and used from C programs
  • Shared library: loaded dynamically and used from C programs
  • Executable: standalone executable

ECL provides a high-level interface c:build-* for each format. If you want to use them, you can find detailed description in the manual. Enjoy!

References

posted by Png hayamiz on Mon 26 Oct 2009 at 00:09

原子と電磁波の相互作用

  • トムソン散乱
  • コンプトン散乱
  • ラマン散乱

分子レベルの相互作用

  • レイリー散乱
  • ミー散乱

See Also

posted by Png takiuchi on Sun 25 Oct 2009 at 08:06

OpenCLのエラーコードのメモです。

   1  // Error Codes
   2  #define CL_SUCCESS                                  0
   3  #define CL_DEVICE_NOT_FOUND                         -1
   4  #define CL_DEVICE_NOT_AVAILABLE                     -2
   5  #define CL_COMPILER_NOT_AVAILABLE                   -3
   6  #define CL_MEM_OBJECT_ALLOCATION_FAILURE            -4
   7  #define CL_OUT_OF_RESOURCES                         -5
   8  #define CL_OUT_OF_HOST_MEMORY                       -6
   9  #define CL_PROFILING_INFO_NOT_AVAILABLE             -7
  10  #define CL_MEM_COPY_OVERLAP                         -8
  11  #define CL_IMAGE_FORMAT_MISMATCH                    -9
  12  #define CL_IMAGE_FORMAT_NOT_SUPPORTED               -10
  13  #define CL_BUILD_PROGRAM_FAILURE                    -11
  14  #define CL_MAP_FAILURE                              -12
  15  
  16  #define CL_INVALID_VALUE                            -30
  17  #define CL_INVALID_DEVICE_TYPE                      -31
  18  #define CL_INVALID_PLATFORM                         -32
  19  #define CL_INVALID_DEVICE                           -33
  20  #define CL_INVALID_CONTEXT                          -34
  21  #define CL_INVALID_QUEUE_PROPERTIES                 -35
  22  #define CL_INVALID_COMMAND_QUEUE                    -36
  23  #define CL_INVALID_HOST_PTR                         -37
  24  #define CL_INVALID_MEM_OBJECT                       -38
  25  #define CL_INVALID_IMAGE_FORMAT_DESCRIPTOR          -39
  26  #define CL_INVALID_IMAGE_SIZE                       -40
  27  #define CL_INVALID_SAMPLER                          -41
  28  #define CL_INVALID_BINARY                           -42
  29  #define CL_INVALID_BUILD_OPTIONS                    -43
  30  #define CL_INVALID_PROGRAM                          -44
  31  #define CL_INVALID_PROGRAM_EXECUTABLE               -45
  32  #define CL_INVALID_KERNEL_NAME                      -46
  33  #define CL_INVALID_KERNEL_DEFINITION                -47
  34  #define CL_INVALID_KERNEL                           -48
  35  #define CL_INVALID_ARG_INDEX                        -49
  36  #define CL_INVALID_ARG_VALUE                        -50
  37  #define CL_INVALID_ARG_SIZE                         -51
  38  #define CL_INVALID_KERNEL_ARGS                      -52
  39  #define CL_INVALID_WORK_DIMENSION                   -53
  40  #define CL_INVALID_WORK_GROUP_SIZE                  -54
  41  #define CL_INVALID_WORK_ITEM_SIZE                   -55
  42  #define CL_INVALID_GLOBAL_OFFSET                    -56
  43  #define CL_INVALID_EVENT_WAIT_LIST                  -57
  44  #define CL_INVALID_EVENT                            -58
  45  #define CL_INVALID_OPERATION                        -59
  46  #define CL_INVALID_GL_OBJECT                        -60
  47  #define CL_INVALID_BUFFER_SIZE                      -61
  48  #define CL_INVALID_MIP_LEVEL                        -62
  49  #define CL_INVALID_GLOBAL_WORK_SIZE                 -63

posted by Png genki on Sat 24 Oct 2009 at 15:54

haml は構造化文章をシンプルかつ強力に記述することができるが、 複数行のデータの扱いには以下の理由で不向きである。

  • 行指向であるため適切なインデントの記述が強要される
  • 頑張って埋め込んでも可読性が落ちて全体の構造が把握し辛くなる

これを改善するには、コード(構造情報)とデータの分離が必要になる。

inline filter module

   1  module Inline
   2    include Haml::Filters::Base
   3   
   4    def self.[](key)
   5      @@data[key.to_s] rescue nil
   6    end
   7   
   8    def render(str)
   9      @@data = Hash[*str.split(/^\s*@@\s*(\w+)\s*\n/m)[1..-1]]
  10      return nil
  11    end
  12  end

上記を評価することで、 sinatra の in file template のようにデータ群を管理できるようになる。

入力(haml)

   1  %h1 Inline Filter
   2  .describe= Inline[:describe]
   3  .author created by #{Inline[:author]}
   4   
   5  :inline
   6   @@ describe
   7   This filter easily separates structure and data.
   8   You can use in-file-templates like sinatra.
   9   
  10   @@ author
  11   maiha@wota.jp

出力(html)

   1  <h1>Inline Filter</h1>
   2  <div class='describe'>
   3    This filter easily separates structure and data.
   4    You can use in-file-templates like sinatra.
   5  </div>
   6  <div class='author'>created by maiha@wota.jp</div>

posted by Png maiha on Tue 20 Oct 2009 at 20:59

Gears を使うには

  1. gears_init.js の読み込み
  2. 低レベルAPIを駆使

という面倒な作業が必要になる。

具体的には

   1  <script type="text/javascript" src="gears_init.js"></script>

   1  var db = google.gears.factory.create('beta.database');
   2  db.open("database-demo");
   3  var rs = db.execute("select name from users");
   4  while(rs.isValidRow()) {
   5    name = rs.fieldByName('name');
   6    rs.next();
   7  }
   8  rs.close();
   9  db.close();

のようなコードが必要になり、今日日こういうのは書きたくない。 そこで、

active_record.js を使う

Aptana が提供してる activejs プロジェクトの ActiveRecord ライブラリを利用すると、以下のようにすっきりする。

   1  <script type="text/javascript" src="active_record.js"></script>

   1  ActiveRecord.connect(ActiveRecord.Adapters.Gears,'database-demo');
   2  var User = ActiveRecord.create('users', {name:''});
   3  User.create({name:'maiha'});

RailsのARを忠実にJavaScriptへ移植してあるため、 ARに慣れていればほぼドキュメントなしで使えるのが嬉しい。

   1  maiha = User.findByName('maiha');  // Dynamic Finder
   2  name  = maiha.name; // Accessor methods
   3  maiha.name = 'foo';
   4  maiha.save();
   5  
   6  User.count();
   7  User.find({all: true, order: 'name'});

他にも

  • Validation
  • Callback
  • Relation (hasOne, hasMany, belongsTo)
  • Migration

といった機能が実装されており、 ARの移植物としてみても完成度が非常に高い。 ちなみに、js のサイズは compaction なしで200KB程度。

参考

  • http://activerecordjs.org/
posted by Png maiha on Mon 19 Oct 2009 at 05:51

しばらくGemを作ってなかったので気がつかなかったのですが、 Gem作りを取り巻く環境が結構変わっているようですね。

まず、newgemやcutagem, hoeのようにgemのひな形を作ってくれる jeweler というtoolが結構使われているようです。これはgithubにインテグレートされていて非常に便利です。

githubはちょっと前からgemをホストするgemリポジトリサービスをやめてしまったようで、代わりに Gemcutterを使うようになっています。 jewelerを使う事で、gemcutterやrubyforgeにgemをpushする事ができます。

posted by Png genki on Sat 17 Oct 2009 at 10:20
Contents
Macでmiddle clickを無理矢理使う方法。
How to build collada-dom on Linux
cmakeをhomeの下にインストールする手順のメモ
[iPhone] メール送信アプリでのツボ
Compiling with ECL (1): File types
原子レベルのレンダリングに関するメモ
OpenCLのエラーコード
haml で in file template
ActiveRecord on Gears
最近のGem事情
Comments
瀧内元気: MacOS版は以下にあります * [genki/ViMouse](https://githu... '23-1
KingofSmack: Here also good reads for this mobile applicatio... '14-5
Spencer: You don't have to re-compile it, this version w... '14-4
staiano: Any chance we can get a recompile for 10.9? '14-1
dsjf: https://gist.github.com/6bf1bf2c3cbb5eb6e7a7 これ... '13-1
Services from s21g
twpro(ツイプロ)
Twitterプロフィールを快適検索
地価2009
土地の値段を調べてみよう
MyRestaurant
自分だけのレストラン手帳
Formula
ブログに数式を埋め込める数式コミュニティ