Skip to content

Instantly share code, notes, and snippets.

@mashiro
Created April 14, 2014 13:36
Show Gist options
  • Save mashiro/10648618 to your computer and use it in GitHub Desktop.
Save mashiro/10648618 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
# -*- encoding: utf-8 -*-
require 'bundler'
Bundler.require
def gist(filename, content, options = {})
data = {
description: options[:description],
public: options.fetch(:public, false),
files: {
filename => {
content: content
}
}
}
conn = Faraday.new 'https://api.github.com' do |conn|
conn.request :json
conn.response :follow_redirects
conn.response :json, content_type: /\bjson$/
conn.adapter :net_http
end
res = conn.post '/gists', data
puts res.body['html_url']
end
begin
hoge
rescue => e
errors = [e.to_s] + e.backtrace.map { |s| "\t#{s}" }
gist 'error.txt', errors.join("\n")
end
@Favorwilliams
Copy link

My Pleasure to write you,
My name is Favor Williams,
My email address is
( [email protected])
Am interested to know
more about you,
Contact me for my
photo and other
important issue via,

[email protected]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment