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 / 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
@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:9540442
Created March 14, 2014 01:12
AngularJS directive for drag and drop file uploading
'use strict';
(function () {
angular.module('ui').directive('imageDrop', function () {
return {
restrict: 'EA',
scope: {
dropFn: '&'
},
link: function (scope, element, attrs) {
@locnguyen
locnguyen / promises
Created April 7, 2014 04:23
Chaining AngularJS promises example
var loadClient = function () {
return currentUserService.getClient().then(function (client) {
$scope.client = client;
return client.id;
});
},
loadDefaultLastPeriod = function (clientId) {
return currentUserService.getScenarioByName({ clientId: clientId, name: 'Last Period' })
.then(function (scenario) {
$scope.defaultScenarios.push(scenario);
@locnguyen
locnguyen / picard.php
Last active August 29, 2015 14:02
Picard ascii art for PHP
$picard = "
............................................________
....................................,.-'''...................``~.,
.............................,.-''...................................''-.,
.........................,/...............................................'':,
.....................,?......................................................,
.................../...........................................................,}
................./......................................................,:`^`..}
.............../...................................................,:''........./
..............?.....__.........................................:`.........../
@locnguyen
locnguyen / vagrant_laravel.md
Last active August 29, 2015 14:05
Laravel Vagrant notes

Write permissions to app/storage need to be granted to the Vagrant VM. The gotcha is you have to do this from the host machine:

chmod -R 777 app/storage

For some reason ~/.composer (or COMPOSER_HOME) will change ownership to root:root. This needs to be owned by the vagrant user:

chown vagrant:vagrant ~/.composer

If you're still getting an exception when running composer install like this

<ul>
<li ng-repeat="(key, errors) in myForm.$error track by $index">
<strong ng-bind="key"></strong> errors
<ul>
<li ng-repeat="e in errors">
<span ng-bind="e.$name"></span> has an error: <strong ng-bind="key"></strong>.
</li>
</ul>
</li>
</ul>
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# All Vagrant configuration is done here. The most common configuration
# options are documented and commented below. For a complete reference,
# please see the online documentation at vagrantup.com.
@locnguyen
locnguyen / rspec-syntax-cheat-sheet.rb
Created November 25, 2012 16:54 — forked from dnagir/rspec-syntax-cheat-sheet.rb
RSpec 2 syntax cheat sheet by example
# RSpec 2.0 syntax Cheet Sheet by http://ApproachE.com
# defining spec within a module will automatically pick Player::MovieList as a 'subject' (see below)
module Player
describe MovieList, "with optional description" do
it "is pending example, so that you can write ones quickly"
it "is already working example that we want to suspend from failing temporarily" do
pending("working on another feature that temporarily breaks this one")
@locnguyen
locnguyen / gist:7848265
Last active December 30, 2015 15:29 — forked from oisin/gist:6562181
Almost pulled all my hair out trying to figure out how to install the do_postgres gem with Postgres.app v9.3
gem install do_postgres -- --with-pgsql-server-dir=/Applications/Postgres93.app/Contents/MacOS --with-pgsql-server-include=/Applications/Postgres93.app/Contents/MacOS/include/postgresql/server