自己封装了的一个httprequest类
require "net/http"
require "net/https"
class HttpRequest
attr_accessor :cookie
def initialize
end
def get_response(domain,path)
url = URI.parse(domain)
resp = Net::HTTP.start(url.host, url.port) {|http|
http.get(path)
}
return deal_response(resp)
end
def post_request(domain,path,data)
url = URI.parse(domain)
http=Net::HTTP.new(url.host, url.port)
headers ={
'Content-Type' => 'application/x-www-form-urlencoded',
}
headers['Cookie']= @cookie if !@cookie.nil?
resp = http.post(path, data, headers)
return deal_response(resp)
end
private
def deal_response(res)
@cookie = res.response['set-cookie']
return res
end
end
linux下虚拟XP共享文件
第一步:
打开linux终端,输入 VBoxManage sharedfolder add "虚拟系统的名称" -name “给要共享的文件夹起个名称" -hostpath "要共享的文件夹"
第二步:
进入虚拟的Winxp,工具-》映射网路驱动-》选择VBoxSr\XXX
一道简单的编程题
题目:将array数组中,从begin下标到end下标之间的元素反序一下,如一个数组初始值是[1, 2, 3, 4, 5, 6],begin为1,end为4,那么当调用了Reverse之后,array数组中的元素便依次成为[1, 5, 4, 3, 2, 6],其中从array[1]到array[4]之前的元素被反序了
arr =[1,2,3,4,5,6]
def reverse(list,b,e)
while(b<e)
list[b],list[e] = list[e],list[b]
b = b+1
e = e-1
end
list
end
p reverse(arr,1,3)