介绍一种以趋势作为判断的交易手法
以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月27日星期二
2009年10月23日星期五
ufw防火墙的使用
防火墙软件 iptables 参数很多比较难用,Ubuntu下面可以用 ufw 来进行防火墙的设置,使用很简单
ufw 下面还有定义好的组合规则
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
因为有些字符需要转换才会正常显示。以下是一个网页程序用来转换。
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
i18n.rb
en.yml
zh.yml
ja.yml
框架自带的验证出错提示信息可参看这里
主要为
- 对框架返回的信息的本地化
- 对数据库表项目的本地化
- 对页面文字的本地化
以下是我的一个例子,点这里看效果
实现对 英文,中文,日文 三种语言的支持
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: "¥" 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: "¥" 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: "¥" 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;
默认是用sqlite
现在最新使用sqlite3
所以在vim配置文件 ~/.vimrc 中加入以下这行
let g:dbext_default_SQLITE_bin = 'sqlite3'
在vim中用select语句来测试
:Select * from table_name;
使用Curl来模拟发送Ajax请求
服务器是根据HTTP请求的头信息来判断是否是一个Ajax请求
以下是一个请求的头信息实例
其中最重要的是 XMLHttpRequest 信息
那么用curl工具来模拟一个Ajax请求就很简单了
那么返回的数据将是一个Javascript代码
以下是一个请求的头信息实例
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 ×</td>\n <td>\u4e0a\u6d77\u9c9c\u82b1</td>\n <td class='item-price'>¥129.00</td>\n </tr>\n <tr class='total-line'>\n <td colspan='2'>Total</td>\n <td class='total-cell'>¥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 ×</td>\\n <td>\\u4e0a\\u6d77\\u9c9c\\u82b1</td>\\n <td class=\'item-price\'>¥129.00</td>\\n </tr>\\n <tr class=\'total-line\'>\\n <td colspan=\'2\'>Total</td>\\n <td class=\'total-cell\'>¥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 }
订阅:
博文 (Atom)