Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

Fix Thrift 0.2.0 Installation with Ruby 1.9.1

When I try the command "gem install thrift" with Ruby 1.9.1, I got a compilation error with something related to a C function "strlcpy()".
Then I searched the web. It seems I am not alone and the community know it.
However I do not want to wait for official update, I want to try Cassandra and Thrift is a dependency I have to use now.
So, read on if you want a dirty fix.
Start command line console and run:
  $ gem install thrift
If you got the error with "strlcpy", you should have thrift code downloaded in your ruby gems folder.
It is "C:\Ruby\lib\ruby\gems\1.9.1\gems\thrift-0.2.0" for my computer on Windows.
  $ cd C:\Ruby\lib\ruby\gems\1.9.1\gems\thrift-0.2.0\ext
If you are using linux, check the lib/.../ext folder.
Open "extconf.rb" and "struct.c" with a text editor. Comment out HAVE_STRLCPY in "struct.c" like this:
  /*
    #ifndef HAVE_STRLCPY
      static
      size_t
      strlcpy (char *dst, const char *src, size_t dst_sz)
      { ...
      }
    #endif
  */
 
Comment out have_func line in "extconf.rb" like this:
  # have_func("strlcpy", "string.h")
 
Then run:
  $ cd C:\Ruby\lib\ruby\gems\1.9.1\gems\thrift-0.2.0
  $ ruby setup.rb
  $ gem spec C:\Ruby\lib\ruby\gems\1.9.1\cache\thrift-0.2.0.gem --ruby > \
    C:\Ruby\lib\ruby\gems\1.9.1\specifications\thrift-0.2.0.gemspec
  $ gem list
You should see "thrift (0.2.0)" is in your local installed gem list.


Ïà¹ØÎĵµ£º

Ruby ShoesµÄСÎÊÌâ

½ñÌì°ÑRuby Shoes´ò°üµÄ³ÌÐò¸´ÖƵ½Ã»Óа²×°Ruby ShoesµÄ»úÆ÷ÉÏ£¬·¢ÏÖËü»¹Ï²»ÁËRuby ShoesµÄ»·¾³°ü¡£
ÕâÈÃÎҸоõºÜ¾ÚÉ¥£¬ºÃ²»ÈÝÒ×ÈëÃÅÁËÒ»ÃÅÓïÑÔ£¬È´ÓöÉÏÁËÎÞ·¨²¿ÊðµÄÎÊÌâ¡£
ÉõÖÁ£¬ÎÒºóÀ´ÏëÒª°ÑÔËÐл·¾³Ç¶Èëµ½Ruby ShoesÖУ¬¶¼Ã»Äܹ»×öµ½¡£
ÕâÑùµÄÎÊÌâÕæÊÇÈÃÎҸоõµ½¶ÔShoesµÄʧÍû¡£
²»¹ý»¹ºÃ£¬³öÁËRuby Shoes£¬»¹Óкܶ ......

ruby Ï̵߳ÄÐÔÄܲâÊÔ

ÔÚʹÓÃÖÐrubyµÄ¹ý³ÌÖÐÄÑÃâ»áÓöµ½Ìá¸ßÐÔÄܵÄÎÊÌ⣬Óɴ˱ãÏëÆðÁËrubyÏ̡߳£µ«ÊÇÎÒÔÚʹÓÃÖÐÈ´·¢ÏÖrubyµÄÏß³ÌÈ´²»ÄÜÌá¸ßÐÔÄÜ¡£ÎÒдÁËÒÔÏ´úÂ룬×öÁËЩ¼òµ¥²âÊÔ¡£
´úÂë
# -*- coding: GB2312 -*-
require 'date'
# ʹÓÃỊ̈߳¬Ï̵߳Ĵ¦Àí´úÂëÀïûÓÐsleep
def have_thread_no_sleep
p Time.now
thread1 = Thread.new do
......

½»»¥Ê½ Ruby Shell irb

irb ÊÇ´ÓÃüÁîÐÐÔËÐеÄ
irb µÄÃüÁîÐÐÑ¡Ïժ×Ô¡¡Porgramming Ruby µÚ¶þ°æ£©
-f
½ûÖ¹¶ÁÈ¡~/.irbrc¡¡Suppress reading ~/.irbrc.
-m
Êýѧģʽ£¨Ö§³Ö·ÖÊýºÍ¾ØÕ󣩡¡Math mode (fraction and matrix support is available).
-d
ÉèÖÃ#DEBUGΪtrue(ͬruby -dÒ»Ñù)¡¡¡¡Set $DEBUG to true (same as ``ruby -d'').
-r lo ......

Rubyѧϰ±Ê¼Ç¶þ——Êý×é

#Ò»¡¢Êý×éÒýÓÃ
arr=[3,4,5,6,7,8,9]
puts arr[0] #3
puts arr.first #3
puts arr[arr.length-1] #9
puts arr[arr.size-1] #9
puts arr.last #9
puts arr[-1] #9
puts arr[-2] #8
print arr[1..3] ,"\n" #456
print arr[-3,4] ,"\n" #789£¬´Ó-3¿ªÊ¼ £¬´òÓ¡4¸öÔªËØ£¬ÕâÀïÖ»ÓÐÈý¸ö
#RubyµÄÊý×é´óСÊǶ¯Ì¬µÄ£¬ÄãÄܹ» ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ