Skip to content

Instantly share code, notes, and snippets.

Avatar
🔫
projecting

Cody Byrnes codyjb

🔫
projecting
View GitHub Profile
View stream-controller.js
var pubnub = PUBNUB.init({
publish_key : 'pub-c-df94b72e-7d48-4df1-8876-2cccc1afe0f8',
subscribe_key : 'sub-c-c5b3ec0c-d248-11e4-95a3-0619f8945a4f',
ssl : (('https:' == document.location.protocol) ? true : false)
});
function rand(len){
var text = "";
var charset = "abcdefghijklmnopqrstuvwxyz0123456789";
for( var i=0; i < len; i++ ) {
@codyjb
codyjb / instantiate.js
Last active Aug 29, 2015
A Test of multi-language gist changer
View instantiate.js
require('antigravity');
View instantiate.html
<!-- Include the PubNub Library -->
<script src="https://cdn.pubnub.com/pubnub-ds-b2.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'
});
View instantiate.html
<!-- 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'
@codyjb
codyjb / ready.js
Last active Aug 29, 2015
Quick Start tutorials for Data Sync
View ready.js
home.on.ready(function(){
syncDoor();
syncLight();
syncMusic();
});
home.on.change(function(ref){
syncDoor();
syncLight();
syncMusic();
View audit.js
pubnub.audit({
channel: 'Your_Channel_Name',
callback: function(m){
console.log(m);
}
});
View 1_instantiate.html
<!-- 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'
});
View history.js
PUBNUB_demo.history({
channel : 'demo_tutorial',
count : 100,
callback : function(m){console.log(m)}
});
View Occupancy.js
pubnub.subscribe({
channel: channel,
// Add presence
presence: function(m){
document.getElementById('occupancy').textContent = m.occupancy;
}
});
View mouseSpeak.js
PUBNUB.publish({
channel : 'mouseMoves',
message : {
x: 400,
y: 200
}
});