Two-Legged OAuth with the Google Drive API in Ruby

Google are discontinuing support for the Documents List API, and moving to the Drive API.

The old API supported authentication with a username and password, but that’s not allowed in the new API. Instead, you need to use OAuth for access.

If you want to have server-to-server authentication, without user interaction, you need a “two-legged” OAuth process, where a token is obtained with an encrypted request and then used for future service requests.

Continue reading Two-Legged OAuth with the Google Drive API in Ruby

from_sentence : the opposite of Rails to_sentence

I like the Rails to_sentence method on String class, which converts an array to a comma-separated sentence where the last element is joined by a connector word.

It makes it easy to take a list of names, for example, and make them human-readable, without having to fiddle with join words and last-item-is-special-case stuff:

['one', 'two'].to_sentence          # => "one and two"
['one', 'two', 'three'].to_sentence # => "one, two, and three"

Continue reading from_sentence : the opposite of Rails to_sentence

Sublime Text 3 : keyboard shortcut to reveal file in sidebar

To see where your current file is in the folder sidebar, you can install SyncedSideBar.

However, that has some side effects – sometimes, even if you’ve hidden the sidebar, it pops back up when you switch between files, or search.

Continue reading Sublime Text 3 : keyboard shortcut to reveal file in sidebar