Skip to content

Instantly share code, notes, and snippets.

Avatar

Sunny Gleason sunnygleason

View GitHub Profile
@sunnygleason
sunnygleason / pubnub_kvstore_ui.html
Created Apr 21, 2017
Advanced BLOCKS Techniques - KV Store UI
View pubnub_kvstore_ui.html
<!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_kvstore_block.js
Created Apr 21, 2017
Advanced BLOCKS Techniques - KV Store BLOCK
View pubnub_kvstore_block.js
export default (request) => {
const db = require('kvstore');
var by = request.message.by || request.params.uuid;
var last_key = by + ":last_msg";
var count_key = by + ":count";
if (request.message && (request.message.text == '/my_stats')) {
//
// special "my_stats" command handling
@sunnygleason
sunnygleason / pubnub_events_ui.html
Last active Apr 19, 2017
Advanced BLOCKS Techniques - Event Types UI
View pubnub_events_ui.html
<!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_events_block.js
Created Apr 19, 2017
Advanced BLOCKS Techniques - Event Types BLOCK
View pubnub_events_block.js
export default (request) => {
const pubnub = require('pubnub');
var message = "Welcome, ";
var punctuation = "!";
if (request.message.action == 'join') {
message = "Welcome, ";
punctuation = "!";
} else if (request.message.action == 'timeout') {
@sunnygleason
sunnygleason / pubnub_encrypt_block.js
Created Apr 19, 2017
Advanced BLOCKS Techniques - Channel Encryption & Meta Attributes BLOCK
View pubnub_encrypt_block.js
export default (request) => {
// NOTE: message metadata attributes are stored in `request.params.meta`
// NOTE: overall metadata attributes are stored in `request.meta`
// NOTE: message metadata attributes are a JSON string, read-write, but must be parsed/stringified to change
// NOTE: overall metadata attributes are read-only
if (request && request.params && request.params.meta) {
let attrs = JSON.parse(request.params.meta);
// to show attrs or request, uncomment:
// console.log(attrs);
@sunnygleason
sunnygleason / pubnub_encrypt_ui.html
Last active Apr 19, 2017
Advanced BLOCKS Techniques - Channel Encryption & Meta Attributes UI
View pubnub_encrypt_ui.html
<!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_aiception_ui.html
Created Mar 21, 2017
PubNub Image Recognition UI w/ AIception
View pubnub_aiception_ui.html
<!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_aiception_block.js
Created Mar 21, 2017
PubNub Image Recognition BLOCK w/ AIception
View pubnub_aiception_block.js
export default (request) => {
const xhr = require('xhr');
const base64 = require('codec/base64');
const authToken = 'YOUR_AUTH_TOKEN';
const url = "https://aiception.com/api/v2.1/detect_object";
const httpOptions = {
"method": "POST",
"timeout": 10000,
@sunnygleason
sunnygleason / pubnub_wia_ui.html
Last active Mar 19, 2017
PubNub IoT Messaging UI w/ Wia
View pubnub_wia_ui.html
<!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_wia_block.js
Created Mar 14, 2017
PubNub IoT Messaging BLOCK w/ Wia
View pubnub_wia_block.js
export default (request) => {
const xhr = require('xhr');
const authKey = request.message.authKey;
const url = "https://api.wia.io/v1/events";
const http_options = {
"method": "POST",
"headers": {
"Content-Type": "application/json",
You can’t perform that action at this time.