Skip to content

Instantly share code, notes, and snippets.

@winebarrel
Last active August 29, 2015 14:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save winebarrel/7e6a4c470fa7b904cbe8 to your computer and use it in GitHub Desktop.
Save winebarrel/7e6a4c470fa7b904cbe8 to your computer and use it in GitHub Desktop.
Replace "Gyazo/script" to follow script:
#!/usr/bin/env ruby
require 'securerandom'
require 'tmpdir'
S3_BACKET = 'my-bucket'
S3_PATH = 'path'
ENDPOINT = 'my-bucket.s3-website-ap-northeast-1.amazonaws.com'
Dir.mktmpdir do |dir|
now = Time.now.utc
filename = "#{now.to_i}.#{SecureRandom.uuid}.png"
tmpfile = File.join(dir, filename)
path = File.join(S3_PATH, now.strftime('%Y/%m/%d'), filename)
upload_path = File.join(S3_BACKET, path)
system(%!screencapture -i "#{tmpfile}"!)
system(%!sips -d profile --deleteColorManagementProperties "#{tmpfile}"!)
system(%!/usr/local/bin/aws s3 cp "#{tmpfile}" s3://#{upload_path}!)
#system(%!osascript -e 'display notification "s3://#{upload_path}" with title "Gyazo"'!)
system(%!open http://#{File.join(ENDPOINT, path)}!)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment