Visual Studio系でC言語からPerlを呼び出す方法


すいません。これだけじゃ動きません。
現在、研究中。


インクルードパスとライブラリパスに下記のパスを追加するだけ。
注)デフォルトインストールパスを記述しているので、環境に合わせて追加する事。

C:\Perl\lib\CORE


上記のパスにヘッダファイルとライブラリが入ってる。
後は、以前に書いた通りで動く。

Catalystアプリケーションを携帯対応にしてみる


ViewはTTでやる。
Viewだけ機種毎に切り替える。

MyApp.pm

use Catalyst qw/
    MobileAgent
/;


TT.pm

# processをオーバーライド
sub process {
    my ( $self, $c ) = @_;

    # 機種を判断
    if($c->req->mobile_agent->is_docomo){
        # ドコモ
        $self->{include_path} = (@{$c->config->{View::TT}->{INCLUDE_PATH}}, $c->path_to('root/docomo_tmpl'));
    }elsif($c->request->mobile_agent->is_vodafone){
        # vodafone
        $self->{include_path} = (@{$c->config->{View::TT}->{INCLUDE_PATH}}, $c->path_to('root/voda_tmpl'));
    }elsif($c->request->mobile_agent->is_ezweb){
        # au
        $self->{include_path} = (@{$c->config->{View::TT}->{INCLUDE_PATH}}, $c->path_to('root/ez_tmpl'));
    }else{
        # PC等
        $self->{include_path} = (@{$c->config->{View::TT}->{INCLUDE_PATH}}, $c->path_to('root/pc_tmpl'));
    }

    # 通常のprocess処理
    $self->SUPER::process($c);

    return 1;
}

Catalystで強制的にデバッグ画面を表示させる


Catalyst::Action::RenderViewってのがあるらしい。

MyApp/Controller/MyCont.pm

sub end : ActionClass('RenderView') {
    my($self, $c) = @_;
}


上記を記述してある状態で、リクエストにdump_info=1を追加すると強制的にデバッグ画面が表示される。

例)

http://exsample.com/mycont/?dump_info=1


ちなみにこの記述だとViewを呼び出した後に呼ぶFillInFormが使えない。
endの処理を全て終わらせてから勝手にViewを呼ばれるから。

jnethackをFedoraにインスコしてみる

jnethackとは

ローグに感化された多くのゲームの1つであるnethackの日本語版。
ローグライクと呼ばれる作品は他に「トルネコの大冒険」「風来のシレン」などがある。




yumにはnethackしかなかったのでソースからインスコ


ここからnethackをダウンロード
ここからjnethackパッチをダウンロード

$ wget http://nchc.dl.sourceforge.net/sourceforge/nethack/nethack-343-linux-X11.tgz
$ tar zxvfp nethack-343-linux-X11.tgz
$ cd nethack-3.4.3
$ wget http://jaist.dl.sourceforge.jp/jnethack/25190/jnethack-3.4.3-0.9.diff.gz
$ gunzip jnethack-3.4.3-0.9.diff.gz
$ patch p1 < jnethack-3.4.3-0.9.diff
$ sh ./sys/unix/setup.sh
$ make all
$ make install


/usr/games/にインスコされるので実行汁。
インスコ場所を変更したいならMakefileを弄ると可能。


数回プレイしてみたが、3階以上進んだことがありません。

DBIx::Classで検索方法色々


今更ながらにDBIx::Classを使ってみた。
その時に勉強した検索方法色々。

# IDを指定して検索
$db->resultset('table')->find(ID);

# 条件を指定して検索
$db->resultset('table')->search({
    flg => 1,
});

# and検索
$db->resultset('table')->search({
    flg => 1,
    id  => 2,
});

# or検索
$db->resultset('table')->search({
    -or => [
        flg => 1,
        id  => 2,
    ]
});

# andとorの組み合わせ
$db->resultset('table')->search({
    -or => [
        {
            flg => 1,
            id  => 2,
        },
        flg => 2,
    ]
});

# 不等号とか
$db->resultset('table')->search({
    id => {'>' => 3},
});

# order byとか
$db->resultset('table')->search({
    flg => 1,
}, {order_by => 'id'});

emacs設定メモ

.emacs

;;---------------------------------------------------------------------------
;; Emacs設定
;;---------------------------------------------------------------------------
;; 日本語の設定
(set-language-environment "Japanese")



;; リージョンの色
(set-face-background 'region "SkyBlue")
(set-face-foreground 'region "black")

(if (boundp 'window-system)
  (setq initial-frame-alist
    (append (list
      '(foreground-color . "azure3") ;; 文字が白
      '(background-color . "black")  ;; 背景は黒
      '(border-color     . "black")
      '(mouse-color      . "white")
      '(cursor-color     . "white")
      '(cursor-type      . bar)
      '(menu-bar-lines . 1)
      '(vertical-scroll-bars . nil) ;;スクロールバーはいらない
      '(width . 100) ;; ウィンドウ幅
      '(height . 35) ;; ウィンドウの高さ
      '(top . 60) ;;表示位置
      '(left . 140) ;;表示位置
    )
  initial-frame-alist)))
(setq default-frame-alist initial-frame-alist)

;; タイトルバーにバッファ名を表示
(setq frame-title-format "%b")

;; ツールバーを表示しない
(tool-bar-mode 0)

;; メニューを表示しない
(menu-bar-mode -1)

;; ミニバッファのサイズを変更しない
(setq resize-mini-windows nil)

;; 起動時の画面を表示しない
(setq inhibit-startup-message t)



;; グローバルキーバインドの変更
(global-set-key "\C-h" 'backward-delete-char)
(global-set-key [f1] 'help-for-help)



;; タブ幅を4に設定
(setq-default tab-width 4)

;; タブ幅の倍数を設定
(setq tab-stop-list
  '(4 8 12 16 20 24 28 32 36 40 44 48 52 56 60))

;; タブではなくスペースを使う
(setq-default indent-tabs-mode nil)
(setq indent-line-function 'indent-relative-maybe)



;; モードラインにカーソルがある行の行数を表示
(line-number-mode 1)

;; モードラインにカーソルがある位置の文字数を表示
(column-number-mode 1)



;; リージョンに色をつける
(setq transient-mark-mode t)

;; リージョンを選択中にBSか文字を入力すると内容を削除する
(delete-selection-mode 1)

ごめん。まだ途中なんだ。



apelのインスコ

$ cvs -d :pserver:anonymous@cvs.m17n.org:/cvs/root login
CVS password: [CR] # NULL string
$ cvs -z9 -d :pserver:anonymous@cvs.m17n.org:/cvs/root checkout apel
$ cd apel
$ make elc
$ make install

WindowsのフォントをFedora7にインスコ


Windowsのフォントが入ってるディレクトリから好きなフォントをFedoraに持ってくる。
〜〜.ttcってヤツね。

/usr/share/fonts/japanese/TrueType/

に持ってくればいいと思う。



持ってきたら

$ xset fp rehash

コレで完了。