To get it done is not easy. I spent a whole day to figure out the various compatibility issues along the way out.
Now there still might be potential issues, but it works by my rough test.
Step 1: Install Apache Cassandra
You may know that the Ruby gem cassandra will do it for you.
To me, I simply want to keep Cassandra independent from Ruby stuff, to ease the upgrade and administration.
Refer to my blog "Setup Cassandra on Windows"
(http://blog.csdn.net/goodxp/archive/2010/02/26/5327732.aspx) for details.
Step 2: Install Thrift (0.2.0)
If you do "gem install cassandra", it should install thrift automatically (being a dependency).
However, there is a compatibility issue on thrift with Ruby 1.9, so to fail Cassandra gem installation.
It will be better to install thrift first and fix it before installing cassandra gem.
Refer to my blog "fix thrift 0.2.0 installation with ruby 1.9.1"
&nb ......
ѧÁËÒ»¸öѧÆÚµÄCÓïÑÔ£¬¿´ÁËÒ»¸öÐÇÆÚµÄruby£¬ÎҲŷ¢ÏÖΪʲôÀÏʦ˵CÊÇ×î»ù´¡µÄ£¬¼ÙÈçûÓÐÒ»¸öѧÆÚµÄC»ù´¡£¬ÄÇrubyÎÒÒ²²»Óÿ´ÁË¡£
RubyºÍCÓïÑÔÓÐÐí¶àµÄÏàͬµãºÍ²»Í¬µã£¬ÔÚѧϰrubyʱ£¬ÓÐʱ¿ÉÒÔÓÃCÀïÃæµÄ˼άÀ´Àí½â£¬¾ÍÏñrubyÀïÃæµÄ·½·¨Æäʵ¾Í¸úCµÄº¯ÊýÈç³öÒ»ÕÞ£»ruby±ÈCʹÓÃʱËæÒâµÄ¶à£¬ÔÚCÀïÉùÃ÷±äÁ¿»¹ÒªÇó±äÁ¿ÀàÐÍ£¬¶ørubyÈ´²»ÓÃÌØÒâÈ¥ÉùÃ÷ÀàÐÍ£¬Ö±½ÓÓþͺ㻶ø¶ÔÓÚÊäÈ룬CÒ²Òª·ÖÊäÈëµÄÀàÐÍ£¬rubyÈ´²»Óã¬Ö±½ÓÓÃÒ»¸ögets¾Í¿ÉÒÔ£¬¶øÇÒ½«¶ÁÈëµÄÎı¾±£´æÔÚÔ¤¶¨Òå±äÁ¿$_ÖУ¬È»ºóÓÃchompɾ³ýĩβµÄ»»Ðзû£¬¶øCÓõÄÊÇgets½ÓÊÕ»»Ðзû£»¶ÔÓÚ¶à¸öµ¥´ÊµÄ±äÁ¿Ãû£¬rubyµÄÏ°¹ßÊÇÓÃÏ»®·Ö¸ôµ¥´Ê£¬¶øCÈ¥ÊÇÏ°¹ßÓôóСдÀ´Çø·Ö²»Í¬µÄµ¥´Ê£»rubyÓÃdo…endÀ´½ç¶¨¿é£¬¶øCÓõÄÊÇ{}£¬ËäÈ»rubyÒ²¿ÉÒÔÓÃ{}£¬µ«{}Ö»ÄÜ°üº¬µ¥ÐдúÂë¿é£¬¶ødo…end°üº¬¶àÐдúÂë¿é……µÈµÈ¡£ÎÒ·¢ÏֵĽö½öÊÇƤ룬ÓÐʲô´íÎóÏ£Íû´ó¼ÒÖ¸³öÀ´£¬¸ú¶àµÄ»¹ÒªµÈ´ó¼ÒÀ´Ì½Ë÷£¬Ï໥½è¼øÏ໥½ø²½¡£
»¹ÓÐÒ»¸ö¾ÍÊÇÔÚ°²×°railsʱµÄÎÊÌ⣬ÎÒÀÏÊÇ×°²»ºÃ£¬×îºóÔÚн¨ÏîÄ¿ÊÇ·¢ÏÖÀïÃæÌáʾ»¹Ã»×°rails£¬È»ºóÎҾ͵ã»÷°²×°¾ÍºÃÁË£¬²» ......
The following is improved version of the code created by David Mullet, from
http://rubyonwindows.blogspot.com/2007/03/ruby-ado-and-sqlserver.html
require 'win32ole'
class SqlServer
# This class manages database connection and queries
attr_accessor :connection, :data, :fields
attr_writer :username, :password
def initialize(host, username = 'sa', password='')
@connection = nil
@data = nil
@host = host
@username = username
@password = password
end
def open(database)
# Open ADO connection to the SQL Server database
connection_string = "Provider=SQLOLEDB.1;"
connection_string << "Persist Security Info=False;"
connection_string << "User ID=#{@username};"
connection_string << "password=#{@password};"
connection_string << "Initial Catalog=#{database};"
connection_string << "Data Source=#{@host};"
connection_string << "Network Libra ......
The following is improved version of the code created by David Mullet, from
http://rubyonwindows.blogspot.com/2007/03/ruby-ado-and-sqlserver.html
require 'win32ole'
class SqlServer
# This class manages database connection and queries
attr_accessor :connection, :data, :fields
attr_writer :username, :password
def initialize(host, username = 'sa', password='')
@connection = nil
@data = nil
@host = host
@username = username
@password = password
end
def open(database)
# Open ADO connection to the SQL Server database
connection_string = "Provider=SQLOLEDB.1;"
connection_string << "Persist Security Info=False;"
connection_string << "User ID=#{@username};"
connection_string << "password=#{@password};"
connection_string << "Initial Catalog=#{database};"
connection_string << "Data Source=#{@host};"
connection_string << "Network Libra ......
×î½üÓÉÓÚѧϰʹÓÃlinuxϵÄC¿ª·¢£¬ÐèÒª²éѯLinux Cº¯Êý²Î¿¼£¬¾Í¾³£ÉÏhttp://man.chinaunix.net/develop/c&c++/linux_c/default.htm²é¿´£¬ÃèÊöµÃ±È½ÏÏêϸ¶øÇÒ»¹ÓÐÀý×Ó¡£
ÍøÉÏ»¹ÓÐÐí¶à¸÷ÖÖ¼¼ÊõµÄÍøÒ³¸ñʽµÄ²Î¿¼²ÄÁ϶¼·Ç³£Ç¿´ó£¬¿ÉϧºÜ¶àʱºò¶¼Ã»ÓÐÍø¡£ÓÚÊǾÍÏëд¸ö½Å±¾¿ÉÒÔ°ÑÎĵµÏÂÔØ£¬Ïñandroid¿ª·¢ÕßÎĵµÒ»ÑùŪµ½±¾µØÀ´£¬ÓÃÆðÀ´¾Í·½±ã¶àÁË£¬ÒªÊÇÓÃCHM¹¤¾ß´ò³Échm¸ñʽ¾Í¸üºÃÁË¡£
ÓÚÊǾͶ¯ÊÖÓÃrubyдÁËÕâô¸ö½Å±¾£¬°ÑÍøÒ³¶ÁÈ¡ÏÂÀ´£¬±£´æµ½±¾µØ£¬Í¬Ê±ÏÂÔØÍøÒ³ÖеÄÑùʽ¡¢JSÎļþÒÔ¼°Í¼Æ¬µÈÎļþ£¬²¢Ìæ»»ÏàÓ¦µÄÁ´½Ó£¬¾¡Á¿±£³ÖÍøÒ³µÄЧ¹û¡£Õû¸ö³ÌÐò´óÔ¼300ÐУ¬³¢ÊÔµØץȡÁ˼¸¸öÍøÕ¾¶¼Í¦ºÃ£¬±£ÁôÁËÑùʽ¡¢³¬Á´½ÓÉõÖÁ²¿·ÖµÄJS¡£³ý´ËÖ®Í⣬Ëü»¹ÄÜÏÞÖÆÏÂÔØÎļþµÄÀàÐͺʹóС£¬¿ÉÒÔ……
µ±È»,bug»¹ºÜ¶à£¬¶øÇÒÍøÒ³µÄHTMLÄÚÈݹýÓÚÁé»îºÍ¸´ÔÓ£¬ºÜ¶à¶«Î÷¸ãÏÂÀ´¿ÉÄܾÍÃæÄ¿È«·ÇÁË£¬ÕæÕýҪдһ¸öºÃµÄparser¹ûÈ»ÊÇÏ൱¸´ÔÓ- -!
ÏÂÃæÊÇ´úÂëµÄ×¢ÊÍ£¬ÍêÕûÎļþ¿ÉÔÚ´ËÏÂÔØ¡£
#¶¨ÒåÒ»¸öÄ£¿é,´òÓ¡ÈÕÖ¾
module Log
def Log.i(msg)
print "[INFO]#{msg}\n"
end
def Log.e(msg)
print "[ERROR]#{msg}\n"
end
end
#¶¨ÒåÒ»¸öÀ࣬ÓÃÓ ......
ÀúÊ·±³¾°£Û1£Ý
µ®ÉúÓÚ1993Äê2ÔÂ24ÈÕµÄRuby(ºì±¦Ê¯)£¬ÓÉÈÕ±¾ÈËËɱ¾Ðк루Yuki Matsumoto£©ÓÚ1994Äê12Ô·¢²¼¡£ Ruby ×÷ΪһÖÖ´¿ÃæÏò¶ÔÏóµÄ½Å±¾³ÌÐòÉè¼ÆÓïÑÔ£¬ÎüÊÕÁËSmalltalkºÍPerlÁ½ÖÖ³ÌÐòÓïÑÔµÄÌØÐÔ¡£
RubyÀíÄî£Û2£Ý
1.Ê×ÏÈ¿¼ÂǵÄÊÇ£¬¼õÉÙ±à³Ìʱ²»±ØÒªµÄËöËéʱ¼ä£¬Áî±àд³ÌÐòµÄÈ˸ßÐË£»
2.Æä´ÎÊÇÁ¼ºÃµÄ½çÃæÉè¼Æ£»
3.Ç¿µ÷ϵͳÉè¼Æ±ØÐëÈËÐÔ»¯£¬¶ø²»ÊÇһζ´Ó»úÆ÷µÄ½Ç¶ÈÉèÏë¡£
LinuxÖа²×°Ruby£Û3£Ý
ÒÀÀµÓÚÄúËùʹÓõÄLinux·¢Ðа汾£¬ÓÐһЩ°²×°RubyµÄ·½·¨¡£Ê×Ñ¡·½·¨ÊǼòµ¥µØÏÂÔØÔ´´úÂë²¢Ç××Ô±àÒë¡£¶øÔÚһЩ²Ù×÷ϵͳƽ̨ÖУ¬Óð²×°°ü¹ÜÀí½â¾ö·½·¨£¬¿ÉÒÔ¼«Æä¼òµ¥µØ°²×°Ruby¡£
ÀýÈ磬ÔÚDebian»òUbuntuÖÐapt-get¹¤¾ßÌṩÁËÒ»ÖÖ¼òÒ׶øÓÅÃÀµÄ½â¾ö·½°¸£º
% sudo apt-get install ruby1.9.1-full
ÉÏÊöÃüÁî°²×°Ä¿Ç°Îȶ¨µÄRuby°æ±¾1.9.1¡£Èç¹ûÄúϲ»¶°²×°Ruby1.8°æ±¾£¬Äú¿ÉÒÔʹÓÃÒÔÏÂÃüÁî°²×°£º
% sudo apt-get install ruby-full
³ÌÐòʾÀý
#!/usr/bin/env ruby
# hello.ry
puts "Hello, world!"
¶ËÖÐÊäÈëÒÔÏÂÃüÁ
$chmod a+x hello.ry
$hello.ry
½á¹ûÊä³öÏÔʾÊÇ£º
Hello, world!
×ÊÔ´
Ruby¹Ù·½Íø£ºhttp://www.ruby-lang.org/en/
RubyÕýÌåÖÐÎÄÍø£ºhttp:// ......
ÁùÖÖÓÃrubyµ÷ÓÃÖ´ÐÐshellÃüÁîµÄ·½·¨
Åöµ½ÐèÒªµ÷ÓòÙ×÷ϵͳshellÃüÁîµÄʱºò£¬RubyΪÎÒÃÇÌṩÁËÁùÖÖÍê³ÉÈÎÎñµÄ·½·¨£º
1.Exec·½·¨:
Kernel#exec·½·¨Í¨¹ýµ÷ÓÃÖ¸¶¨µÄÃüÁîÈ¡´úµ±Ç°½ø³Ì£º
Àý×Ó£º
$ irb
>> exec 'echo "hello $HOSTNAME"'
hello nate.local
$
ÖµµÃ×¢ÒâµÄÊÇ£¬exec·½·¨ÓÃechoÃüÁîÀ´È¡´úÁËirb½ø³Ì´Ó¶øÍ˳öÁËirb¡£Ö÷ÒªµÄȱµãÊÇ£¬ÄãÎÞ·¨´ÓÄãµÄruby½Å±¾ÀïÖªµÀÕâ¸öÃüÁîÊdzɹ¦»¹ÊÇʧ°Ü¡£
2.System·½·¨¡£
Kernel#system·½·¨²Ù×÷ÃüÁîͬÉÏ£¬ µ«ÊÇËüÊÇÔËÐÐÒ»¸ö×ÓshellÀ´±ÜÃ⸲¸Çµ±Ç°½ø³Ì¡£Èç¹ûÃüÁîÖ´Ðгɹ¦Ôò·µ»Øtrue£¬·ñÔò·µ»Øfalse¡£
$ irb
>> system 'echo "hello $HOSTNAME"'
hello nate.local
=> true
>> system 'false'
=> false
>> puts $?
256
= ......