Skip to content

Instantly share code, notes, and snippets.

@trafnar
Created August 18, 2012 22:57
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save trafnar/3390267 to your computer and use it in GitHub Desktop.
Save trafnar/3390267 to your computer and use it in GitHub Desktop.
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
Copy link
Author

trafnar commented Nov 28, 2012

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