Skip to content

Instantly share code, notes, and snippets.

@pokutuna
Created April 4, 2011 06:08
Show Gist options
  • Save pokutuna/901198 to your computer and use it in GitHub Desktop.
Save pokutuna/901198 to your computer and use it in GitHub Desktop.
gyazo through proxy
*** script 2011-04-04 14:33:41.000000000 +0900
--- script.proxy 2011-04-04 14:55:51.000000000 +0900
***************
*** 60,83 ****
'User-Agent' => UA
}
! Net::HTTP.start(HOST,80){|http|
res = http.post(CGI,data,header)
! url = res.response.to_ary[1]
! system "echo -n #{url} | pbcopy"
! system "open #{url}"
! # save id
! newid = res.response['X-Gyazo-Id']
! if newid and newid != "" then
! if !File.exist?(File.dirname(idfile)) then
! Dir.mkdir(File.dirname(idfile))
! end
! if File.exist?(idfile) then
! File.rename(idfile, idfile+Time.new.strftime("_%Y%m%d%H%M%S.bak"))
! end
! File.open(idfile,"w").print(newid)
! if File.exist?(old_idfile) then
! File.delete(old_idfile)
! end
end
! }
--- 60,91 ----
'User-Agent' => UA
}
! begin
! http = Net::HTTP.new(HOST,80)
! http.open_timeout = 2
res = http.post(CGI,data,header)
! rescue
! http = Net::HTTP.new(HOST,80,proxy_addr = 'proxy.hoge.jp', proxy_port = 8080)
! http.open_timeout = 2
! res = http.post(CGI,data,header)
! end
!
! url = res.response.to_ary[1]
! system "echo -n #{url} | pbcopy"
! system "open #{url}"
! # save id
! newid = res.response['X-Gyazo-Id']
! if newid and newid != "" then
! if !File.exist?(File.dirname(idfile)) then
! Dir.mkdir(File.dirname(idfile))
end
! if File.exist?(idfile) then
! File.rename(idfile, idfile+Time.new.strftime("_%Y%m%d%H%M%S.bak"))
! end
! File.open(idfile,"w").print(newid)
! if File.exist?(old_idfile) then
! File.delete(old_idfile)
! end
! end
!
@pokutuna
Copy link
Author

pokutuna commented Apr 4, 2011

line38. proxy.hoge.jpを修正してつかう

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment