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

ruby来枚举csdn未注册的用户名

require 'open-uri'
$NAME_CHARS= (?a..?z).to_a+(?0..?9).to_a
def is_name_used(name)
str=open('http://passport.csdn.net/UserExist.aspx?UserName='+name)
str=str.read
#str=str.encode('GBK','utf-8')
return true if str[/Red/]
end
def enum_names(len=2)
return if len<2
f=File.open('d:\work\a.txt',"w+")
strpack="A"*len
i,v=0,""
$NAME_CHARS.permutation(len) do |x|
v=x.pack(strpack)
break if v[/^[\d]+/]
#p i+=1
f.puts "#{i+=1} : #{v}"
f.puts "#{v} is not use!" unless is_name_used(v)
end

rescue =>ex
p "err : #{ex.to_s}(#{v})"
ensure
f.close if f
end


相关文档:

Ruby声音


转 Adding Sound to Your Ruby Apps
Have you ever thought about including sounds in your Ruby application? Used sparingly, sound may enhance your applications by adding audio cues or a custom touch. You could, for example, play a beep or chime that announces the completion of a lengthy process. Per ......

ruby类变量在development模式失效

分页中用到类变量,主要是用来标记“页码输入框”的id 如果一个页面有几个分页,“页码输入框”的id要是不同的才能分清是哪个要分页。使用类变量就是为了达到这个目的,让所有的对象实例共用一个变量,不必每次重新初始化变量。 类变量使用代码示例 1 require 'ruby-debug'
2 debugger
3 cla ......

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

ruby调用平台指令删除指定文件夹

正常情况下,ruby如果发现文件夹中有system,readonly,hide类型的文件,则是不能直接删除
他们的。如何解决呢?
以其人之道还治其人之身!
def dryf(fpath) #destroy file
x = Iconv.iconv('utf-8','gbk',fpath).to_s
%x{attrib -R -S -H \"#{Iconv.iconv('gbk','utf-8',x).to_s}\"}
f = File.new(f ......

使用ruby与MS Access数据库交互

ruby常规访问access数据库的方法应该是使用DBI库

require 'dbi'

DBI.connect("DBI:ADO:Provider=Microsoft.Jet.OLEDB.4.0;Data Source=db.mdb;")

可是
简单尝试之后没能成功,提示找不到驱动器ADO,懒得再试,遂找其他方法。
一番搜索之后,发现可以用WIN32OLE来访问access,写一个简单的类包装之: ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号