-
-
Save zunda/55a992e541d351e19dcb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
scrot -s -e 'cloudapp $f; rm $f' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby | |
# https://gist.github.com/wuputah/cd6a7f3781c288fbbc4c | |
usage = "#{File.basename($0)} file-to-upload ...\nURLs will be in your clipboard" | |
# $ gem install --user-install cloudapp_api | |
require 'cloudapp_api' | |
config_file = "#{ENV['HOME']}/.cloudapp" | |
begin | |
email, password = File.read(config_file).split("\n") | |
rescue Errno::ENOENT | |
end | |
if not password or password.empty? | |
$stderr.puts "#{config_file} shuold have your email and password (one par line)" | |
end | |
if ARGV.empty? | |
$stderr.puts "usage: #{usage}" | |
exit 0 | |
end | |
begin | |
CloudApp.authenticate(email, password) | |
urls = ARGV.map do |x| | |
$stderr.print "Uuploading #{x} as... " | |
begin | |
url = CloudApp::Item.create(:upload, {:file => x}).url | |
url += "/#{File.basename(x)}" | |
$stderr.puts url | |
url | |
rescue SystemCallError => e | |
$stderr.puts e # and try other files | |
end | |
end | |
# Copy them to your (linux) clipboard. | |
IO.popen("xclip -i", "w") do |io| | |
io.print urls.compact.join(",") | |
end | |
rescue NameError => e | |
if "uninitialized constant CloudApp::ResponseError::MultiJson" == e.message | |
$stderr.puts "Error from CloudApp API" | |
exit 1 | |
else | |
raise e | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment