Skip to content

Instantly share code, notes, and snippets.

View pblca's full-sized avatar
🔫
projecting

pblc pblca

🔫
projecting
  • garbage.gg
  • San Francisco
View GitHub Profile
@pblca
pblca / instantiate.html
Last active June 18, 2017 05:36
Getting Started Tutorial for Using PubNub with JavaScript
<!-- Include the PubNub Library -->
<script src="https://cdn.pubnub.com/pubnub.min.js"></script>
<!-- Instantiate PubNub -->
<script type="text/javascript">
var PUBNUB_demo = PUBNUB.init({
publish_key: 'Your Publish Key Here',
subscribe_key: 'Your Subscribe Key Here'
});
<!DOCTYPE html>
<html>
<head>
<title>Chester Family Recipes</title>
<link rel= "stylesheet" href="recipestyle.css">
</head>
<body>
<html>
<head>
<!-- Include the QR Generator library -->
<script type="text/javascript" src="/static/js/vendor/qrcode.js"></script>
</head>
<body>
<!-- A DOM object to add the QR code to -->
<div id="qr"></div>
<script>
PUBNUB.publish({
channel : 'mouseMoves',
message : {
x: 400,
y: 200
}
});
pubnub.subscribe({
channel: channel,
// Add presence
presence: function(m){
document.getElementById('occupancy').textContent = m.occupancy;
}
});
PUBNUB_demo.history({
channel : 'demo_tutorial',
count : 100,
callback : function(m){console.log(m)}
});
<!-- Include the PubNub Library -->
<script src="https://cdn.pubnub.com/pubnub.min.js"></script>
<!-- Instantiate PubNub -->
<script type="text/javascript">
var PUBNUB_demo = PUBNUB.init({
publish_key: 'Your Publish Key Here',
subscribe_key: 'Your Subscribe key Here'
});
pubnub.audit({
channel: 'Your_Channel_Name',
callback: function(m){
console.log(m);
}
});
@pblca
pblca / ready.js
Last active August 29, 2015 14:11
Quick Start tutorials for Data Sync
home.on.ready(function(){
syncDoor();
syncLight();
syncMusic();
});
home.on.change(function(ref){
syncDoor();
syncLight();
syncMusic();
<!-- Include the PubNub Library -->
<script src="https://cdn.pubnub.com/pubnub.min.js"></script>
<!-- Instantiate PubNub -->
<script type="text/javascript">
var PUBNUB_demo = PUBNUB.init({
publish_key: 'Your Publish Key Here',
subscribe_key: 'Your Subscribe key Here',
secret_key: 'Your Secret key Here'