Skip to content

Instantly share code, notes, and snippets.

@youpy
Last active September 25, 2015 22:18
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save youpy/993553 to your computer and use it in GitHub Desktop.
Save youpy/993553 to your computer and use it in GitHub Desktop.
/Applications/Gyazo.app/Contents/Resources/script
#!/usr/bin/env ruby
require 'fileutils'
require 'digest/md5'
def main
file = File.expand_path("~/Dropbox/Public/g/#{Digest::MD5.hexdigest(Time.now.to_f.to_s)}.png")
url = 'https://dl.dropboxusercontent.com/u/334064/g/' + File.basename(file)
FileUtils.mkdir_p File.dirname(file)
system "screencapture -i \"#{file}\""
if File.exist?(file) then
system "sips -d profile --deleteColorManagementProperties \"#{file}\""
end
wait_for_upload(url)
system "echo -n #{url} | pbcopy"
system "open #{url}"
end
def wait_for_upload(url)
until(`curl -I -X GET '#{url}'`.match(/200 OK/)) do
sleep 1
end
end
main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment