Skip to content

Instantly share code, notes, and snippets.

View locnguyen's full-sized avatar

Loc Nguyen locnguyen

  • Southern California
  • X @locn
View GitHub Profile
@locnguyen
locnguyen / ConvertBase64ImageServiceObject
Created March 13, 2014 23:06
Service object for converting Base64 encoded image to save with Carrier Wave in Ruby apps
# Needed for Rails 3+
class FilelessIO < StringIO
attr_accessor :original_filename
end
class ConvertBase64ImageService
def call(base64_encoded_image, filename)
@locnguyen
locnguyen / gist:9280712
Created February 28, 2014 21:48
Sample SignNow API usage
Create a new user with base 64 encoded client credentials...
curl -H 'Authorization: Basic MGZjY2RiYzczNTgxY2EwZjliZjhjMzc5ZTZhOTY4MTM6MzcxOWExMjRiY2ZjMDNjNTM0ZDRmNWMwNWI1YTE5NmI=' --data '{"email":"lnguyen@mailinator.com", "password": "x"}' -X POST https://capi-eval.signnow.com/api/user
Create an oauth2 token for the new user
curl -H 'Authorization: Basic MGZjY2RiYzczNTgxY2EwZjliZjhjMzc5ZTZhOTY4MTM6MzcxOWExMjRiY2ZjMDNjNTM0ZDRmNWMwNWI1YTE5NmI=' --data 'username=lnguyen@mailinator.com&password=x&scope=*&grant_type=password' https://capi-eval.signnow.com/api/oauth2/token
Create a new document for that user with his oauth2 token
curl -H 'Authorization: Bearer be933cbc0ebe63f8d636a517f23feb4826ceef67b5f29a12896d40cd0e9dd4c0' -F 'file=snlogo.png' https://capi-eval.signnow.com/api/document
Get a list of the user's documents