易截截图软件、单文件、免安装、纯绿色、仅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初探

从今天起不再浪费时间,开始走向自动化测试这条光明的道路,并以搭建一个自动化测试平台为目标,并这个过程一点点的记录下来和大家分享
首先,是ruby环境的搭建
(1)到ruby的官网:http://www.ruby-lang.org/en/下载 ruby安装程序;
      PS :选择 ruby on windows,我下载的是Ruby 1.8.6 One ......

Ruby 命令行 常用命令

从命令行启动Ruby解释器时,你不仅可以提供程序文件的名字,而且可以提供一个或多个命令行开关。你选择的开关指示解释器以一种特定的方式运转,并且/或者执行特定的操作。
Ruby命令行开关有20多个,其中有些很少使用,有些则每天被很多Ruby程序员使用。在这里我们将再看几个最常用的。(你已经看到过其中的两个,-c和&ndas ......

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的数组大小是动态的,你能够 ......

转载——Ruby字符串处理

转自:http://developer.51cto.com/art/200912/170762.htm 
Ruby字符串处理函数总结列表分享
Ruby字符串处理函数包括返回字符串长度函数;判断字符串中是否包含另一个串函数;字符串插入;字符串分隔,默认分隔符为空格等等。
 
str.length => integer 
str.include? other_str
&nbs ......

phpRPC + Ruby + Arduino = 远程控制

phpRPC + Ruby + Arduino = 遠程控制LED開關(?)
嗯,我知道這是個很無聊的Sample :P
關於phpRPC與Arduino請自行Google
觀看此demo之前請先安裝另外一篇所提到的serialport
與另外一個Gem
套件:phprpc
在這個ļ ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号