Skip to content

Instantly share code, notes, and snippets.

View jcleblanc's full-sized avatar

Jonathan LeBlanc jcleblanc

View GitHub Profile
Steps to creating a machine learning system
1. Create your JWT application with Box
2. Set up a webhook on a folder
3. Set up a lambda to listen for the webhook notifications
4. Upload a file using the Box file API (this will trigger your webhook)
5. Read in the file from Box and upload the file to your preferred machine learning system
6. When the machine learning system sends a notification (after processing the file) upload the new data (via the Box metadata API) to the file.
Resources
@jcleblanc
jcleblanc / box_webhook_folder_create.js
Created September 11, 2018 18:51
Create a webhook on a folder in Box to listen for file upload events
'use strict';
// Initialize packages
const util = require('util'); // Deep inspection of objects
const boxSDK = require('box-node-sdk'); // Box SDK
const fs = require('fs'); // File system for config
// Fetch config file for instantiating SDK instance
// SAVE YOUR OWN APP CONFIG FILE TO config.json
const configJSON = JSON.parse(fs.readFileSync('config.json'));
@jcleblanc
jcleblanc / quickstart_auth_oauth_start.java
Last active November 8, 2017 23:12
Quickstart OAuth auth samples - Redirect the user to Box
// Redirect user to login with Box
String box_redirect = Config.box_redirect
+ "?response_type=code"
+ "&client_id=" + Config.client_id
+ "&redirect_uri=" + Config.redirect_uri;
res.redirect(box_redirect);
curl https://svcs.sandbox.paypal.com/Permissions/RequestPermissions -s --insecure -H "X-PAYPAL-SECURITY-USERID: caller_1312486258_biz_api1.gmail.com" -H "X-PAYPAL-SECURITY-PASSWORD: 1312486294" -H "X-PAYPAL-SECURITY-SIGNATURE: AbtI7HV1xB428VygBUcIhARzxch4AL65.T18CTeylixNNxDZUu0iO87e" -H "X-PAYPAL-REQUEST-DATA-FORMAT: JSON" -H "X-PAYPAL-RESPONSE-DATA-FORMAT: JSON" -H "X-PAYPAL-APPLICATION-ID: APP-80W284485P519543T" -d '{"scope":"EXPRESS_CHECKOUT", "callback":"http://www.example.com/success.html", "requestEnvelope": { "errorLanguage":"en_US" }}'
@jcleblanc
jcleblanc / bt_dropin_node_server.js
Created September 19, 2015 16:15
Braintree Drop-In UI Express Server Sample (Node)
var express = require('express'),
bodyParser = require('body-parser'),
app = express(),
util = require('util'),
braintree = require('braintree');
app.use( bodyParser.json() ); // to support JSON-encoded bodies
app.use(bodyParser.urlencoded({ // to support URL-encoded bodies
extended: true
}));
@jcleblanc
jcleblanc / bt_dropin_node_client.html
Created September 19, 2015 16:15
Braintree Drop-In UI Client Sample (Node)
<!DOCTYPE HTML>
<html>
<head>
<title>Dropin</title>
</head>
<body>
<form id="checkout" method="post" action="http://localhost:3000/checkout">
<div id="payment-form"></div>
<input type="submit" value="Make Payment">
@jcleblanc
jcleblanc / subscription_agreement.js
Created June 26, 2014 06:15
paypal_rest_subscriptions_user_agreement
curl -v POST https://api.sandbox.paypal.com/v1/payments/billing-agreements
-H 'Content-Type:application/json' \
-H 'Authorization: Bearer {accessToken}' \
-d '{
"name": "Main Subscription",
"description": "Fruit of the Month Subscription",
"start_date": "2015-02-19T00:37:04Z",
"plan": {
"id": "P-0NJ10521L3680291SOAQIVTQ"
},
@jcleblanc
jcleblanc / subscription_billing.js
Created June 26, 2014 05:58
paypal_rest_subscriptions_billing_agreement
curl -v POST https://api.sandbox.paypal.com/v1/payments/billing-plans \
-H 'Content-Type:application/json' \
-H 'Authorization: Bearer {accessToken}' \
-d '{
"name": "Fruit of the Month",
"description": "10 Pound Box of Fruit",
"type": "fixed",
"payment_definitions": [
{
"name": "Standard Package",
@jcleblanc
jcleblanc / auth_return.json
Created May 31, 2013 15:30
HATEOAS link return structure from a successful auth request through the PayPal REST APIs
"links":[
{
"href":"https://api.sandbox.paypal.com/v1/payments/authorization/9T287484DP554682S",
"rel":"self",
"method":"GET"
},
{
"href":"https://api.sandbox.paypal.com/v1/payments/authorization/9T287484DP554682S/capture",
"rel":"capture",
"method":"POST"
@jcleblanc
jcleblanc / node_sdk_response.js
Created April 20, 2013 05:56
Response object from the PayPal Node.js SDK
{ id: 'CARD-3G9597783S5131059KFZC2GQ',
valid_until: '2016-04-19T00:00:00.000Z',
state: 'ok',
type: 'visa',
number: 'xxxxxxxxxxxx0331',
expire_month: '11',
expire_year: '2018',
first_name: 'Joe',
last_name: 'Shopper',
links: