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
<script src="pubnub.js"></script>
<script>(async()=>{
'use strict';
const pubnub = PubNub({ subscribeKey: 'demo', publishKey: 'demo' });
pubnub.subscribe({
channel: 'my_channel',
messages: (message) => document.body.innerHTML += `<div>${message}</div>`,
});
@stephenlb
stephenlb / chatroom-security.md
Last active November 21, 2021 16:27
Chatroom Security

Chat User Identification with Digital Signature Message Verification

You can identify the sender by creating a Unique ID as well as a Name attached to the message payload of the chat conversation. This is similar to IRC strategies but a bit more simplistic.

var user_id      = PUBNUB.uuid();
var user_name    = name.value;
var user_message = input.vaule;
@stephenlb
stephenlb / subscribe.sh
Last active July 8, 2021 18:19
Bash and Shell Command PubNub Subscribe in One Line - Basic TCP Subscribe Calls
## =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
## URL Variables
## http://p.pubnub.com/stream/<SUBKEY>/<CHANNEL>/0/-1
## =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
## Demo Stream
while true; do (printf 'GET http://p.pubnub.com/stream/sub-c-5f1b7c8e-fbee-11e3-aa40-02ee2ddab7fe/pubnub-sensor-network/0/-1 HTTP/1.1\r\nHost: pubnub\r\n\r\n'; sleep 5) | nc p.pubnub.com 80; done
## Local tunnel
curl "http://0.0.0.0:80/publish/demo-36/demo-36/0/ch6/0/1"
@stephenlb
stephenlb / index.js
Last active July 6, 2021 18:23
PubNub Function for Microsoft's Translate V3 API
const PubNub = require('pubnub');
const readline = require('readline');
const pubnub = new PubNub({
publishKey: "pub-c-716a3b86-1770-4e00-985f-f12211d9def9",
subscribeKey: "sub-c-535a73fe-de7d-11eb-ad9d-a277214e1d91",
});
const channel = "translate";
pubnub.addListener({
message: function(event) {
@stephenlb
stephenlb / sign-grant.html
Created May 28, 2021 18:57
Grant Signature PubNub Access Manager (PAM) HMAC SHA-256 - JavaScript
Open Dev Console
<script>(async ()=>{
'use strict';
let secret = "sec-demo";
let enc = new TextEncoder("utf-8");
let body = "GET\npub-demo\n/v2/auth/grant/sub-key/sub-demo\nauth=myAuthKey&g=1&target-uuid=user-1&timestamp=1595619509&ttl=300";
let algorithm = { name: "HMAC", hash: "SHA-256" };
@stephenlb
stephenlb / pubnub-python-publish.py
Last active February 4, 2021 02:47
USE THIS https://github.com/stephenlb/pubnub-python-docker - THE CODE BELOW IS FINE< BUT IF YOU WANT DOCKERFILE, USE REPO
import pubnub#pubnub==4.0.2
import time
from pubnub.pnconfiguration import PNConfiguration
from pubnub.pubnub import PubNub
pnconf = PNConfiguration()
pnconf.subscribe_key = "demo"
pnconf.publish_key = "demo"
pubnub = PubNub(pnconf)
@stephenlb
stephenlb / cryptoDashboard.html
Last active December 13, 2020 14:43
Realtime Ticker Price Changes for Ethereum, Bitcoin and Litecoin.
<!DOCTYPE html>
<html>
<head>
<title>Crypto Currency Prices</title>
<script src="https://cdn.pubnub.com/sdk/javascript/pubnub.4.18.0.min.js"></script>
<script type="text/javascript" src="https://pubnub.github.io/eon/v/eon/1.0.0/eon.js"></script>
<link type="text/css" rel="stylesheet" href="https://pubnub.github.io/eon/v/eon/1.0.0/eon.css"/>
</head>
<body>
@stephenlb
stephenlb / tls.sh
Last active November 16, 2020 22:22
Test TLS SSL Ciphers on a Server - Which Ciphers and TLS Protocols does the server support?
#!/bin/zsh
## - - - - - - - - - - - - - - - - - - - - - - - - - - -
## Usage
## - - - - - - - - - - - - - - - - - - - - - - - - - - -
##
## ./tls.sh <SERVER_IP_OR_DOMAIN_NAME>
##
## ./tls.sh pubnub.com
## ./tls.sh ps.pndsn.com
@stephenlb
stephenlb / animated-gif.md
Last active October 31, 2020 22:57
DIY How to make your own HD Animated GIF Generator

HD Animated GIF Generator

You can make your own HD animated GIF generator.
Follow along with these commands to get started.

HD Animated GIF Generator

git clone git://source.ffmpeg.org/ffmpeg.git
cd ffmpeg
@stephenlb
stephenlb / webrtc-demo.html
Last active August 31, 2020 21:34
WebRTC on localhost and HTTPS answer for StackOverflow http://stackoverflow.com/a/41969170/524733 - you must run an HTTPS server even on localhost.
<!DOCTYPE html>
<html>
<form id='loginForm'>
<input id='username' placeholder='Pick a username!' />
<input type='submit' value='Log In'>
</form>
<form id='callForm'>
<input id='number' placeholder='Enter user to dial!' />
<input type='submit' value='Call'/>