GitHub Sale: sign up for any paid plan this week and pay nothing until January 1, 2009!  [ hide ]

public
Description: SimplePaste web application
Homepage: http://atdot.net/sp
Clone URL: git://github.com/ko1/simplepaste.git
simplepaste / bin / spc.rb
100644 29 lines (22 sloc) 0.521 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/usr/bin/ruby
 
TextPasteURL = 'http://www.atdot.net/sp/commit/auto'
 
####################################################
 
require 'uri'
require 'cgi'
require 'net/http'
Net::HTTP.version_1_2
 
def paste str
  body = CGI.escape(str)
  uri = URI.parse(TextPasteURL)
 
  Net::HTTP.start(uri.host, uri.port) {|http|
    response = http.post(uri.path, 'paste_body=' + body)
    puts response.body
  }
end
 
if ARGV.empty?
  paste ARGF.read
else
  ARGV.each{|file|
    paste File.read(file)
  }
end