Skip to content

Instantly share code, notes, and snippets.

@sunnygleason
sunnygleason / garage.js
Created August 28, 2016 22:59
Liftmaster Garage Control Integration w/ PubNub and Node.JS
var CTRL_CHAN, DOOR_STATES, HOME_CHAN, LIFTMASTER_PASSWORD, LIFTMASTER_USERNAME,
MyQ, PUB_KEY, PubNub, SUB_KEY, garage, initPubNub, makeHandler, pubnubConns,
refreshStatus, _;
_ = require('underscore');
MyQ = require('liftmaster');
PubNub = require('pubnub');
LIFTMASTER_USERNAME = 'YOUR_LIFTMASTER_USERNAME';
LIFTMASTER_PASSWORD = 'YOUR_LIFTMASTER_PASSWORD';
@sunnygleason
sunnygleason / pubnub_wason_sentiment.js
Created October 26, 2016 12:00
PubNub Sentiment Analysis with IBM Watson BLOCK
const xhr = require('xhr');
const qs = require('codec/query_string');
export default (request) => {
const apiUrl = 'https://gateway-a.watsonplatform.net/calls/text/TextGetTextSentiment';
const apiKey = '0000000000000000000000000000000000000000';
const querystring = qs.stringify({
outputMode: 'json',
showSourceText: false,
@sunnygleason
sunnygleason / pubnub_watson_tts.js
Last active January 15, 2020 06:43
PubNub Text-to-Speech BLOCK with IBM Watson
const console = require('console');
const xhr = require('xhr');
const store = require('kvstore');
const query = require('codec/query_string');
const auth = require('codec/auth');
export default (request) => {
// watson api token
const username = '00000000-0000-0000-0000-000000000000';
const password = '000000000000';
@sunnygleason
sunnygleason / pubnub_google_maps.html
Created January 31, 2017 17:59
PubNub Mapping w/ Google Maps
<!doctype html>
<html>
<head>
<title>Google Maps Example</title>
<script src="https://cdn.pubnub.com/sdk/javascript/pubnub.4.4.1.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" />
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" />
</head>
<body>
<div class="container">
@sunnygleason
sunnygleason / pubnub_mapbox.js
Created November 2, 2016 03:04
PubNub Geocoding and Mapping w/ MapBox BLOCK
let xhr = require('xhr');
let query = require('codec/query_string');
export default request => {
let mapbox_clientToken = '000000000000000000000000000000000000000000000000000000000000000000000000';
let mapbox_geo_apiUrl = 'https://api.mapbox.com/geocoding/v5/mapbox.places/';
let mapbox_maps_apiUrl = 'https://api.mapbox.com/styles/v1/mapbox/streets-v8/static';
let searchParam = request.message.query;
@sunnygleason
sunnygleason / pubnub_twitter_ui.html
Last active September 6, 2017 18:51
PubNub Twitter Publisher BLOCK UI
<!DOCTYPE html>
<html>
<head>
<title>Angular 2</title>
<script src="https://unpkg.com/core-js@2.4.1/client/shim.min.js"></script>
<script src="https://unpkg.com/zone.js@0.7.2/dist/zone.js"></script>
<script src="https://unpkg.com/reflect-metadata@0.1.9/Reflect.js"></script>
<script src="https://unpkg.com/rxjs@5.0.1/bundles/Rx.js"></script>
<script src="https://unpkg.com/@angular/core/bundles/core.umd.js"></script>
@sunnygleason
sunnygleason / pubnub_angular2_expanded.html
Created January 29, 2017 20:30
PubNub Expanded Chat UI w/ Angular2
<!DOCTYPE html>
<html>
<head>
<title>Angular 2</title>
<script src="https://unpkg.com/core-js@2.4.1/client/shim.min.js"></script>
<script src="https://unpkg.com/zone.js@0.7.2/dist/zone.js"></script>
<script src="https://unpkg.com/reflect-metadata@0.1.9/Reflect.js"></script>
<script src="https://unpkg.com/rxjs@5.0.1/bundles/Rx.js"></script>
<script src="https://unpkg.com/@angular/core/bundles/core.umd.js"></script>
@sunnygleason
sunnygleason / pubnub_infobip_ui.html
Last active August 29, 2017 18:14
PubNub SMS sender w/ Infobip API
<!DOCTYPE html>
<html>
<head>
<title>Angular 2</title>
<script src="https://unpkg.com/core-js@2.4.1/client/shim.min.js"></script>
<script src="https://unpkg.com/zone.js@0.7.2/dist/zone.js"></script>
<script src="https://unpkg.com/reflect-metadata@0.1.9/Reflect.js"></script>
<script src="https://unpkg.com/rxjs@5.0.1/bundles/Rx.js"></script>
<script src="https://unpkg.com/@angular/core/bundles/core.umd.js"></script>
@sunnygleason
sunnygleason / pubnub_infobip_function.js
Last active August 29, 2017 18:07
PubNub SMS sender FUNCTION JavaScript
const INFOBIP_API_KEY = 'YOUR_API_KEY';
const INFOBIP_API_URL = 'https://api.infobip.com/sms/1/text/single';
const SUCCESSFUL_SMS_STATUS_GROUPS = [1, 3];
const pubNub = require('pubnub');
const xhr = require('xhr');
function composeOptions(apiKey, body) {
return {
method: 'POST',
@sunnygleason
sunnygleason / pubnub_mnubo_function.js
Created August 4, 2017 17:22
PubNub IoT Events FUNCTION w/ Mnubo
const XHR = require('xhr');
const db = require('kvstore');
const basicAuth = require('codec/auth');
function fetchAccessToken(authUri, clientId, clientSecret) {
const auth = basicAuth.basic(clientId, clientSecret);
const httpOptions = {
method: 'POST',
body: 'grant_type=client_credentials&scope=ALL',
headers: {