2009年11月4日星期三

加山雄三 永遠の若大将 歌と共に おやじバンド結成、毎月演奏

いのち果てるまで
========

「次の曲は『旅人よ』。ご存じの方は、どうぞ一緒に歌ってください。僕を初めて見る外国の方にも、日本では有名な歌手なのだなと思ってもらえるでしょうからね」
2005年10月、米ニューヨークのカーネギーホール大ホールでデビュー45周年コンサートを開いた。客席には日本人の姿も多い。歌の合間は英語で話していたが、ここだけは日本語で。演出の石田弘さんのアイデアだった。
「草は枯れても いのち果てるまで 君よ 夢をこころに 若き旅人よ」。期待以上のものすごい大合唱が巻き起こり、会場にいたみんなの心を揺さぶった。石田さんは涙でぐちゃぐちゃになっている。僕らに対して横柄で冷たかったホールの職員たちまで涙、涙・・・・・・。僕には歌がある。歌い続けてきてよかった。
「加山さん、エレキ引いてくださいよ」。ザ・ワイルドワンズの島英二君にそう言われたのが1994年のこと。あれほど好きだったエレキギターなのに、僕は70年の倒産騒ぎのころに放り出して、ずっと倉庫に捨て置いていた。
ワイルドワンズは後輩の加瀬邦彦君が60年代に結成した僕の弟分で、「思い出の渚」が有名だ。バンド名は僕がつけた。「どんな意味です?」「自然児だよ」 「修善寺ですか」。そんな連中である。
「こんなに錆びちゃって、ひどいや」。島君は僕のギターに新しい弦を張り、アンプにつないだ。ああ、懐かしい音がする。「エレキの若大将」の日々がよみがえった。
「よし、メンバーを集めよう」。僕や島君を含めて7人編成のおやじバンド、ハイパーランチャーズを結成。加瀬君の経営するライブハウス「ケネディハウス銀座」で毎月演奏するようになった。おかげで錆びついていたギターの腕もずいぶん回復した。
06年3月には東京文化会館大ホールで公演した。ポップス系の音楽家がこのステージに立つのは僕が初めてだそうだ。大本直人さん指揮、千住明さん編曲という恵まれた環境で歌った。長女が生まれた時に作った弦楽合奏のためのロンド「真悠子」では指揮棒も振った。あれは緊張した。
連載の前半に「音楽は趣味」と書いた。仕事と考えると楽しみが失われるから、あえて「趣味」と言わせてもらっている。思えば、僕は多趣味な人間だ。船やスキーだけでなく、近年は油彩や水彩画、陶芸にも熱中している。59歳で初めて開いた個展は13回を数え、西伊豆に自分の釜も開いた。鉄道模型やテレビゲームもかなりのマニアだ。
72歳になっても、「永遠の若大将」のイメージが強すぎて、俳優としてはマイナスになった面もあるだろうが、音楽家としてはまったく逆である。多くの人々と共有した夢の世界が「若大将」で、僕の音楽はそこに誘う呪文のようなものかもしれない。
今は「湘南 海 物語 オヤジ達の伝説」と題して、ワイルドワンズと一緒に各地でコンサートを開いている。「夜空の星」や「君と何時までも」を歌えば、お客さんも僕自身も「若大将」の時代にひとっ飛び。心から「幸せだなあ」といえる瞬間だ。
来年はデビュー50周年を迎える。生涯現役でやっていくため、酒もたばこもやめた。僕は歌いたい。夢をこころに、いつまでも。

2009年10月27日星期二

FlatTrend指标的解读

介绍一种以趋势作为判断的交易手法

以4种颜色代表
Red, Salmon, LimeGreen, LightGreen
红, 弱红, 绿, 弱绿

红色表示卖
绿色表示买
弱,表示强度低一级

--------------------------------------------
算法:
--------------------------------------------

主要指标参看:
1.抛物线状止损和反转指标(SAR)
2.平均方向性运动指标 (ADX)

正: SAR值 > CLOSE值
+ADX > -ADX 时强度为2
+ADX < -ADX 时强度为1

负: SAR值 < CLOSE值
+ADX > -ADX 时强度为1
+ADX < -ADX 时强度为2

2009年10月23日星期五

ufw防火墙的使用

防火墙软件 iptables 参数很多比较难用,Ubuntu下面可以用 ufw 来进行防火墙的设置,使用很简单

sudo ufw enable  # 启用ufw防火墙
sudo ufw disable # 关闭ufw防火墙

sudo ufw allow 22 # 打开SSH端口
sudo ufw allow 89 # 打开WWW端口

sudo ufw delete allow 22 # 把打开的22端口设置删除

ufw 下面还有定义好的组合规则
sudo ufw app list # 参看组合规则列表
sudo ufw app info Apache # 参看Apache规则的说明
sudo ufw allow Apache # 启用Apache规则
sudo ufw delete allow Apache # 删除Apache规则
sudo ufw allow "Apache Full" # 打开HTTP, HTTPS运用

ufw 可以使用更多参数
sudo ufw allow from 192.168.0.0/24 to any app Samba # 打开本地网络的Samba运用
sudo ufw delete allow from 192.168.0.0/24 to any app Samba # 关闭本地网络的Samba运用

sudo ufw status # 显示设置的规则列表

如何在网页中显示网页代码

这篇博客里面常常要显示网页代码,直接复制到这里是不行的。
因为有些字符需要转换才会正常显示。以下是一个网页程序用来转换。

http://blogtool.flatlabs.net/source.html

<pre>
你的代码
</pre>

Rails本地化

Rails2.3加入了I18n,已经能够很好的支持本地化(Locale)了
主要为
  • 对框架返回的信息的本地化
  • 对数据库表项目的本地化
  • 对页面文字的本地化

以下是我的一个例子,点这里看效果

实现对 英文,中文,日文 三种语言的支持

RAILS_ROOT/app/controller/application_controller.rb
RAILS_ROOT/config/initializers/i18n.rb
RAILS_ROOT/coonfig/locales/en.yml
RAILS_ROOT/coonfig/locales/zh.yml
RAILS_ROOT/coonfig/locales/ja.yml

application_controller.rb
# 为本地化处理加一个过滤器
class ApplicationController < ActionController::Base
  before_filter :set_locale

protected
  def set_locale
    session[:locale] = params[:locale] if params[:locale]
    I18n.locale = session[:locale] || I18n.default_locale
  end
end

i18n.rb
I18n.default_locale = 'en'

LOCALES_DIRECTORY = "#{RAILS_ROOT}/config/locales/"

LANGUAGES = {
  'English' => 'en',
  '中文' => 'zh',
  '日本語' => 'ja'
}

en.yml
en:
  number:
    currency:
      format:
        unit: "&yen;" 
  
  layout:
    title: "Xi-yang-yang Wedding Garden"
    side:
      home: "Home"
      faq:  "Questions"
      news: "News"
      contact: "Contact"
    cart:
      title: "Your Cart"
      total: "Total"
      checkout: "Checkout"
      empty_cart: "Empty Cart" 

zh.yml
zh:
  number:
    currency:
      format:
        unit: "&yen;"
        precision: 2
        separator: "."
        delimiter: ","
        format: "%u%n"

  activerecord:
    errors:
      # The values :model, :attribute and :value are always available for interpolation
      # The value :count is available when applicable. Can be used for pluralization.
      messages:
        inclusion: "必须是表内的值" #is not included in the list
        exclusion: "保留" # is reserved"
        invalid: "无效" # "is invalid"
        confirmation: "与确认值不一致" # "doesn't match confirmation"
        accepted: "必须被接受" # "must be accepted"
        empty: "不能为空" # "can't be empty"
        blank: "不能为空白" # "can't be blank"
        too_long: "超长(最長{{count}})" # "is too long (maximum is {{count}} characters)"
        too_short: "超短(最短{{count}})" # "is too short (minimum is {{count}} characters)"
        wrong_length: "长度不对(字数必须为{{count}})" # "is the wrong length (should be {{count}} characters)"
        taken: "该值已经存在" # "has already been taken"
        not_a_number: "不是数字" # "is not a number"
        greater_than: "必须大于{{count}}" # "must be greater than {{count}}"
        greater_than_or_equal_to: "不得小于{{count}}" # "must be greater than or equal to {{count}}"
        equal_to: "必须等于{{count}}" # "must be equal to {{count}}"
        less_than: "必须小于{{count}}" # "must be less than {{count}}"
        less_than_or_equal_to: "不得大于{{count}}" # "must be less than or equal to {{count}}"
        odd: "必须为奇数" # "must be odd"
        even: "必须为偶数" # "must be even"
        record_invalid: "验证失败: {{errors}}" # "Validation failed: {{errors}}"
      template:
        header:
          one: "1个错误发生导致处理失败" # "1 error prohibited this {{model}} from being saved"
          other: "{{count}}个错误发生导致处理失败" # "{{count}} errors prohibited this {{model}} from being saved"
        body: "以下的项目出错" # "There were problems with the following fields:" 

    model:
      order: "订购"
    attributes:
      order:
        name: "姓名"
        address: "地址"
        email: "E-mail"
        pay_type: "付款方式" 

  layout:
    title: "喜洋洋婚庆花苑"
    side:
      home: "主页"
      faq:  "常见问题"
      news: "新信息"
      contact: "联系"
    cart:
      title: "你的购物车"
      total: "合计"
      checkout: "购买"
      empty_cart: "清空购物车"
 

ja.yml
ja:
  number:
    currency:
      format:
        unit: "&yen;"
        precision: 2
        separator: "."
        delimiter: ","
        format: "%u%n"

  activerecord:
    errors:
      # The values :model, :attribute and :value are always available for interpolation
      # The value :count is available when applicable. Can be used for pluralization.
      messages:
        inclusion: "リストには含まれていません" #is not included in the list
        exclusion: "保留" # is reserved"
        invalid: "無効です" # "is invalid"
        confirmation: "一致していません" # "doesn't match confirmation"
        accepted: "設定しないとなりません" # "must be accepted"
        empty: "空にしてはいけません" # "can't be empty"
        blank: "空白にしてはいけません" # "can't be blank"
        too_long: "長すぎ(最長{{count}}桁数)" # "is too long (maximum is {{count}} characters)"
        too_short: "短すぎ(最短{{count}}桁数)" # "is too short (minimum is {{count}} characters)"
        wrong_length: "桁数が不正({{count}}桁数)" # "is the wrong length (should be {{count}} characters)"
        taken: "もう設定されていました" # "has already been taken"
        not_a_number: "数字ではありません" # "is not a number"
        greater_than: "{{count}}より大きくしないといけません" # "must be greater than {{count}}"
        greater_than_or_equal_to: "{{count}}以上にしないといけません" # "must be greater than or equal to {{count}}"
        equal_to: "{{count}}ではないといけません" # "must be equal to {{count}}"
        less_than: "{{count}}より小さくしないといけません" # "must be less than {{count}}"
        less_than_or_equal_to: "{{count}}以下にしないといけません" # "must be less than or equal to {{count}}"
        odd: "奇数にしないといけません" # "must be odd"
        even: "偶数にないといけません" # "must be even"
        record_invalid: "検証失敗: {{errors}}" # "Validation failed: {{errors}}"
      template:
        header:
          one: "1個のエラーが発生したため処理が失敗しました" # "1 error prohibited this {{model}} from being saved"
          other: "{{count}}個のエラーが発生したため処理が失敗しました" # "{{count}} errors prohibited this {{model}} from being saved"
        body: "以下のフィールドにエラーが発生しました" # "There were problems with the following fields:" 
    model:
      order: "注文"
    attributes:
      order:
        name: "名前"
        address: "住所"
        email: "E-mail"
        pay_type: "支払方法" 

  layout:
    title: "喜洋々ウエディングガーデン"
    side:
      home: "ホーム"
      faq:  "よくある質問"
      news: "ニュース"
      contact: "お問い合わせ"
    cart:
      title: "あなたのカート"
      total: "合計"
      checkout: "チェックアウト"
      empty_cart: "カートをクリア" 


框架自带的验证出错提示信息可参看这里

2009年10月22日星期四

使用vim插件dbext来查询sqlite数据库时的设置

vim插件dbext可以在vim中使用数据查询

默认是用sqlite
现在最新使用sqlite3

所以在vim配置文件 ~/.vimrc 中加入以下这行

let g:dbext_default_SQLITE_bin = 'sqlite3'

在vim中用select语句来测试
:Select * from table_name;

使用Curl来模拟发送Ajax请求

服务器是根据HTTP请求的头信息来判断是否是一个Ajax请求
以下是一个请求的头信息实例

Accept: text/javascript , text/html, application/xml, text/xml, */*
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: close
X-Requested-With: XMLHttpRequest
X-Prototype-Version: 1.5.0_rc0
Content-Type: application/x-www-form-urlencoded

其中最重要的是 XMLHttpRequest 信息
那么用curl工具来模拟一个Ajax请求就很简单了

curl -H "X-Requested-With: XMLHttpRequest" http://ryan.heroku.com/store/add_to_cart/2


那么返回的数据将是一个Javascript代码

try {
$$("div#notice").each(function(value, index) {
value.hide();
});
Element.update("cart", "<div class='cart-title'>Your Shopping Cart</div>\n<table>\n  <tr id='current_item'>\n    <td>1 &times;</td>\n    <td>\u4e0a\u6d77\u9c9c\u82b1</td>\n    <td class='item-price'>&yen;129.00</td>\n  </tr>\n  <tr class='total-line'>\n    <td colspan='2'>Total</td>\n    <td class='total-cell'>&yen;129.00</td>\n  </tr>\n</table>\n<form method=\"post\" action=\"/store/checkout\" class=\"button-to\"><div><input type=\"submit\" value=\"Checkout\" /><input name=\"authenticity_token\" type=\"hidden\" value=\"78brTTCuEhmyuLasMW/Q0GtgyzwGpfl4Fr8k1WLQFNU=\" /></div></form>\n<form method=\"post\" action=\"/store/empty_cart\" class=\"button-to\"><div><input type=\"submit\" value=\"Empty cart\" /><input name=\"authenticity_token\" type=\"hidden\" value=\"78brTTCuEhmyuLasMW/Q0GtgyzwGpfl4Fr8k1WLQFNU=\" /></div></form>\n");
$("cart").visualEffect("blind_down");
$("current_item").visualEffect("highlight", {"startcolor":"#88ff88","endcolor":"#114411"});
} catch (e) { alert('RJS error:\n\n' + e.toString()); alert('$$(\"div#notice\").each(function(value, index) {\nvalue.hide();\n});\nElement.update(\"cart\", \"<div class=\'cart-title\'>Your Shopping Cart</div>\\n<table>\\n  <tr id=\'current_item\'>\\n    <td>1 &times;</td>\\n    <td>\\u4e0a\\u6d77\\u9c9c\\u82b1</td>\\n    <td class=\'item-price\'>&yen;129.00</td>\\n  </tr>\\n  <tr class=\'total-line\'>\\n    <td colspan=\'2\'>Total</td>\\n    <td class=\'total-cell\'>&yen;129.00</td>\\n  </tr>\\n</table>\\n<form method=\\\"post\\\" action=\\\"/store/checkout\\\" class=\\\"button-to\\\"><div><input type=\\\"submit\\\" value=\\\"Checkout\\\" /><input name=\\\"authenticity_token\\\" type=\\\"hidden\\\" value=\\\"78brTTCuEhmyuLasMW/Q0GtgyzwGpfl4Fr8k1WLQFNU=\\\" /></div></form>\\n<form method=\\\"post\\\" action=\\\"/store/empty_cart\\\" class=\\\"button-to\\\"><div><input type=\\\"submit\\\" value=\\\"Empty cart\\\" /><input name=\\\"authenticity_token\\\" type=\\\"hidden\\\" value=\\\"78brTTCuEhmyuLasMW/Q0GtgyzwGpfl4Fr8k1WLQFNU=\\\" /></div></form>\\n\");\n$(\"cart\").visualEffect(\"blind_down\");\n$(\"current_item\").visualEffect(\"highlight\", {\"startcolor\":\"#88ff88\",\"endcolor\":\"#114411\"});'); throw e }