Skip to content

Instantly share code, notes, and snippets.

View dzeitman's full-sized avatar

Dan Zeitman dzeitman

View GitHub Profile
@dzeitman
dzeitman / PubSub
Last active January 25, 2017 06:45
<!-- Include the PubNub Library -->
<script src="https://cdn.pubnub.com/sdk/javascript/pubnub.[version number].js"></script>
<!-- Instantiate PubNub -->
<script type="text/javascript">
var pubnubDemo = new PubNub({
publishKey: 'Your Publish Key Here',
subscribeKey: 'Your Subscribe Key Here'
});
@dzeitman
dzeitman / PubNubBlock-IBM-TONAL
Created March 15, 2017 00:17
IBM Tonal Analysis Block
export default (request) => {
const base64Codec = require('codec/base64');
const xhr = require('xhr');
const qs = require('codec/query_string');
const credentials = {
url: 'https://gateway.watsonplatform.net/tone-analyzer/api/v3/tone',
username: '<IBM USERNAME>',
password: '<IBM PASSWORD>'
var request = require('request-promise');
module.exports = function(ctx, cb) {
var opts = {
uri: 'https://api.meetup.com/2/events.json',
qs:{
group_id: ctx.meta.group_id,
key: ctx.secrets.meetup_token,
},
json: true
'use strict';
module.exports = (context, cb) => {
console.log(context);
// post we use body
if(context.body.token != context.secrets.app_token){
const msg = 'Not authorized to use this service outside of our company slack channel';
cb(null,msg);
'use strict';
module.exports = (context, cb) => {
console.log(context);
// post we'll use context.body
if(context.body.token != context.secrets.app_token){
const msg = 'Not authorized to use this service outside of our company slack channel';
cb(null,msg);
}else{

Cloudinary's API's provide some great capibilities such as auto tagging.
Sometimes developers want to expand on that by calling other Third Party APIS such as IBM Watson.

In this example we'll take an asset previously uploaded to cloudinary and use IBM Watson services to classify the image to find out what's in the image and then combine the image metadata into a JSON payload, and save that payload back to Cloudinary as a Static JSON resource.

This simple pattern allows for caching the meta data within a static file.
This scenerio might be used versus calling Watson API's each time you want to retrieve the additional meta data.

/**
1> Create a webtask.
2> Add NPM Module for Cloudinary
3> Add secrets for your cloud, api_key and api_secret
*/
var cloudinary = require("cloudinary");
function autoTagByID(context, cb){
@dzeitman
dzeitman / crop-all-faces.js
Last active April 22, 2018 03:27
fetch image with multiple faces and return cropped faces array;
/**
1> Create a webtask.
2> Add NPM Module for Cloudinary
3> Add secrets for your cloud, api_key and api_secret
*/
var cloudinary = require("cloudinary");
var namor = require('namor');
@dzeitman
dzeitman / Example Results
Last active May 7, 2018 19:15
Cloudinary Video upload with Caterorization and VTT creation options example
{
"public_id": "cloudinary-video-promo",
"version": 1525707742,
"signature": "7b87e2472042e8565e51c212d5c37be05498c96f",
"width": 1920,
"height": 1080,
"format": "mp4",
"resource_type": "video",
"created_at": "2018-05-07T15:42:22Z",
"tags": [],
const cloudinary = require('cloudinary');
const express = require('express');
const Webtask = require('webtask-tools');
const bodyParser = require('body-parser');
const request = require('request');
const JSONP = require('node-jsonp');
var Algorithmia = require('algorithmia');