Skip to content

Instantly share code, notes, and snippets.

@swdyh
Created April 17, 2009 14:36
Show Gist options
  • Select an option

  • Save swdyh/97062 to your computer and use it in GitHub Desktop.

Select an option

Save swdyh/97062 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
# -*- encoding: utf-8 -*-
require 'net/http'
require 'time'
require 'rubygems'
require 'pit'
require 'kconv'
def post url, opt = {}
uri = (url.class == URI) ? url : URI(url)
Net::HTTP.post_form uri, opt
end
def post_tumblr text
post_url = 'http://www.tumblr.com/api/write'
opt = {
'type' => 'regular',
'title' => Time.now.iso8601,
'body' => text,
'group' => 'http://swdyh.tumblr.com/',
'format' => 'markdown',
}
res = post(post_url, opt.merge(Pit.get('tumblr.com')))
puts res.body
end
post_tumblr Kconv.toutf8(`pbpaste`)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment