Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Created by RubyPico at Sat Nov 12 23:44:12 2016
updated file contents
a new file
あいうえお
modified contents
Owner

ongaeshi commented Nov 12, 2016 edited

# https://developer.github.com/v3/gists/#create-a-gist
json = {
  description: "Created by RubyPico at #{Time.now}",
  public: true,
  files: {
    "file1.txt" => {
      content: "updated file contents"
    },
    "old_name.txt" => {
      filename: "new_name.txt",
      content: "modified contents"
    },
    "new_file.txt" => {
      content: "a new file\nあいうえお"
    },
  }
}

puts Browser.post(
  "https://api.github.com/gists",
  header: { "Authorization" => "token XXXXXXXX" },
  json: json
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment