#CC=cc
PROC=${ORACLE_HOME}/bin/proc
PROC_INCLUDES=\
include=$(ORACLE_HOME)/precomp/public \
include=$(ORACLE_HOME)/rdbms/public \
include=$(ORACLE_HOME)/plsql/public \
include=$(ORACLE_HOME)/network/public
PROCFLAGS=code=ansi_c \
lines=yes \
parse=full \
char_map=string \
dbms=V8 \
unsafe_null=yes \
$(PROC_INCLUDES)
CFLAGS=-O4 -trigraphs -g -Wall -D DEBUG\
-I$(ORACLE_HOME)/precomp/public \
-I$(ORACLE_HOME)/rdbms/public \
-I$(ORACLE_HOME)/plsql/public \
-I$(ORACLE_HOME)/network/public
LDFLAGS=-L${ORACLE_HOME}/lib -lclntsh
TARGET=yumlog
OBJECTS=main.o insert.o
.SUFFIXES: .pc .c .o
all: ${OBJECTS}
${CC} ${CFLAGS} ${LDFLAGS} ${OBJECTS} -o ${TARGET}
.c.o:
${CC} ${CFLAGS} -c $<
.pc.c:
${PROC} ${PROCFLAGS} $<
clean:
rm -rf main.o insert.o insert.c yumlog tp* insert.lis
2010年5月27日星期四
Makefile的例子
Makefile的例子
2010年5月21日星期五
Set utf8 for all MySQL encoding
[mysqld]
#
# * Using utf8 for all encoding
#
default-character-set=utf8
skip-character-set-client-handshake
# end add by yz_wang
#
# * Using utf8 for all encoding
#
default-character-set=utf8
skip-character-set-client-handshake
# end add by yz_wang
2010年5月12日星期三
关于Rails程序安全性
问题
默热情况下ActiveRecord允许访问者更新所有字段,以及子表字段。
这就让系统中的敏感字段暴露在外。
ActiveRecord里面提供了一下两个函数来声明可以改变的字段。
attr_accessible attr_protected
但是在实际使用中,极为不便,因为
ActiveRecord.new
ActiveRecord.update_attributes
的方法将无法正常使用
当然你可以为每个属性赋值,但这个不是聪明的做法。
问题所在不是出现在ActiveRecord上面。
而是应该在ActiveController上屏蔽一些敏感Parameter
寻找良久,以下这个Plugin应该是一个最为完善的解决方案吧。
据说这个是从Merb里面研究出来的,我想Rails3可能会有直接支持吧。
http://github.com/cjbottaro/param_protected
参看以下链接
http://railspikes.com/2008/9/22/is-your-rails-application-safe-from-mass-assignment
安全检查工具
http://thinkrelevance.com/blog/2008/02/26/tarantula-vs-your-rails-app.html
默热情况下ActiveRecord允许访问者更新所有字段,以及子表字段。
这就让系统中的敏感字段暴露在外。
ActiveRecord里面提供了一下两个函数来声明可以改变的字段。
attr_accessible attr_protected
但是在实际使用中,极为不便,因为
ActiveRecord.new
ActiveRecord.update_attributes
的方法将无法正常使用
当然你可以为每个属性赋值,但这个不是聪明的做法。
问题所在不是出现在ActiveRecord上面。
而是应该在ActiveController上屏蔽一些敏感Parameter
寻找良久,以下这个Plugin应该是一个最为完善的解决方案吧。
据说这个是从Merb里面研究出来的,我想Rails3可能会有直接支持吧。
http://github.com/cjbottaro/param_protected
参看以下链接
http://railspikes.com/2008/9/22/is-your-rails-application-safe-from-mass-assignment
安全检查工具
http://thinkrelevance.com/blog/2008/02/26/tarantula-vs-your-rails-app.html
2010年2月22日星期一
Railsエラーメッセージ日本語化(参考)
(省略)
errors:
messages:
inclusion: "は一覧にありません。"
exclusion: "は予約されています。"
invalid: "が不正な値です。"
confirmation: "が一致しません。"
accepted: "を承諾してください。"
empty: "が記入されていません。"
blank: "が記入されていません。"
too_long: "は{{count}}文字以内で記入してください。"
too_short: "は{{count}}文字以上で記入してください。"
wrong_length: "は{{count}}文字で記入してください。"
taken: "はすでに使用されています。"
not_a_number: "は数値で入力してください。"
greater_than: "は{{count}}より大きい値を指定してください。"
greater_than_or_equal_to: "は{{count}}以上の値を指定してください。"
equal_to: "は{{count}}を指定してください。"
less_than: "は{{count}}より小さい値を指定してください。"
less_than_or_equal_to: "は{{count}}以下の値を指定してください。"
odd: "は奇数を指定してください。"
even: "は偶数を指定してください。"
# Append your own errors here or at the model/attributes scope.
models:
# Overrides default messages
attributes:
# Overrides model and default messages.
2009年11月17日星期二
ubuntuでRails環境を設定
sudo apt-get udpate
sudo gem update --system
sudo gem update --no-ri --no-rdoc
sudo gem install rails haml --no-ri --no-rdoc
vim-rails設定
sudo apt-get install vim-rails
vim-rails-setup
sudo gem update --system
sudo gem update --no-ri --no-rdoc
sudo gem install rails haml --no-ri --no-rdoc
vim-rails設定
sudo apt-get install vim-rails
vim-rails-setup
2009年10月23日星期五
如何在网页中显示网页代码
这篇博客里面常常要显示网页代码,直接复制到这里是不行的。
因为有些字符需要转换才会正常显示。以下是一个网页程序用来转换。
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 }
2008年7月25日星期五
Fedora9下 phpBB3的安装
Fedora9下共享论坛软件phpBB3之安装步骤
系统环境
Fedora9默认安装
yum install httpd
yum install mysql-server
下载phpBB3软件:phpBB-3.0.2.zip
su - # 切换到root
cd /var/www
unzip /to/file/path/phpBB-3.0.2.zip # 生成phpBB3目录
chown -R apache. /phpBB3 #目录所有者改为apache所有
chcon -t httpd_sys_script_rw_t phpBB3/config.php # SeLinux设定,让config.php可写
编辑phpb设定
vi /etc/httpd/conf.d/phpbb.conf
服务自启动设定
chkconfig httpd on
chkconfig mysqld on
系统环境
Fedora9默认安装
- 安装php,php-mysql, php-mbstring, php-gd, ImageMagic
- 安装以及设置www服务器软件 apache
- 安装MySql服务器
- 安装phpbb软件
- 设置apache服务器
yum install httpd
yum install mysql-server
下载phpBB3软件:phpBB-3.0.2.zip
su - # 切换到root
cd /var/www
unzip /to/file/path/phpBB-3.0.2.zip # 生成phpBB3目录
chown -R apache. /phpBB3 #目录所有者改为apache所有
chcon -t httpd_sys_script_rw_t phpBB3/config.php # SeLinux设定,让config.php可写
编辑phpb设定
vi /etc/httpd/conf.d/phpbb.conf
Alias /phpbb "/var/www/phpBB3" # 可通过http://localhost/phpbb 访问
<directory>
Options Indexes MultiViews
AllowOverride None
Order allow,deny
Allow from all
</directory>
服务自启动设定
chkconfig httpd on
chkconfig mysqld on
订阅:
博文 (Atom)
