Tuesday, December 22, 2015

Ubuntu CUPS Driver for Google Cloud Print

On my Ubuntu desktop computer, printing to Google Cloud Print works great when printing from Chrome.  This screenshot shows how I can select my printer, the Brother MFC-J450DW, from the printers I have previously setup in Google Cloud Print.

Google Cloud Print Printer Selection Dialog Box
Google Cloud Print Printer Selection Dialog Box
The problem is being able to select my Google Cloud Print printer from any other printer selection dialog box in Ubuntu.  The answer is to setup a CUPS printer driver that knows how to print to your Google Cloud Print printer.

Fortunately, Niftiest Software has made such a CUPS driver available: CUPS Cloud Print.  According to their website,
CUPS Cloud Print is a Google Cloud Print driver for UNIX-like operating systems ( Linux, Mac OS X , BSDs etc ). It allows any application which prints via CUPS to print to Google Cloud Print directly.
CUPS Clount Print is very easy to install on Ubuntu.  You just add their Personal Package Archive (PPA), apt-get install cupscloudprint, and run the setup script, written in python.  The setup script will prompt you for your Google user account.  Then it generates a link which you visit in your browser.  This will grant access to CUPS Cloud Print at Google and give you an authorization code. Just copy/paste that code when prompted by the setup script, choose an optional prefix for your Google Cloud Print printer names for when they show up as CUPS printers, and you're done.  After this, your Google Cloud Print printers will show up in your Printers settings, and you can choose them from any Ubuntu Print dialog box.

Ubuntu Printer Settings Dialog Box
Ubuntu Printer Settings Dialog Box

Here you can see that my Google Cloud Print printer name was Brother_MFC-J450DW and I told the CUPS Cloud Print setup script to use the prefix GCP-.  The prefix makes it easy to distinguish the Google Cloud Print printers from other printers you may have installed.  As you can see, I don't have any other printer setup besides the Google Cloud Print printers.

It's nice to be able to print easily from anywhere within Ubuntu without ever having to install a proprietary printer driver.  Thanks to Google Cloud Print and Niftiest Software for making this capability freely available!

Monday, January 19, 2015

Send Large Files with Amazon S3 and Groovy


Sometimes you need to send a very large files to people. You could use your email or file sharing service of choice, but they have limits.  For example:

Google Mail - 25 MB limit
Google Drive - 100 GB limit
Dropbox - 2-16 GB limit

Even if your file is within the limit, you don't necessarily want to use those services each time, because it will add up, and eventually you'll run out of space in your account.

You could use services that specialize in sending large files. For example: Hightail, WeTransfer, DropSend, etc. But, you may not trust them with your files or just don't want to bother with creating additional accounts.

I came up with another solution that works well for developers like me that are familiar with using Amazon S3.  With a simple script (I wrote mine in Groovy), I can upload any file from my computer to Amazon S3 and then generate a pre-signed URL that gives access to the file for a certain period of time.  This URL can be IM'd or emailed to anyone so that they can download the file before the URL expires.

Here are the steps to use this script:
  1. Make sure you have an AWS account and a bucket setup in S3.
  2. Download the script from GitHub: UploadToS3AndGenerateSignedUrl.groovy
  3. Modify the global variables:
    • pathToFile
    • bucketName
    • expiresInHours
    • myAccessKeyID,
    • mySecretKey
  4. Run the script:
    • groovy UploadToS3AndGenerateSignedUrl.groovy
  5. Copy the URL that gets printed to stdout. It will look similar to this:
    • https://my-bucket-name.s3.amazonaws.com/myLargeFile.zip?AWSAccessKeyId=12E3AZEDFJQ6CMZW1HG5&Expires=1421887816&Signature=GFQ0LeR%2FtgWWGtXu3cJXspFtKNE%3D
  6. Send the URL to someone else in an email. They can click on it to download the file.
  7. Optionally, use the Amazon S3 Console to remove the file from S3 once the recipient(s) have downloaded the file so that you don't get charged to have it sitting there forever.