Friday, April 8, 2016

Rails Tools: Paperclip and Cloudinary, brought together

Need a low-cost viable solution for storing and serving image file attachments in your Rails application? Read on...

For a number of implementations, I have used thoughtbot's Paperclip gem to manage my Rails models' file attachments. It provides sizing and scaling via Imagemagick and is simple to get up and running quickly. For file storage, I found the paperclip-dropbox gem as an excellent way to hook up a free Dropbox account to store and manage a few files.

Unfortunately, not only is that gem no longer activity maintained (with ominous warnings across the homepage now), but this solution also doesn't work quite so well for images; particularly, serving images to display online. And the jump in price point from Dropbox to AWS or similar wasn't really something I wanted to take on. So, I needed something cost-effective that was good at serving images. For that purpose, I ran across Cloudinary.

Cloudinary is an image and video cloud-based management solution which is very fast, easy to manage, and has a usable free tier. It also has some awesome directives that can be used for on-the-fly image transformation in just about any way you can imagine, such as sizing, scaling, coloring, overlaying, and much more. Not only that, but Cloudinary is also Rails-friendly, coming with a Rails gem as well as a direct integration to CarrierWave, which is essentially an alternative to Paperclip.

Using Cloudinary and CarrierWave together is a great solution for many, and for those happy to do that, Cloudinary provides detailed instructions on getting integrated. However, for me, migrating from my Paperclip/Dropbox solution to CarrierWave/Cloudinary was a task I wasn't too keen on performing. So, I decided to build the missing link, bringing together Paperclip and Cloudinary.


Gem Version


The paperclip-cloudinary gem adds "cloudinary" as a new storage option for Paperclip, and dropping that in as the storage option along with the downloadable configuration file from a Cloudinary account will have your images stored in Cloudinary in minutes. From there, you can use Cloudinary's cool features to further manipulate your images in views. Or not, it's up to you from there.

Bottom line, if you're sticking with Paperclip, but want a better free-to-low-cost alternative to Dropbox for serving images, try paperclip-cloudinary.

--
Carl Scott
Software Developer, Solertium Corporation
View Carl Scott's profile on LinkedIn View Carl Scott's ohloh profile

Tuesday, January 12, 2016

How I Log My Time In My Sleep

Photograph by: apops, Fotolia.com
Every day last week, I woke up to see that my development time had been logged.

But I haven't logged in to FreshBooks since 2015.

Like many other development teams, our company uses FreshBooks to track our time and invoice clients.  It's a great tool with all the features we need for day-to-day operations. However, as a programmer, over the years I have failed to use this tool properly, and neglected my time logging duties until it was absolutely necessary. This neglect often required "time logging parties" with other members of my team who had been equally neglectful, which was a kind misnomer for stressful sessions of reading through e-mails, project management tools, git logs, hand-written notes, and anything else to help us remember just how much time we spent working on something.

And, like many other development teams, I work on multiple projects per day -- sometimes per hour!

For me, the most frustrating thing about logging time is essentially having to record my operations so many times. First, when I tell a client what I'm going to do. Again when I code the thing I was supposed to do. Then, I write fairly detailed commit messages describing what I did. Finally, I communicate with the client that the thing was done. And now I have to write all this again in an time tracking tool?! Ugh.

It doesn't often get done. And when it does, it isn't efficient. Time should be logged in-process.

I've tried stopwatch solutions, but they simply don't work when you forget to hit the button. And I'm too busy (forgetful) to hit the button. Or, I get distracted with something else going on, or a client calls, or I need to task switch immediately, etc. etc.

Why can't I just code and have my time tracked as I code?

Well, now I can, thanks to WakaTime.

WakaTime advertises itself as FitBit for programmers, and that's a pretty spot-on description. In the same way that FitBit tracks your statistics just by you doing your everyday tasks, WakaTime tracks your time spent in your IDE of choice (Vim, Eclipse, Android Studio, and many more) and automatically uploads that information to the web. At the end of the day, just by coding, you've got a picture of everything you've worked on for the day. For free.

"Yes!"
To complete the puzzle, though, I needed to get the time out of WakaTime and in to FreshBooks. There wasn't anything out there that did that for me, so I created it:


WakaTimeFreshBooks is a Java command-line client that pulls the time logged for a given day in WakaTime and pushes that information as time entries into FreshBooks. After a couple minutes of setting up my API keys and matching up the WakaTime projects I wanted to log with FreshBooks projects I wanted to send the time to, I was up and running. Simple, yet effective.

On December 28, 2015, I set this to run as a daily cron job, and I haven't logged time since.

Now eventually, I'll have to edit my time sheets to include useful notes for invoices. And I still need to log out-of-band communications, as well as testing and video conferences (although, WakaTime is working on solutions for those things!). But, for now, I know that my coding time has been submitted, and that it's fairly accurate, which is much more than I could say merely a few weeks ago.

And I didn't have to do anything but code.

--
Carl Scott
Software Developer, Solertium Corporation
View Carl Scott's profile on LinkedIn View Carl Scott's ohloh profile