我要去桂林

我要去桂林

Using pl_analyze

Posted by accesine on 2008-4-7 19:14:06 CST - 0 comments - 0 trackbacks
Installing
sudo gem install production_log_analyzer
Setup
First:

Set up SyslogLogger according to the instructions here:

seattlerb.rubyforge.org/SyslogLogger/

Then:

Set up a cronjob (or something like that) to run log files through pl_analyze.



Using pl_analyze
To run pl_analyze simply give it the name of a log file to analyze.

pl_analyze /var/log/production.log
If you want, you can run it from a cron something like this:

/usr/bin/gzip -dc /var/log/production.log.0.gz | /usr/local/bin/pl_analyze /dev/stdin
Or, have pl_analyze email you (which is preferred, because tabs get preserved):

/usr/bin/gzip -dc /var/log/production.log.0.gz | /usr/local/bin/pl_analyze /dev/stdin -e devnull@robotcoop.com -s "pl_analyze for `date -v-1d "+%D"`"
In the future, pl_analyze will be able to read from STDIN.

希望对将版本升级到 Rails 2.0 的开发人员有所帮助。

Posted by accesine on 2008-3-31 19:58:12 CST - 0 comments - 0 trackbacks
希望对将版本升级到 Rails 2.0 的开发人员有所帮助。 http://yudionrails.com/2007/12/17/rails-2-0-final-released-summary-of-features 下面是系列的列表:(按照时间排序) * ActionMailer::Base.server_settings 删减 * 1.月_份.自_现_在_起.不_再.出_错 * 源代码注释 * 如何更快捷的调用helper * 不再将乱七八糟的东西丢进您的 Environment 文件 * Rails 为我们提供 Activerecord 缓存 * 记录在Cookie上的session成为默认 * 扩展缓存应用的规模 * rhtml与rxml正慢慢的死去 * mime::type 中简便的方法 * 独特的Activerecord缓存 * 在 RESTful 路由中设定新的定界符号 * 对象的迁移 * Activesource中的 Custom method * render的使用性提升了70% * 更加灵活的 to_xml * 新的rake数据库命令 * 为您推介 validates_numericality_of * Activeresource 中的 finder升级 * has_many 与 has_one 的 RESTful 路由 * 带回性感的一面 * Fixtures 堆积 * 使用 rake 查看路由列表 * Partial 也有了 Layout * 新的 Rails 数据库接口 * Rails 日志记录变利索点儿了 * 网站签名防护的改进 * Exception Handling 的升级 * 设置插件加载顺序 * Rails Validation 现在 允许_为空 * Fixtures 变得简单了 * filters 的更新 * 为 environment.rb 前部加载“挂钩”

Ultrasphinx works on windows 的问题

Posted by accesine on 2008-3-25 7:17:38 CST - 0 comments - 0 trackbacks
RE: Ultrasphinx works on windows... [ 回复 ]

https://rubyforge.org/forum/forum.php?thread_id=20654&forum_id=14244


2008-03-08 00:49
Hi!

We just downloaded the latest version of sphinx for windows and the ultrasphinx plugin. We made the appropriate changes to reflect the windows path in the 'default.base' file (query_log, log, pid_file, and index path).

When we tried to run rake ultrasphinx:daemon:start, we received the following error:

ultrasphinx: spelling support not available (raspell configuration raised "uninitialized constant Ultrasphinx::Spell::Aspell")

Do you know we can resolve this issue? We installed Aspell from http://aspell.net/win32/.

Thanks in advance!

作者: Evan Weaver
RE: Ultrasphinx works on windows... [ 回复 ]
2008-01-12 05:43

Great.

作者: Alan T
Ultrasphinx works on windows... [ 回复 ]
2007-12-27 12:29
Just in case the question comes up, yes ultrasphinx does work on windows. The only changes to the default instructions are, for the sphinx download, download the win32 binaries option from the sphinx site and stick the 3 executables in your path. You will also need to change the paths in default.base to reflect windows directory structure.

Rails 1.2.6 慢的原因在这里

Posted by accesine on 2008-3-24 12:30:19 CST - 0 comments - 0 trackbacks
Rails 1.2.6 慢的原因在这里
http://izumi.plan99.net/blog/index.php/2008/03/18/performance-comparison-rails-126-vs-202/

I ran both applications in Mongrel (with the ‘production’ environment). The results of ‘ab -n 5000 http://localhost:3000/’ are as follows:

Rails 1.2.6: 141.19 requests/sec
Rails 2.0.2: 214.76 requests/sec
Wow, what a difference! Rails 2.0 is 50% faster in a dummy application!

In Rails 1.2, a lot of time is spent in the session store. Let’s see what happens if we specify “session :off” in both applications:

Rails 1.2.6: 189.51 requests/sec
Rails 2.0.2: 246.69 requests/sec
Wow! Even with sessions off, Rails 2.0 is still 30% faster! So the cookie session store isn’t the only thing responsible for the performance improvement!

Edge Rails has even more performance improvements. Things are definitely going the right direction.

pure ruby database 列表

Posted by accesine on 2008-1-14 13:50:42 CST - 0 comments - 0 trackbacks
add to del.icio.us   tags:  pure  ruby  database
最近需要用到 pure ruby database ,现在整理一下

纯种ruby的数据库KirbyBase

http://www.netpromi.com/kirbybase_ruby.html

KirbyBase For Ruby

中文手册的翻译进行中,已有了一定的规模

http://e2c.91yee.com/posts/show/145


RDDB is a Ruby document-oriented database system inspired by CouchDB and developed by Anthony Eden. If you're familiar with CouchDB, the whole system should make sense from the start, but if not, read on. You can create a database and insert documents in a simple enough way:

http://www.rubyinside.com/rddb-restful-ruby-document-oriented-database-643.html

遗留系统的问题 :在rails中 has_many 默认的外键名称可以指定吗?

Posted by accesine on 2007-12-1 15:01:43 CST - 0 comments - 0 trackbacks
遗留系统的问题 :在rails中 has_many 默认的外键名称可以指定吗?set_primary_key... by accesine ... 0 秒前 ... 1 次点击

has_many 在处理遗留系统的问题 set_primary_key

在rails中 has_many 默认的外键名称可以指定吗?

比如:默认的
belongs_to rogrammer # foreign key - programmer_id

我想把 programmer_id 指定成: p_id 可以吗?


class Assignment < ActiveRecord::Base
belongs_to rogrammer # foreign key - programmer_id
belongs_to roject # foreign key - project_id
end
class Programmer < ActiveRecord::Base
has_many :assignments
has_many rojects, :through => :assignments
end
class Project < ActiveRecord::Base
has_many :assignments
has_many rogrammers, :through => :assignments
end

ruby undefined method `cur_image' for

Posted by accesine on 2007-12-1 9:46:19 CST - 0 comments - 0 trackbacks
棘手的RMagick
?
传说在windows下面装RMagick会让人很抓狂
不信邪的我今天在试用RMagick也差点绝望了 在尝试这个加水印的例子的时候
总是收到这样的报错
test.rb:10:in `annotate': undefined method `cur_image' for a06.jpg JPEG 400x80 4
00x80+0+0 DirectClass 8-bit 15kb:Magick::Image (NoMethodError)
? ? ? ?from test.rb:10

惯例Google,查到几条相关信息
1.在用Magick::Image.read('xxx.jpg')的时候 返回可能是个数组,传给annotate的时候要传Image类型
所以不行 ?不过我已经用.first拿Image对象了 所以没有这个问题

2.RMagick 在windows上最新的版本是06年11月28号发布的 ?版本号1.14.1 binary gem for Ruby
1.8.5 ,跟最新上两个礼拜发布的2.0.0 beta2已经差了很久了..

3.去论坛看为啥没有最新的windows版本跟上 作者回答是 I don't have a Windows PC so the
RMagick Windows gems are built by volunteers. The previous volunteer
doesn't have time to do another build. If you know of somebody who
could step up to the task please ask them to email me.

4.我忍无可忍给作者发了封mail拜托他把头文件发给我 我想尝试编译自救

5.无意中在这篇文章的最后找到问题的根源 原来是我的gem太新了 以前就听说gem 0.9.4 问题多多 没想到真的会这么麻烦
?
最后我把gem从0.9.4"更新"到0.9.2 搞定了...


?

根据imagemagick和一些网站的资料,总结了常用的加水印(特别是中文)的代码

Posted by accesine on 2007-11-29 22:10:16 CST - 0 comments - 0 trackbacks
根据imagemagick和一些网站的资料,总结了常用的加水印(特别是中文)的代码。

require 'rubygems'
require 'RMagick'

#在图片中嵌入中文文字

ruby 代码
def t1

img=Magick::Image.read('path\read_image1.jpg').first #图片路径,用相对路径即可,相对于public来说的
my_text="\251 这是黑马的标致"
copyright=Magick::Draw.new
copyright.annotate(img,0,0,3,18,my_text) do #可设字的位置
self.gravity = Magick::CenterGravity
self.font='public\images\simsun.ttc' #这地方必须使用中文字库,才能打中文到图片上。在windows中c:\windows\fonts\simsun.ttc拷到项目的public\images目录下就可以随着项目使用了。另外注意:笔者是使用utf-8字符集来编辑源文件的,如果你不是,请在程序中对汉字转换编码为utf-8
self.pointsize=96 #字体大小
self.font_weight=Magick::BoldWeight
self.fill='red' #字的颜色
self.gravity=Magick::SouthEastGravity
self.stroke = "none"
end
img=img.raise #浮雕效果
img.write('path\img')

end

#加图片和中文水印文字

ruby 代码
def test_photo

img=Magick::Image.read('public\photo\big_image\1\1119218437.jpg').first
img2=Magick::Image.read('public\photo\big_image\2\DSCN4991-thumb.jpg').first #版权图片
my_text="\251 黑马的标致"
img.composite!(img2, -0,-0, Magick::CopyCompositeOp) #图片叠加 ,CopyCompositeOp是composite的运算之一,还有很多运算方法,实现各种效果,可以在官网找到 http://www.imagemagick.org/RMagick/doc/constants.html#CompositeOperator
copyright=Magick::Draw.new
copyright.annotate(img,0,0,3,18,my_text) do #可设字的位置
self.gravity = Magick::CenterGravity
self.font='public\images\simsun.ttc'
self.pointsize=96 #字体大小
self.font_weight=Magick::BoldWeight
self.fill='red' #字的颜色
self.gravity=Magick::SouthEastGravity
self.stroke = "none"
end
img=img.raise #浮雕效果
mark.rotate!(-90) #可旋转
img = img.watermark(mark, 0.15, 0, Magick::EastGravity) #0.15是透明度
img.write('public\photo\big_image\1\1119218437-image1_bak.jpg')
end

RMagick是 ImageMagick

Posted by accesine on 2007-11-29 22:08:01 CST - 0 comments - 0 trackbacks
Ruby Rmagick 的安装与测试


RMagick是 ImageMagick?& GraphicsMagick 影象处理程式库的 Ruby 版界面, 很方便使用,功能也强,让我们试试看吧。
安装以Window平台为例:
首先到这个地方去下载RMagick的最新Windows版本,到目前为止的最新版本是rmagick-win32-1.13.0_IM-6.2.9-3.zip。
先解压,然后在解压目录下输入命令安装:

gem install rmagick-1.13.0-win32.gem

然后再点ImageMagick-6.2.9-3-Q8-windows-dll.exe安装,并且把这个的安装路径放到path环境变量里面去,否则会出现CORE_RL_magick_.dll找不到的错误,即下面的错误:

下面我们来看一个缩略图的例子a.rb:

require 'RMagick'
include Magick
pic = ImageList.new("vd2.png")
l = pic.columns > pic.rows ? pic.columns : pic.rows
f = 128.0/l;
thumb = pic.thumbnail(f)
thumb.write("vd2_tb.png")

放一张vd2.png的图片在同一目录下,运行ruby a.rb即可看到缩略图了哈。
例子还有很多,可以参考官方网站:
影像大小转换, 裁剪, 合成,Sample
影像特效, Sample
提供画图的功能, Sample
还有绘制向量图功能, Sample


Rails的安装命令:gem install rails -v 1.1.6 -r -y
Faster_csv的安装命令:gem i fastercsv

script和rule engine,在ruby中该怎么处理呢?

Posted by accesine on 2007-11-29 7:51:48 CST - 0 comments - 0 trackbacks
script和rule engine,在ruby中该怎么处理呢?
http://www.talios.com/a_ruby_rule_engine.htm

http://rubyforge.org/projects/ruby-rules/

http://www.dzone.com/links/rss/ruleby_a_pure_ruby_rule_engine.html

http://rools.rubyforge.org/


java 上我用过:http://labs.jboss.com/drools/

Drools is a business rule management system (BRMS) and an enhanced Rules Engine implementation, ReteOO, based on Charles Forgy's Rete algorithm tailored for the Java language. More importantly, Drools provides for Declarative Programming and is flexible enough to match the semantics of your problem domain with Domain Specific Languages, graphical editing tools, web based tools and developer productivity tools.
Purple theme designed by Livid, this blog is proudly powered by Project Nexus.