Skip to content

Instantly share code, notes, and snippets.

@sunnygleason
sunnygleason / pubnub_initialstate_block.js
Created March 14, 2017 19:10
PubNub IoT Time Series BLOCK w/ InitialState
export default (request) => {
const xhr = require('xhr');
const accessKey = "YOUR_ACCESS_KEY";
const bucketKey = "YOUR_BUCKET_KEY";
const event = request.message.event;
const http_options = {
"method": "POST",
@sunnygleason
sunnygleason / pubnub_initialstate_ui.html
Created March 14, 2017 19:08
PubNub IoT Time Series UI w/ IntialState
<!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_bot_ui.html
Last active March 14, 2017 17:48
PubNub Bot Integration UI w/ Gupshup
<!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_bot_block.js
Last active March 14, 2017 17:44
PubNub Bot Integration BLOCK w/ Gupshup
//
// NOTE: In Gupshup, your bot should have code like this:
//
// function HttpEndpointHandler(context, event) {
// context.sendResponse("Hello there, the current time is: " + new Date().toISOString());
// }
//
export default (request) => {
const xhr = require('xhr');
@sunnygleason
sunnygleason / pubnub_geo_esri.js
Created March 13, 2017 20:38
PubNub Geocoding BLOCK w/ ESRI
export default (request) => {
let xhr = require('xhr');
let query = require('codec/query_string');
let apiUrl = 'https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/findAddressCandidates';
let queryParams = {
singleLine: request.message.text,
outFields: "*",
f: 'json'
@sunnygleason
sunnygleason / pubnub_geo_esri.html
Last active March 13, 2017 20:23
PubNub Geocoding UI w/ ESRI
<!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_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_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_angular2_basic.html
Last active January 29, 2017 20:58
PubNub Basic 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_newrelic_block.js
Created January 28, 2017 20:43
PubNub Monitoring BLOCK w/ New Relic
export default (request) => {
var xhr = require('xhr');
var accountId = 'YOUR_ACCOUNT_ID';
var insightsKey = 'YOUR_INSIGHTS_KEY';
var url = 'https://insights-collector.newrelic.com/v1/accounts/'
+ accountId + '/events';
var params = {