Instantly share code, notes, and snippets.

What would you like to do?
Create a service workflow in Automator with a "Run AppleScript" action with this for an easy shortcut for posting to (See
-- pastebin.workflow.applescript
-- An automator workflow to copy selected text to
-- Created by Marc Abramowitz
-- December 5, 2010
-- version 1.0
on run {input}
-- prep input for validation
set inputResult to (input as string)
-- Build the curl command to post to
set curlCMD to "curl --stderr /dev/null -d\"paste_code=" & urlencode(inputResult) & "\""
-- Run the script and get the result:
set pastebinUrl to (do shell script curlCMD)
-- Open in default web browser
open location pastebinUrl
-- return result to be copied to the clipboard
return pastebinUrl
end run
on urlencode(theText)
set theTextEnc to ""
repeat with eachChar in characters of theText
set useChar to eachChar
set eachCharNum to ASCII number of eachChar
if eachCharNum = 32 then
set useChar to "+"
else if (eachCharNum 42) and (eachCharNum 95) and (eachCharNum < 45 or eachCharNum > 46) and (eachCharNum < 48 or eachCharNum > 57) and (eachCharNum < 65 or eachCharNum > 90) and (eachCharNum < 97 or eachCharNum > 122) then
set firstDig to round (eachCharNum / 16) rounding down
set secondDig to eachCharNum mod 16
if firstDig > 9 then
set aNum to firstDig + 55
set firstDig to ASCII character aNum
end if
if secondDig > 9 then
set aNum to secondDig + 55
set secondDig to ASCII character aNum
end if
set numHex to ("%" & (firstDig as string) & (secondDig as string)) as string
set useChar to numHex
end if
set theTextEnc to theTextEnc & useChar as string
end repeat
return theTextEnc
end urlencode

This comment has been minimized.


This comment has been minimized.

Copy link

dattz commented Apr 13, 2016

This is now obselete.
"THIS API HAS BEEN DISABLED. Please use Pastebin's new API."

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment