Created
October 8, 2010 08:08
-
-
Save dannvix/616490 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby | |
require 'net/http' | |
require 'uri' | |
if ARGV.length < 1 then | |
puts "Usage: ./paste2plurk.rb [filename] ... " | |
exit | |
end | |
def get_language (filename) | |
return 'bash' if filename.match(/^.*\.sh$/) | |
return 'bat' if filename.match(/^.*\.bat$/) | |
return 'c' if filename.match(/^.*\.(c|h)$/) | |
return 'cpp' if filename.match(/^.*\.cpp$/) | |
return 'csharp' if filename.match(/^.*\.cs$/) | |
return 'css' if filename.match(/^.*\.css$/) | |
return 'html' if filename.match(/^.*\.htm[l]+$/) | |
return 'java' if filename.match(/^.*\.java$/) | |
return 'perl' if filename.match(/^.*\.pl$/) | |
return 'python' if filename.match(/^.*\.py$/) | |
return 'ruby' if filename.match(/^.*\.rb$/) | |
return 'textpre' | |
end | |
ARGV.each do |filename| | |
next if File.directory? filename | |
puts "Uploading #{filename} ..." | |
resp = Net::HTTP.post_form( | |
URI.parse('http://paste.plurk.com/'), { | |
'language' => get_language(filename), | |
'code' => File.read(filename) | |
}) | |
puts resp['Location'] | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Ruby!