Pastie now auto-senses if line-wrap is a bad or good idea. Feedback?
## mark a section (Learn more)
namespace :pastie do desc 'Copies the contents of the Mac OS X clipboard to pastie; borrowed from the Utility Belt gem' task :clip do if RUBY_PLATFORM =~ /darwin/ require 'net/http' class MacClipboard class << self def read IO.popen('pbpaste') {|clipboard| clipboard.read} end def write(stuff) IO.popen('pbcopy', 'w+') {|clipboard| clipboard.write(stuff)} end end end pastie_url = Net::HTTP.post_form(URI.parse("http://pastie.caboo.se/pastes/create"), {"paste_parser" => "ruby", "paste[authorization]" => "burger", "paste[body]" => MacClipboard.read}).body.match(/href="([^\"]+)"/)[1] MacClipboard.write(pastie_url) system("open #{pastie_url}") pastie_url else puts "Sorry, get a Mac ;-)" end end end
This paste will be private.
From the Design Piracy series on my blog: