ko1 / simplepaste

SimplePaste web application

This URL has Read+Write access

Koichi Sasada (author)
Sun Jun 15 19:31:58 -0700 2008
commit  40b6106b2cabed93f62932ca7c68719f86e9259d
tree    c49dde2ffd0be3059cb976e8aeffbe90072360dc
parent  00f1e9d0bd0ca932d7fc91f7b35538d70a1ab658
simplepaste / bin / spc.rb
6008a663 » Koichi Sasada 2008-06-08 add files 1 #!/usr/bin/ruby
2
11b55a61 » Koichi Sasada 2008-06-08 * disable $DEBUG flag 3 TextPasteURL = 'http://www.atdot.net/sp/commit/auto'
6008a663 » Koichi Sasada 2008-06-08 add files 4
5 ####################################################
6
7 require 'uri'
8 require 'cgi'
9 require 'net/http'
10 Net::HTTP.version_1_2
11
12 def paste str
13 body = CGI.escape(str)
14 uri = URI.parse(TextPasteURL)
15
16 Net::HTTP.start(uri.host, uri.port) {|http|
17 response = http.post(uri.path, 'paste_body=' + body)
18 puts response.body
19 }
20 end
21
22 if ARGV.empty?
23 paste ARGF.read
24 else
25 ARGV.each{|file|
26 paste File.read(file)
27 }
28 end