-
判断一组数字是否是Pythagorean Triple/Quadruple
所属栏目:[百科] 日期:2020-12-17 热度:105
今天PHP站长网 52php.cn把收集自互联网的代码分享给大家,仅供参考。 def isPyTri?(a,b,c) if (a**2 + b**2 == c**2) return true else return false end enddef isPyQuad?(a,c,d) if(a**2 + b**2 + c**2 == d**2) return[详细]
-
Ruby 在 Windows 下读取键盘输入
所属栏目:[百科] 日期:2020-12-17 热度:109
今天PHP站长网 52php.cn把收集自互联网的代码分享给大家,仅供参考。 require 'Win32API'def getch @getch ||= Win32API.new('crtdll','_getch',[],'L') @getch.callendwhile (c = getch) != ?e puts "You typed #{c.chr[详细]
-
莱布尼茨公式 估算PI
所属栏目:[百科] 日期:2020-12-17 热度:184
今天PHP站长网 52php.cn把收集自互联网的代码分享给大家,仅供参考。 #The Leibniz formula: 1-(1/3)+(1/5)-(1/7)+(1/9)...def pi(prec) denom = 3.0 mod = -1.0 result = 1.to_f i = 0 while( i prec) result += mod*((1[详细]
-
Linux 一键静音脚本
所属栏目:[百科] 日期:2020-12-17 热度:193
今天PHP站长网 52php.cn把收集自互联网的代码分享给大家,仅供参考。 #!/usr/bin/env ruby#alsactl -F init # if can't unmutes = `amixer get Master`val = s.scan(/Mono:sPlaybacks(d+)/)[0][0].to_ival1 = 41if val[详细]
-
Ruby 使用 gserver 创建一个简单的网络服务程序
所属栏目:[百科] 日期:2020-12-17 热度:118
今天PHP站长网 52php.cn把收集自互联网的代码分享给大家,仅供参考。 require 'gserver'class HelloServer GServer def serve(io) io.puts("Hello!") endendserver = HelloServer.new(1234)server.startserver.join 以上[详细]
-
Ruby 使用 HTTP 代理的例子
所属栏目:[百科] 日期:2020-12-17 热度:50
今天PHP站长网 52php.cn把收集自互联网的代码分享给大家,仅供参考。 require 'net/http'web_proxy = Net::HTTP::Proxy('your.proxy.hostname.or.ip',8080)url = URI.parse('http://www.rubyinside.com/test.txt')web_pro[详细]
-
Ruby Socket编程实例
所属栏目:[百科] 日期:2020-12-17 热度:82
今天PHP站长网 52php.cn把收集自互联网的代码分享给大家,仅供参考。 require "socket"def testTCPServer server = TCPServer.new 2000 # Server bound to port 2000 loop do client = server.accept # Wait for a client[详细]
-
Rails 实现页面的基本认证 (Basic Authentication)
所属栏目:[百科] 日期:2020-12-17 热度:130
今天PHP站长网 52php.cn把收集自互联网的代码分享给大家,仅供参考。 require 'net/http'url = URI.parse('http://www.rubyinside.com/test.txt')Net::HTTP.start(url.host,url.port) do |http| req = Net::HTTP::Get.new[详细]
-
ruby使用Win32API操作鼠标
所属栏目:[百科] 日期:2020-12-17 热度:187
今天PHP站长网 52php.cn把收集自互联网的代码分享给大家,仅供参考。 #要求ruby1.8.xrequire 'Win32API'#定义API GetCursorPos和SetCursorPos的接口get_cursor_pos = Win32API.new("user32","GetCursorPos",['p'],'v')$se[详细]
-
Ruby :编写一个 XML-RPC 程序
所属栏目:[百科] 日期:2020-12-17 热度:176
今天PHP站长网 52php.cn把收集自互联网的代码分享给大家,仅供参考。 require 'xmlrpc/server'server = XMLRPC::Server.new(1234)server.add_handler("sample.sumAndDifference") do |a,b| { "sum" = a.to_i + b.to_i,"di[详细]
-
使用mechanize分析并批量下载校内网相册照片
所属栏目:[百科] 日期:2020-12-17 热度:166
今天PHP站长网 52php.cn把收集自互联网的代码分享给大家,仅供参考。 #encoding: utf-8require 'rubygems'require 'mechanize'class Renren def initialize(e,p) @agent = Mechanize.new @page = @agent.get('http://3g.r[详细]
-
检测NFS设置是否合法
所属栏目:[百科] 日期:2020-12-17 热度:194
今天PHP站长网 52php.cn把收集自互联网的代码分享给大家,仅供参考。 def check_mount_nfs_1(ip,path) rtn = `/bin/ping -q -c 1 #{ip}` if $?.exitstatus == 0 rtn = `/sbin/showmount -e #{ip}` if $?.exitstatus == 0[详细]
-
简单抓取一个页面
所属栏目:[百科] 日期:2020-12-17 热度:76
今天PHP站长网 52php.cn把收集自互联网的代码分享给大家,仅供参考。 require ‘open-uri’require ‘iconv’ic = Iconv.new(“UTF8”,”GB2312”)yang = open(“http://www.baidu.com”)data = ic.iconv(yang.read)puts[详细]
-
win32 dll 调用
所属栏目:[百科] 日期:2020-12-17 热度:88
今天PHP站长网 52php.cn把收集自互联网的代码分享给大家,仅供参考。 #!evn rubyrequire 'rubygems'require 'dl'require 'Win32API'#dll文件名dllname = 'mm.dll'#dll里的函数名method_name = 'convert'#string buffbuff[详细]
-
Quadratic formula (二次公式)
所属栏目:[百科] 日期:2020-12-17 热度:160
今天PHP站长网 52php.cn把收集自互联网的代码分享给大家,仅供参考。 #PennyBoki @ /dream.in.codeputs 'Enter the coefficients'puts 'Enter a: 'STDOUT.flush a=gets.chomp.to_f # user enters the coefficient aputs '[详细]
-
上传代码
所属栏目:[百科] 日期:2020-12-17 热度:57
今天PHP站长网 52php.cn把收集自互联网的代码分享给大家,仅供参考。 a/a 以上是编程之家(jb51.cc)为你收集整理的全部代码内容,希望文章能够帮你解决所遇到的程序开发问题。 如果觉得编程之家网站内容还不错,欢迎将编程[详细]
-
Ruby 使用 HTTPS 发送数据到服务器
所属栏目:[百科] 日期:2020-12-17 热度:200
今天PHP站长网 52php.cn把收集自互联网的代码分享给大家,仅供参考。 require 'net/http'require 'net/https'url = URI.parse('https://example.com/')http = Net::HTTP.new(url.host,url.port)http.use_ssl = true if ur[详细]
-
上传截图到 http://img.vim-cn.com/
所属栏目:[百科] 日期:2020-12-17 热度:76
今天PHP站长网 52php.cn把收集自互联网的代码分享给大家,仅供参考。 #!/usr/bin/env ruby# -*- coding: utf-8 -*-# upircimage.rb /tmp/a.png# you may want change thisdest_url = 'http://img.vim-cn.com/'cmd = ['cur[详细]
-
Ruby CGI 设置 Cookie 和其他 HTTP 头
所属栏目:[百科] 日期:2020-12-17 热度:64
今天PHP站长网 52php.cn把收集自互联网的代码分享给大家,仅供参考。 #!/usr/bin/rubyrequire "cgi"cgi = CGI.new("html3")cookie = cgi.cookies['yourCookie']cookie = CGI::Cookie.new('yourCookie','hits=0',"last=#{T[详细]
-
统计单词出现的次数
所属栏目:[百科] 日期:2020-12-17 热度:163
今天PHP站长网 52php.cn把收集自互联网的代码分享给大家,仅供参考。 #Counts the number of times a 'word' appears in a 'phrase'def CountWordOccurrence(word,phrase,matchCase) # Gets the length of the phrase ind[详细]
-
ruby正则表达式打印匹配行
所属栏目:[百科] 日期:2020-12-17 热度:69
今天PHP站长网 52php.cn把收集自互联网的代码分享给大家,仅供参考。 class Filetestattr_accessor :filenamedef initialize(filename)@filename = filenameenddef puts_file_line(word)File.open(@filename,"r") do |fil[详细]
-
Ruby 列表 SSH 服务器上的文件
所属栏目:[百科] 日期:2020-12-17 热度:161
今天PHP站长网 52php.cn把收集自互联网的代码分享给大家,仅供参考。 require 'rubygems'require 'net/ssh'Net::SSH.start('example.com',:username='userName',:password='mypass') do |session| cmd = 'ls -l /home' se[详细]
-
多线程端口扫描
所属栏目:[百科] 日期:2020-12-17 热度:60
今天PHP站长网 52php.cn把收集自互联网的代码分享给大家,仅供参考。 #!/usr/bin/ruby# -*- coding: utf-8 -*-require 'socket'include Socket::Constantsrequire 'timeout'if ARGV[0] ips = ARGV[0].split(/s/)else p '[详细]
-
Ruby适配器模式
所属栏目:[百科] 日期:2020-12-17 热度:105
今天PHP站长网 52php.cn把收集自互联网的代码分享给大家,仅供参考。 class Connection def request raise "Abstract method" end end class MysqlAdapter Connection attr_accessor :connection def initialize @connect[详细]
-
ruby rot13加密
所属栏目:[百科] 日期:2020-12-17 热度:127
今天PHP站长网 52php.cn把收集自互联网的代码分享给大家,仅供参考。 class String def rot13 self.tr "A-Za-z","N-ZA-Mn-za-m" endend#用法:#str="abc"#print str.rot13 以上是编程之家(jb51.cc)为你收集整理的全部代码[详细]