显示标签为“ruby”的博文。显示所有博文
显示标签为“ruby”的博文。显示所有博文

星期四, 八月 23, 2007

ruby lesson2

File.open("s1.txt") do |filed|
while lined = filed.gets
fh = File.new("out.txt", "a") #是追加
if lined=~/^>/
fh.puts lined
else
require 'watir'
include Watir

ie = Watir::IE.new
ie.goto("http://www.imtech.res.in/raghava/eslpred/submit.html")
ie.text_field(:name, "seq").set(lined)
ie.button(:value, "Submit sequence").click

aFile = File.new("lei.htm" , "w")
aFile << ie.html
aFile.close
ie.close
#2
File.open("lei.htm") do |file|
while line = file.gets
if line=~/Reliability Index|Expected Accuracy/

line=line.gsub(/
  • |\ \;|<\/B><\/LI><\/UL><\/FONT><\/TD><\/TR>|<\/B>/,'')
    fh.puts line

    end
    end
    end
    end
    end
    end
  • 星期三, 八月 22, 2007

    MYSQL远程连接问题

    MYSQL远程连接问题
    GRANT ALL PRIVILEGES ON *.* TO 用户名@"%" IDENTIFIED BY '密码' WITH GRANT OPTION;

    %表示所有。也可以限制成:10.10.10.10 (IP)

    星期一, 八月 20, 2007

    FireWatir,可以控制浏览器,包括输入东西超级简单,强大!支持linux, Mac machine,windows

    http://code.google.com/p/firewatir/downloads/list
    所有文件都在上面:
    Installation guide for FireWatir:
    1.Install JSSh XPI using following steps:
    firefox 插件,用firefox打开就可以了。
    2.gem install firewatir.gem


    命令:
    require 'firewatir'
    include FireWatir

    ff = Firefox.new
    ff.goto 'www.google.com'
    ff.text_field(:name, 'q').set('keyword')
    ff.button(:name, 'btnG').click

    语法:
    http://wtr.rubyforge.org/watir_user_guide.html

    星期日, 八月 05, 2007

    ruby rails 开发环境搭建

    1.安装ruby,ruby -v
    ruby 1.8.6 (2007-03-13 patchlevel 0) [i386-mswin32]

    2.gem 安装rail: gem install rails --remote
    Bulk updating Gem source index for: http://gems.rubyforge.org
    Install required dependency activesupport? [Yn] y
    Install required dependency activerecord? [Yn] y
    Install required dependency actionpack? [Yn] y
    Install required dependency actionmailer? [Yn] y
    Install required dependency actionwebservice? [Yn] y
    Successfully installed rails-1.2.3
    ....

    3.MySQL Server and MySQL Clinet:
    MySQL:
    http://dev.mysql.com/downloads/mysql/5.0.html#downloads
    不需要选择,Congfigure the MySQL Sever now

    MySQl Clinet:
    http://dev.mysql.com/downloads/gui-tools/5.0.html

    星期一, 七月 30, 2007

    UltraEdit for ruby

    UltraEdit for ruby
    1.高级》工具栏配置》
    命令行:C:\ruby\bin\ruby.exe -w "%f"
    工作目录:%p
    菜单项名称:Ruby
    选取“输出到列表窗口” 和“捕捉输出” 单击“插入”再”确定“

    3.从此地址ftp://www.ultraedit.com/wf/ruby.txt下载ruby语法文件。

    4、修改UltraEdit根目录下的wordfile.txt文件,将上面下载过来的ruby.txt里的内容加裁到wordfile.txt末尾。

    5、修改wordfile.txt文件,查找HTML位置,将RHTML加到HTML位置的后面,就可以支持.rhtml高亮显示。

    OK,所有步骤已经全部完成,如果您也是RUBY爱好者不防也试试。

    星期日, 七月 22, 2007

    get_response

    require 'net/https'
    response = Net::HTTP.get_response('http://www.sina.com.cn','index.html')
    puts response.body

    ruby抱错了:
    c:/ruby/lib/ruby/1.8/net/http.rb:560:in `initialize': getaddrinfo: no address as
    sociated with hostname. (SocketError)
    from c:/ruby/lib/ruby/1.8/net/http.rb:560:in `open'
    from c:/ruby/lib/ruby/1.8/net/http.rb:560:in `connect'
    from c:/ruby/lib/ruby/1.8/timeout.rb:48:in `timeout'
    from c:/ruby/lib/ruby/1.8/timeout.rb:76:in `timeout'
    from c:/ruby/lib/ruby/1.8/net/http.rb:560:in `connect'
    from c:/ruby/lib/ruby/1.8/net/http.rb:553:in `do_start'
    from c:/ruby/lib/ruby/1.8/net/http.rb:542:in `start'
    from c:/ruby/lib/ruby/1.8/net/http.rb:374:in `get_response'
    from D:/my ruby/get.rb:3


    不需要http://否则会出错的!

    response = Net::HTTP.get_response('www.sina.com.cn','index.html')
    这样就可以了。