易截截图软件、单文件、免安装、纯绿色、仅160KB

ruby和MinGW的一次融合

我们在使用C编程时会遇到一个问题,比如头文件的一个函数包含在一个lib中,但是
在实际连接中我们不知道它在哪个库中。也许可行的一种办法是直接上网查询某个
函数的依赖条件,这对于常用函数是没问题的!但是对于复杂而又缺少文档的第三方
lib来说,无异于大海捞针。
自此通过2种办法来尝试解决这个问题,我们先看第一种:
在Windows下使用批处理语言来查找指定的函数符号:
crt.bat:
@echo off
set gccpath=d:\downloadsvr\mingwstudio\mingw
dir %gccpath%\lib /b>files.txt
if not exist files md files
for /f %%i in (files.txt) DO (
    set fprefix=%%i
    %gccpath%\bin\nm.exe -s -D %gccpath%\lib\%%i>files\%%i.txt
    for %%a in (files\%%i.txt) do (
        if %%~za equ 0 del %%a
    )
)
del files.txt
@echo ######## Create Names Database Successed!!! #########
pause
;#################################################################
fnd.bat:
@echo off
dir files\ /b >tmp.txt
for /f %%i in (tmp.txt) DO (
    find /i /n "%1" files\%%i
)
del tmp.txt
以上有2个bat文件,crt.bat是生成对应lib文件夹中的所有lib的符号,分别放在若干个文本
文件中。只要lib不发生变动,那么只要生成一次即可!然后使用fnd.bat来查询某个符号。
that's all!!!
那么使用ruby能否完成这一功能呢?答案是肯定的:
class LibSyms
attr_accessor :libs

def save_syms(fname="cache_syms.dat")
data = Marshal.dump(@syms)
File.open(fname,"w+b") {|f|f.puts data}
end

def load_syms(fname="cache_syms.dat")
data=nil
File.open(fname,"r+b"){|f|data=f.read}
@syms=Marshal.load(data)
end

def enum_syms
@syms={}
@libs = []
`dir \"#{@path}\\lib\" /b`.lines {|line|@libs<<@path+"\\lib\\"+line.chomp}

@libs.each do |fname|
tmp=`\"#{@path}\\bin\\nm.exe\" -s -D \"#{fname}\"`.split("\n")
@syms[fname]=tmp
end
end

def initial


相关文档:

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 ......

Install Cassandra with Ruby 1.9.1 on Windows

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.
  ......

学ruby有感(by 王瀚)

    学了一个学期的C语言,看了一个星期的ruby,我才发现为什么老师说C是最基础的,假如没有一个学期的C基础,那ruby我也不用看了。
        Ruby和C语言有许多的相同点和不同点,在学习ruby时,有时可以用C里面的思维来理解,就像ruby里面的方法其实就跟C的函数如出一 ......

Ruby watir 测试框架

转自 http://www.advidea.cn/biancheng/200943135232.html 
Ruby watir 测试框架
大多数人都会安装 ruby,
也通过Ruby 安装 gem,
也安装了ruby IDE开发工具:netbeans,
但就是不能跑watir环境,狂晕加吐中。。。
错误如下:
in `require': no such file to load -- watir (LoadError)
反正就是找不到watir,这里 ......

ruby的类与模块(1)

class Point
@x = 1
@y = 2
def initialize(x,y)
@x,@y = x,y
end
end 
代码中的@x,@y为实例变量,实例变量只对self的环境起作用,因此initialize外面的@x=1,@y=2只对类本身起作用,而方法内部,的@x,@y是对对象的实例起作用的。
class Point
include Enumerable
def initialize(x ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号