1.ruby
http://www.ruby-doc.org/core/
代理访问:http://anonymouse.org/cgi-bin/anon-www.cgi/http://www.ruby-doc.org/core/
http://www.ruby-doc.org/stdlib/
2.rmagick
http://studio.imagemagick.org/RMagick/doc/index.html
3.gemjack.com集合的大多数rdoc(推荐!)
http://gemjack.com/
mysql和oracle存储图片文件都是用blob类型,但是ruby怎么处理的呢?
ruby还是把它当作字符串,但是要经过加工.
我们完全可以使用rmagick这个图形库来进行.
代码:
require 'rubygems'
require_gem 'rmagick'
include Magick
DBI.connect('DBI:Mysql:test_dbo:192.168.0.164', 'mysql', '') { |dbh|
dbh.execute 'SET NAMES utf8'
1.upto(13) { |i|
str = "insert into users(name, pwd, img) values(?,?,?)"
dbh.prepare(str) { |st|
jpg = Image.read('1.jpg').first
st.execute('a', 'b', jpg.to_blob)
}
}
}
如果从数据库反响出来,也类似(from_blob方法)
首先创建表,我们这里默认编码utf8:
create table samples (
id int not null auto_increment,
foo varchar(100) not null,
bar text not null,
primary key (id)
) Type=MyISAM CHARACTER SET utf8;
这里创建表类型时要使用MyISAM类型,因为只有MyISAM类型才支持完整的utf8.最后设置编码utf8.
1.dbi操作数据库
如果你本地编码时gbk的话,首先要默认类Iconv进行转换.
require 'iconv'
def gb2u str
conv = Iconv.new("UTF-8", "GBK")
str = conv.iconv(str)
str << conv.iconv(nil)
conv.close
str
end
插入代码:
DBI.connect('DBI:Mysql:test:localhost', 'mysql', '') { |dbh|
dbh.execute 'SET NAMES utf8' #这里要指明代码
1.upto(13) { |i|
st.execute("insert into samples(foo, bar) values('#{gb2u('一')}#{i}', '#{gb2u('二')}')")
}
}
2.activerecord
activerecord是对dbi的包装.(也更神,呵呵!)
代码:
require 'rubygems'
require_gem 'activerecord' #因为我是gem的安装
ActiveRecord::Base.establish_connection(
:adapter => "mysql",
:host => "localhost",
:database => "test",
:username => "mysql",
:password => "",
:encoding => "utf8") #编码只需这里指明
#指明表
class Mytab < ActiveRecord::Base
set_table_name 'samples'
end
#插入数据
tab = Mytab.new
tab.foo= gb2u('一')
tab.bar = gb2u('二')
tab.save
#查询数据
data = Mytab.find(:all)
data.each { |line|
puts "['#{line[:id]}', '#{line[:foo]}, '#{line[:bar]}]"
}
看rrobots的一个简单的例子:
----------------------- code -----------------------
require 'robot'
class NervousDuck
include Robot
def tick events
turn_radar 1 if time == 0
turn_gun 30 if time < 3
accelerate 1
turn 2
fire 3 unless events['robot_scanned'].empty?
end
end
----------------------- code -----------------------
这里至少要实现tick方法.
下面是控制robot的一些方法和属性:
battlefield_height #the height of the battlefield
battlefield_width #the width of the battlefield
energy #your remaining energy (if this drops below 0 you are dead)
gun_heading #the heading of your gun, 0 pointing east, 90 pointing
#north, 180 pointing west, 270 pointing south
gun_heat #your gun heat, if this is above 0 you can't shoot
heading #your robots heading, 0 pointing east, 90 pointing north,
#180 pointing west, 270 pointing south
size #your robots radius, if x <= size you hit the left wall
radar_heading #the heading of your radar, 0 pointing east,
#90 pointing north, 180 pointing west, 270 pointing south
time #ticks since match start
speed #your speed (-8/8)
x #your x coordinate, 0...battlefield_width
y #your y coordinate, 0...battlefield_height
accelerate(param) #accelerate (max speed is 8, max accelerate is 1/-1,
#negativ speed means moving backwards)
stop #accelerates negativ if moving forward (and vice versa),
#may take 8 ticks to stop (and you have to call it every tick)
fire(power) #fires a bullet in the direction of your gun,
#power is 0.1 - 3, this power will heat your gun
turn(degrees) #turns the robot (and the gun and the radar),
#max 10 degrees per tick
turn_gun(degrees) #turns the gun (and the radar), max 30 degrees per tick
turn_radar(degrees) #turns the radar, max 60 degrees per tick
dead #true if you are dead
say(msg) #shows msg above the robot on screen
broadcast(msg) #broadcasts msg to all bots (they recieve 'broadcasts'
#events with the msg and rough direction)
首先要设置返回头jsp页面:response.setContentType("text/xml");
var node=xmlHttpReq.responseXML.documentElement.childNodes;
document.write("当前在线人数" +node.item(0).textContent+"人");
for(obj_key in node.item(0)){
alert(obj_key);
}这个方法知道的textContent这个方法的
兼容微软Office的办公软件OpenOffice,可用于文档处理,电子表格和幻灯片制作;类似于Outlook,集成邮件、联系人、日程和任务管理等强大功能的 Evolution;GGV和XCHM分别用于查看PDF和CHM文档;Smart-Storage让U盘、移动硬 盘、读卡器、 MP3、MP4、数码相机及刻录机的使用变得异常简单;英汉词典 Stardict;压缩与归档工具File-Roller;Planner和Dia分别用于项目管理和流程 图制作。
以安全轻便著称的Firefox浏览器,支持多页面浏览、屏蔽弹出式窗口和网页字体放大;类似于Foxmail,可用于收发邮件、新闻组及RSS的 Thunderbird;支持 ICQ、Yahoo、MSN、IRC、Jabber等协议的即时通讯软件Gaim;用于视频对话的 Gnomemeeting;支持断点续传的D4X;用于BT下载的Gnome-BT;可实现网络IP电话的Linphone;用于远程桌面控制和诊断的 Tsclient。
类似于Photoshop的强大图像处理工具Gimp;类似于Coreldraw或Illustrator的矢量处理软件Inkscape;类似于 Pagemaker的排版软件Scribus;类似于3D Max的三维设计软件Blender;类似于Acdsee的图片管理软件Gthumb、F-Spot;Xsane扫描软 件简单易用。
超能媒体播放器Totem,支持目前流行的大多数影音格式和在线播放;用于抓取CD 音轨的Sound-Juicer;用于组织和管理大量数码音乐的 Rhythmbox;类似于Winamp 的MP3播放软件bmp;简洁的电视播放器Tvtime;高品质的录音软件;各种趣味盎然 的游戏软件。
1。gem query --remote # shortcut: gem q -R
#列出所有包
2。gem query --remote --name-matches doom
# shortcut: gem q -R -n doom
#列出所有名字匹配的包
3。gem install --remote progressbar
# shortcut: gem i -r progressbar
#安装指定名字的包。
gem ins -r progressbar --version '> 0.0.1' #这里可以匹配版本
4。gem specification progressbar
# shortcut: gem spec progressbar
#查看安装过的指定包详细信息
5。gem uninstall progressbar
#卸载包
6。gem query --local
# shortcut: 'gem q -L'
#列出所有本地安装过的包
7。gem ins rake
#在本地安装,如果没有远程安装
8。gem list -b ^C
#列出所有以C开头的包
9。gem_server
开启rdoc服务。可以查看安装包的rdoc
这里现在xunleibho_v14.dll
命令行输入:regsvr32 xunleibho_v14.dll
#mdconfig -a -t vnode -f abc.iso -u 1
#mount_cd9660 /dev/md0 /mnt