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