Skip to content

Instantly share code, notes, and snippets.

@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_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_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: {
@sunnygleason
sunnygleason / pubnub_mnubo_ui.html
Created August 4, 2017 17:19
PubNub IoT Events UI w/ Mnubo
<!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_neutrino_ui.html
Created April 25, 2017 18:15
PubNub HTML Sanitizer UI w/ Neutrino
<!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_neutrino_block.js
Last active April 25, 2017 18:14
PubNub HTML Sanitizer BLOCK JavaScript
export default (request) => {
const xhr = require('xhr');
const query = require('codec/query_string');
const userId = 'YOUR_USER';
const apiKey = 'YOUR_API_KEY';
const outputType = 'plain-text';
let apiUrl = 'https://neutrinoapi.com/html-clean';
@sunnygleason
sunnygleason / pubnub_twitter_block.js
Last active April 25, 2017 17:18
PubNub Twitter Publisher BLOCK JavaScript
const xhr = require('xhr');
const base64Codec = require('codec/base64');
const crypto = require('crypto');
export default (request) => {
// see https://apps.twitter.com
const consumerKey = "YOUR_CONSUMER_KEY";
const consumerSecret = "YOUR_CONSUMER_SECRET";
const accessToken = "YOUR_ACCESS_TOKEN";
const oauthTokenSecret = "YOUR_OAUTH_TOKEN_SECRET";
@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_xhr_block.js
Created April 21, 2017 21:01
Advanced BLOCKS Techniques - XHR BLOCK
export default (request) => {
const xhr = require('xhr');
const query = require('codec/query_string'); // for HTTP URL encoding
const auth = require('codec/auth'); // for HTTP Basic Auth
const base64 = require('codec/base64'); // for other custom schemes
const apiUrl = "https://api.duckduckgo.com/?";
var queryString = query.stringify({
q : request.message.text,
@sunnygleason
sunnygleason / pubnub_xhr_ui.html
Last active April 21, 2017 21:02
Advanced BLOCKS Techniques - XHR 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>