ゆるPerl #14 にいってきた
Cafe どえりゃあ 復活です
Paas 的なものでなんかやりたいと思って,
とりあえずdotcloud を試そうと思って,
フレームワークどうしようかなと思って,
とりあえず Amon2 を試そうと思って,
cpanm Amon2 したら,make がないって言われて,
そういえば,今日Lion にしたから,/usr/bin の下が綺麗になってて,
Xcode 入れなきゃって思ったけど,
どうせならXcode4 にしようと思って,
ダウンロードしてインストールしてたらなんか時間が過ぎてた感じ.
id:bleis-tift の人がGit-Hooks を修正してたので,
自分のplatform で試してたら前に書いたところで普通にエンバグしてたので
一件修正しときました.bleis さんすんませんした.
今回は,Perl をちょっとだけ書いたので偉いと思いました.まる
あと日付が変ったけどこの日記を更新するスクリプトが動かなかったので
ライブラリを更新しました.
htmlize-region-and-browse を書く流れ
ということで,region 版を書いてみたけど,
こういうの増やすのはどうやるのが正しいのか知らないので識者に期待する流れ.
;;; htmlize (add-to-list 'load-path (expand-file-name ".emacs.d/htmlize" home)) (require 'htmlize) ;;; http://www.kanasansoft.com/weblab/2011/07/htmlize-and-browse.html (defun htmlize-region-and-browse () (interactive) (defcustom htmlize-and-browse-directory-path temporary-file-directory "htmlize-and-browse-temporary-file-directory" :type 'string :group 'htmlize-and-browse) (setq htmlize-and-browse-buffer-file-name (concat "htmlize-and-browse-" (format-time-string "%Y%m%d%H%M%S" (current-time)) ".html")) (setq htmlize-and-browse-buffer-file-path (concat htmlize-and-browse-directory-path htmlize-and-browse-buffer-file-name)) (with-current-buffer (htmlize-region (region-beginning) (region-end)) (write-file htmlize-and-browse-buffer-file-path) (set-buffer-modified-p nil) (kill-buffer htmlize-and-browse-buffer-file-name) (shell-command (concat "open " htmlize-and-browse-buffer-file-path))))
;;; htmlize(add-to-list 'load-path (expand-file-name ".emacs.d/htmlize" home))
(require 'htmlize)
;;; http://www.kanasansoft.com/weblab/2011/07/htmlize-and-browse.html
(defun htmlize-region-and-browse ()
(interactive)
(defcustom
htmlize-and-browse-directory-path temporary-file-directory
"htmlize-and-browse-temporary-file-directory"
:type 'string
:group 'htmlize-and-browse)
(setq htmlize-and-browse-buffer-file-name
(concat "htmlize-and-browse-"
(format-time-string "%Y%m%d%H%M%S" (current-time))
".html"))
(setq htmlize-and-browse-buffer-file-path
(concat htmlize-and-browse-directory-path
htmlize-and-browse-buffer-file-naame))
(with-current-buffer (htmlize-region (region-beginning) (region-end))
(write-file htmlize-and-browse-buffer-file-path)
(set-buffer-modified-p nil)
(kill-buffer htmlize-and-browse-buffer-file-name)
(shell-command (concat "open " htmlize-and-browse-buffer-file-path))))
ゆるPerl #13 にいってきた - 開発環境の話
だいたいPerl の話をしないで,Ports の話とか Android の話とかをしています.
あ,Perl6 の話とか dotcloud の話はした.か?
今回は,開発環境の開発環境として,
- Jenkins
- AsakusaSatellite
- Redmine
な環境をローカル(MacOSX) に作ろうとしてみた.
Jenkins
パッケージがあるので入れる.
restart も画面からやればいいので便利.
stop/start は,launchctl で,
$ sudo launchctl unload -w /Library/LaunchDaemon/org.jenkins-ci.plist $ sudo launchctl load -w /Library/LaunchDaemon/org.jenkins-ci.plist
とかすればいい.
Plugins
$ git clone https://github.com/suer/asakusa-satellite-plugin $ cd asakusa-satellite-plugin $ mvn package $ sudo cp target/asakusa-satellite-plugin.hpi /Users/Shared/Jenkins/Home/plugins $ sudo chown daemon /Users/Shared/Jenkins/Home/plugins/asakusa-satellite-plugin.hpi
後で増やすつもり.
AsakusaSatellite
clone してきて,指示どおりやれば動くような気がする.
そのままだとport がRedmine とぶつかるので,適当に
$ bundle exec rails server -p 3001
とかしてport を変える必要があるかも.
gem で落としてきたhaml とかの version が新しかった所為か以下のを当てないと動かなかった.
あと Gemfiles に
gem 'sass'
を書くとwarning が消えるような気がする.
なんか,websocket を起動するとCPU を食うので,
調べるまでは動かさないようにしている.
*1:最初 gem install sass とかしてたのは秘密だ
ゆるPerl #12 に行ってきた
とりあえず,lift がやりたかったので,その辺をやったりしてました.
とりあえず超初心者なりにやってみた.
Download から,落としてきて,
$ wget --no-check-certificate https://github.com/lift/lift_24_sbt/tarball/master $ tar xf lift-lift_24_sbt-7f1d566.tar.gz $ cd lift-lift_24_sbt-7f1d566/scala_29/lift_blank $ git init; git add .; git ci -m 'initial revision' $ ./sbt update $ cat <<EOF > .gitignore heredoc> /lib_managed heredoc> /project/boot heredoc> /project/build/target heredoc> /target heredoc> EOF $ git add .gitignore $ git ci -m 'ignore generated files' $ ./sbt \~jetty-run
とりあえず起動した(http://localhost:8080/)
では,Getting Start に行って試してみよう!
ふむ.index.html を書く.と
説明を読んでみよう
- content + id=main
- surround スニペット default + id=contentcomet スニペット in class: Chat < CometActor
- - ChatIn スニペット
で,View にあるスニペットとして Chat < CometActor が必要.と
Chat < CometListener (リスナー)でもあるよ.- registerWith = ChatServer - as ListerManager
- lowPriority - incoming message
- render - "li *" ClearClearable
メッセージを管理するシングルトン ChatServer < LiftActor, ListenerManager (マネージャ)もあるよ.
- lowPriority - updateListener - event to Listener
- createUpdate = msgs - to pass update event to Listener
メッセージを受けるスニペット ChatIn
(package が code.snippet だとスニペット=CoC)- render - SHtml.onSubmit - ChatServer ! s
で,sbt update \~jetty-run しろって言われる.
メソッドの話
Perl6 になって,メソッドがよくわからんくなった.
あとメタプログラミングRuby を読んで,どこにメソッドが差してあるかが
気になってきた今日このごろ.少し調べてみることにする.
class C11 { method f {say "C11"} } class C12 { method f {say "C12"} } class C21 { method f {say "C21"} } class C22 { method f {say "C22"} } class B1 is C11 is C12 { method f {say "B1"} } class B2 is C21 is C22 { method f {say "B2"} } class A is B1 is B2 { method f {say "A"} } my $obj = D.new; say $obj.WHAT; # D() say $obj.^parents(:tree).perl; # ([B1, [C11, [Any, [Mu]]], [C12, [Any, [Mu]]]], [B2, [C21, [Any, [Mu]]], [C22, [Any, [Mu]]]])
A -+- B1 -+- C11 | | | C12 | B2 -+- C21 | C22
role C11 { method f {say "C11"} } role C12 { method f {say "C12"} } role C21 { method f {say "C21"} } role C22 { method f {say "C22"} } role B1 does C11 does C12 { method f {say "B1"} } role B2 does C21 does C22 { method f {say "B2"} } class A does B1 does B2 { method f {say "A"} }
A -+- B1 -+- C11 | | | C12 | B2 -+- C21 | C22
メタプログラミングRuby 四日目を読んだ
で,
- 特異クラスは たぶん Role を差してやればいいと思う
- alias は,なんかいい方法があるんだろうか.next とか?
- my &old_name := &thermo; &thermo = sub {}; とか普通にできるみたい(S06)
# our にすれば,class スコープに augment class MyClass { our $c; method c { $c } } # 別名を付けて,上書き augment class Str { .^add_method('real_chars', &chars); method chars { .real_chars > 5 ?? 'long' !! 'short' } }
メタプログラミングRubyposted with amazlet at 11.02.20メタプログラミングRuby 三日目を読んだ
- Proc と lambda と instance_eval かな
- scope の話
さて
- block は全てがクロージャです.
- method { } で,無名メソッドが作れる
- 第一引数がオブジェクト($obj.$method と $method($obj) が同じ)
- -> でも,引数を受け取るクロージャが作れる
- AUTOLOAD が使えればもうちょっとキレイに作れるような
- set / get を使わない方向で
- :key(value) 形式は名前付きパラメータに取られてる?
- our を使わないとsubで定義したのにblock を超えられなかった.逆じゃね?
- require が .pm じゃないと駄目になってる?
- glob() がわからん.
setup method { $.set('key' => 'value'); } event "name", method { $.get('key'); };
メタプログラミングRubyposted with amazlet at 11.02.20