Skip to content

Instantly share code, notes, and snippets.

View stephenlb's full-sized avatar
😀
Coding with Rust

Stephen Blum stephenlb

😀
Coding with Rust
View GitHub Profile
@stephenlb
stephenlb / main.js
Last active December 21, 2015 22:09 — forked from dristic/main.js
var pubnub = PUBNUB.init({
publish_key : '<PUBLISH_KEY>',
subscribe_key : '<SUBSCRIBE_KEY>'
})
pubnub.subscribe({
channel : "my_channel",
message : function (message) {
console.log("I got the message: " + message)
},
@stephenlb
stephenlb / 1.js
Created October 29, 2013 18:28 — forked from ToeJamson/1.js
<div
channel-name=notifications-channel
segregate-notifications-by-page=false
id=desktop-notifications-config
></div>
<div id=pubnub pub-key=demo sub-key=demo></div>
<script src=http://http://cdn.pubnub.com/pubnub-3.5.4.min.js></script>
<script
src=http://www.pubnub.com/static/html5-desktop-notification-broadcasting.js
></script>
@stephenlb
stephenlb / analytics.html
Created November 22, 2013 19:39
We finally integrated a full Funnel Tracking System that allows us to track Revenue Generated per External Marketing Project. Please use the following JavaScript Snippet on all Projects going forward:
<script>
piAId='29622';
piCId='23596';
(function(){
function async_load(){
var s=document.createElement('script');s.type='text/javascript';
s.src=('https:'==document.location.protocol?'https://pi':'http://cdn')
+'.pardot.com/pd.js';
var c=document.getElementsByTagName('script')[0];
c.parentNode.insertBefore(s,c);}
@stephenlb
stephenlb / mtgox.js
Last active December 31, 2015 02:48
Stream Trade and Price Ticker Data from Mt.Gox via JavaScript. To learn more, visit http://rtbitcoin.co and also visit https://en.bitcoin.it/wiki/MtGox/API/Pubnub
(function(){
/*
// ----------------------------- //
// -- MTGOX TICKER DISPLAY -- //
// ----------------------------- //
PUBNUB.events.bind( 'trade.BTC', function(data) { console.log(data); } );
// ----------------------------- //
@stephenlb
stephenlb / 1.html
Last active December 31, 2015 18:19 — forked from ToeJamson/1.js
<script src="http://cdn.pubnub.com/pubnub.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.0.8/angular.min.js"></script>
<script src="http://pubnub.github.io/angular-js/scripts/pubnub-angular.js"></script>
@stephenlb
stephenlb / 1.html
Last active October 27, 2018 05:10 — forked from ToeJamson/1.js
Enter Chat and press enter
<div><input id=input placeholder=you-chat-here /></div>
Chat Output
<div id=box></div>
<script src=http://cdn.pubnub.com/pubnub.min.js></script>
<script>(function(){
var pubnub = PUBNUB.init({publish_key:'demo',subscribe_key:'demo',ssl:true});
var box = PUBNUB.$('box'), input = PUBNUB.$('input'), channel = 'chat';
@stephenlb
stephenlb / timetoken.js
Created December 21, 2013 01:13
PubNub JavaScript SDK TimeToken Access on Subscribe.
PUBNUB.subscribe({
channel : "hello_world",
message : function( message, envelope, channel ) {
// TIMETOKEN
console.log(envelope[1]);
}
})
@stephenlb
stephenlb / pam-example.py
Last active May 25, 2020 02:43
NEW UPDATE: https://github.com/pubnub/python/tree/master/python <-- PubNub Access Manager (PAM) Python Full Library for Granting and Revoking Access in Real-Time on the PubNub Real-Time Network.
import pam
## PubNub Access Manager (PAM)
manager = pam.access(
pubkey="pam",
subkey="pam",
seckey="pam"
)
## Grant User Access
@stephenlb
stephenlb / calculate-payload-size.js
Last active January 2, 2016 04:19
Calculating a PubNub Message Payload Size. This is necessary to prevent yourself from getting a "Message Too Large" gateway response.
(function(){
// Calculating a PubNub Message Payload Size.
function calculate_payload_size( channel, message ) {
return encodeURIComponent( channel + JSON.stringify(message) ).length + 97;
}
})();
@stephenlb
stephenlb / channels.json
Last active January 2, 2016 13:49
Loading History from PubNub Mt.Gox Trades. These are resource files for a StackOverflow answer found here: http://stackoverflow.com/questions/20976433/how-to-retrieve-more-than-100-messages-from-the-history-of-a-pubnub-channel/20988208#20988208
{
"ticker.LTCGBP": "0102a446-e4d4-4082-8e83-cc02822f9172",
"ticker.LTCCNY": "0290378c-e3d7-4836-8cb1-2bfae20cc492",
"depth.BTCHKD": "049f65dc-3af3-4ffd-85a5-aac102b2a579",
"depth.BTCEUR": "057bdc6b-9f9c-44e4-bc1a-363e4443ce87",
"ticker.NMCAUD": "08c65460-cbd9-492e-8473-8507dfa66ae6",
"ticker.BTCEUR": "0bb6da8b-f6c6-4ecf-8f0d-a544ad948c15",
"depth.BTCKRW": "0c84bda7-e613-4b19-ae2a-6d26412c9f70",
"depth.BTCCNY": "0d1ecad8-e20f-459e-8bed-0bdcf927820f",
"ticker.BTCCAD": "10720792-084d-45ba-92e3-cf44d9477775",