hSATAC

>> ('cat' + 'ash').reverse #=> "hsatac"

Redmine + Bundler 復活記

老實說,不記得之前是動了什麼,總之我的佈署 apache + passenger + ree 環境
redmine 爆炸了。推測應該是 gem 的關係。
上網看了一下, rails 2.3 只支援 rubygems 1.7
就先把 rubygems downgrade 回來

gem update --system 1.7

和 tkalu, xdite, ihower, 以及小蟹詢問了各種可能的解決方案後
確定我應該是要用 bundler 來管理一下 redmine 的 gems

根據 ihower 提供的資訊, redmine 有一個內建 bundler 的 fork 版
搜尋了一下找到了 https://www.chiliproject.org/
把他的 Gemfile 借過來一用

再按照 Bundler 官網上的 Rails 2 教學 來設定,果然成功把我的 redmine 救了回來!

chiliproject 的 Gemfile 可能要稍加修改,例如他用 rails 2.3.14,可以改成 redmine 官網支援的 2.3.11
然後一些沒用到的 gem 例如 pg 可以移除。

Rake 0.9 爆炸解法

由於 rake 0.9 跟之前的不相容,因此裝了以後大概都會碰到這堆錯誤:

/Users/cat/.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2/lib/rake/version.rb:4: warning: already initialized constant MAJOR
/Users/cat/.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2/lib/rake/version.rb:5: warning: already initialized constant MINOR
/Users/cat/.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2/lib/rake/version.rb:6: warning: already initialized constant BUILD
/Users/cat/.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2/lib/rake/version.rb:3: warning: already initialized constant NUMBERS
/Users/cat/.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2/lib/rake/version.rb:9: warning: already initialized constant VERSION
/Users/cat/.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2/lib/rake.rb:26: warning: already initialized constant RAKEVERSION
/Users/cat/.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2/lib/rake/early_time.rb:17: warning: already initialized constant EARLY
/Users/cat/.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2/lib/rake/alt_system.rb:32: warning: already initialized constant WINDOWS
/Users/cat/.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2/lib/rake/application.rb:28: warning: already initialized constant DEFAULT_RAKEFILES
WARNING: Possible conflict with Rake extension: String#ext already exists
WARNING: Possible conflict with Rake extension: String#pathmap already exists
/Users/cat/.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2/lib/rake/task_arguments.rb:73: warning: already initialized constant EMPTY_TASK_ARGS
/Users/cat/.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2/lib/rake/invocation_chain.rb:49: warning: already initialized constant EMPTY
/Users/cat/.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2/lib/rake/file_utils.rb:10: warning: already initialized constant RUBY
/Users/cat/.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2/lib/rake/file_utils.rb:84: warning: already initialized constant LN_SUPPORTED
/Users/cat/.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2/lib/rake/dsl_definition.rb:143: warning: already initialized constant Commands
/Users/cat/.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2/lib/rake/file_list.rb:44: warning: already initialized constant ARRAY_METHODS
/Users/cat/.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2/lib/rake/file_list.rb:47: warning: already initialized constant MUST_DEFINE
/Users/cat/.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2/lib/rake/file_list.rb:51: warning: already initialized constant MUST_NOT_DEFINE
/Users/cat/.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2/lib/rake/file_list.rb:55: warning: already initialized constant SPECIAL_RETURN
/Users/cat/.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2/lib/rake/file_list.rb:61: warning: already initialized constant DELEGATING_METHODS
/Users/cat/.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2/lib/rake/file_list.rb:364: warning: already initialized constant DEFAULT_IGNORE_PATTERNS
/Users/cat/.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2/lib/rake/file_list.rb:370: warning: already initialized constant DEFAULT_IGNORE_PROCS
/Users/cat/.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2/lib/rake.rb:64: warning: already initialized constant FileList
/Users/cat/.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2/lib/rake.rb:65: warning: already initialized constant RakeFileUtils
rake aborted!
stack level too deep

(See full trace by running task with –trace)

CloudAAA 雲端大亂鬥簡記

這次 CloudAAA 活動是由 CloudTWTaipei-GTUG 合辦
借到了精誠資訊的大樓,相當棒的一個場地。
不得不稱讚主辦單位,一進來打開電腦四個 AP 速度又快,足顯誠意
食物飲水也很精美充足,真的是沒什麼好挑剔的。

一開始 Hank Lin 主講 aws 的部份
Hank 一開場就直接嗆「aws feature 比微軟和 google 多的多」
因為我本身對 aws 比較沒有深入研究
加上 Hank 講得實在是有點快
只略約有印象好像介紹了一些 Route 53 的新特色
還有 Oracle 的部份可以用自己的 license ,沒有的話可以用租的
然後買他的書
(認識的要買可以找我,打6折)

讓 Empathy 支援 P4-Context

這兩天灌了 Ubuntu 11.04 在玩
內建的 Empathy 即時通訊軟體很強大,整合了多種 im
但是他的 msn 不支援 msn protocol 的 P4-Context tag
最直接的影響就是 m群看不到是誰在說話。
看了一下發現他底層是用 python-papyon 這套 msn lib
於是就可以直接動手修改啦!

先開啟 /usr/share/pyshared/papyon/conversation.py
找到 387 行:

        if message_type == 'text/plain':
            msg = ConversationMessage(unicode(message.body, message_encoding),
                    TextFormat.parse(message_formatting),
                    self.__last_received_msn_objects)
            try:
                display_name = message.get_header('P4-Context')

Better Array, Better PHP

PHP 的 array() 大家都是詬病已久了,總是在想,要是能像其他語言一樣,用個中括號括起來就好那該有多好。

Firefox4 X WebM X Apache

今天在弄一些 WebM 的東西,同樣的頁面和影像檔在 chrome 都很正常,但是碰到 firefox 4 就會爛掉,可是 firefox 4 明明就支援 WebM 了啊

 

後來做了幾個實驗,直接用 file:/// 開檔案,居然就正常了! 但放到伺服器上,又出了問題。

survey 了一下,果然是 apache 處理 WebM 時 mimetype 沒有正確送出。

只要修改 /etc/apache2/mime.types 把 WebM 加進去就可以了

video/webm webm
至於 chrome 為什麼會正常,只能猜測 chrome 有特別針對這個問題做優化吧…

有沒有 chrome 偷偷對 WebM mimetype 做優化都不告訴別人的八卦?

整合 Redmine 和 Git

其實就是[專案設定] > [版本控管] 裡面填 git repo path 而已
不過一直報找不到專案,看了一下 error log 原來是找不到 git 執行檔
解法很簡單,原本 httpd.conf 設定的 ruby 要再包一層去 export path
例如原本你設定的是

PassengerRuby /usr/local/Cellar/ruby-enterprise-edition/2011.03/bin/ruby

就開一個 /usr/local/bin/ruby_with_env 的可執行檔
裡面把 export $PATH

#!/bin/bash
export PATH="/usr/local/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/X11/bin:/opt/local/bin:/usr/local/git/bin:/usr/local/git/bin/:$PATH"
/usr/local/Cellar/ruby-enterprise-edition/2011.03/bin/ruby $*

再把 httpd.conf 的裡面設定的 ruby 改成

PassengerRuby /usr/local/bin/ruby_with_env

大功告成!

How to Enable Php Gmp on Mac OS X Without Macports

If you are using macports, you can easily install the package of “php-gmp”.

But if you are a user of homebrew like me, you may need these tips.

First, you have to install gmp via homebrew, but it will give you gmp 5.0.1, which doesn’t work with PHP 5.3

So you have to modify your Formula, go to /usr/local/Library/Formula/gmp.rb and modify:

url 'ftp://ftp.gnu.org/gnu/gmp/gmp-5.0.1.tar.bz2'
sha1 '6340edc7ceb95f9015a758c7c0d196eb0f441d49'
to
url 'ftp://ftp.gmplib.org/pub/gmp-4.3.2/gmp-4.3.2.tar.bz2'
sha1 'c011e8feaf1bb89158bd55eaabd7ef8fdd101a2c'

Now, you can run

brew install gmp
to install gmp.

Next step, download the php source code from php.net, we will need to build a php_gmp.so module from it.

Extract the source code and go to phpsource/ext/gmp/

run

phpize
./configure
MACOSX_DEPLOYMENT_TARGET=10.6 CFLAGS='-O3 -fno-common -arch i386 -arch x86_64' LDFLAGS='-O3 -arch i386 -arch x86_64' CXXFLAGS='-O3 -fno-common -arch i386 -arch x86_64' make -j6;sudo make install

And you will get your gmp.so in phpsource/ext/gmp/module/

Copy that to your /usr/lib/php/extensions/no-debug-non-zts-20090626/

And load it in your /private/etc/php.ini

It’s done!