Create a gist now

Instantly share code, notes, and snippets.

replacement script for gyazo to save files to your dropbox public folder
#!/usr/bin/env ruby
dropbox_user_id = 'YOUR_DROPBOX_USER_ID'
nyazo_folder_name = 'nyazo' # or your folder name of choice
system_user = IO.popen("whoami", "r+").gets.chomp
nyazo_folder_path = "/Users/#{system_user}/Dropbox/Public/#{nyazo_folder_name}"
system "mkdir -p #{nyazo_folder_path}"
filename = "#{(0...8).map{65.+(rand(25)).chr}.join.downcase}.png"
image_path = "#{nyazo_folder_path}/#{filename}"
system "screencapture -i \"#{image_path}\""
if File.exist?(image_path)
system "sips -d profile --deleteColorManagementProperties \"#{image_path}\""
end
url = "https://dl.dropbox.com/u/#{dropbox_user_id}/#{nyazo_folder_name}/#{filename}"
system "echo #{url} | pbcopy"
# sleep 3 # major hack
system "open #{url}"
if !File.exist?(image_path) then
exit
end
@trafnar
Owner

This has two issues:

  • I don't know how to make the browser open once the upload is complete so it just waits a couple seconds
  • If you cancel the screenshot, the browser still opens
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment