Skip to content

Instantly share code, notes, and snippets.

View stephenlb's full-sized avatar
😁
Coding Python, Rust, JavaScript, AI

Stephen Blum stephenlb

😁
Coding Python, Rust, JavaScript, AI
View GitHub Profile
@stephenlb
stephenlb / pubnub.clj
Last active November 14, 2015 05:26
PubNub V2 Streaming Publish/Susbscribe Clojure Library
(ns pubnub
(:require [ clojure.data.json :as json ])
(:require [ clojure.string :as str ])
(:require [ clj-sockets.core :as sock ])
(:require [ clojure.core.async :as async ])
(:require [ org.httpkit.client :as http ])
(:import [ java.net URLEncoder ]))
;; =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
;; Declaring
@stephenlb
stephenlb / https.py
Last active January 25, 2024 12:24
HTTPS Server - All-in-One Secure HTTPS Server
#!/usr/bin/python
# server
# python https.py
#
# browser
# https://0.0.0.0:4443
import BaseHTTPServer
import SimpleHTTPServer
@stephenlb
stephenlb / sentiment.js
Created April 8, 2016 17:54
Sentiment Event Handler
function process(request){
var XHR = require("xhr");
var r = XHR.get("https://alchemy.p.mashape.com/text/TextGetTextSentiment",
{"query-params": {
"outputMode":"json",
"showSourceText":false,
"text":request.message.text,
"mashape-key":" -- YOUR MASHAPE KEY HERE -- "
@stephenlb
stephenlb / functions-rest-api.md
Last active April 8, 2024 15:58
PubNub Functions REST APIs using CURL Commands

PubNub Functions REST APIs using CURL Commands

PubNub Functions

Authenticate with an email and password to receive a session_token. The Session Token will be a top level key called token. The Session Token token is used for all requests after authentication. You also receive a user_id which is used in your apps and keys lookup.

Login

@stephenlb
stephenlb / example.html
Last active September 20, 2016 21:40
PubNub Tiny SDK in 150 lines of JavaScript
<!-- include tiny sdk -->
<script src="pubnub-tiny.js"></script>
<!-- usage example -->
<script>
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
// Initiate
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
var ref = subscribe({
subkey : 'YOUR_SUBSCRIBE_KEY_HERE'
@stephenlb
stephenlb / blocks-message-copy.js
Last active February 7, 2017 23:27
PubNub Message Copy - https://admin.pubnub.com/#/blocks/1165/import - Copy a Message between PubNub Keys 🎉
export default (request) => {
const xhr = require('xhr')
const pub_key = 'demo' // YOUR 2nd PUBLISH KEY
const sub_key = 'demo' // YOUR 2nd SUBSCRIBE KEY
const chncopy = request.channels[0]
const msgcopy = JSON.stringify(request.message)
const url = "http://pubsub.pubnub.com/publish/" + [
pub_key, sub_key, 0, chncopy, 0, msgcopy
].join('/')
@stephenlb
stephenlb / open-growth-sdk-notes.md
Last active October 7, 2016 17:37
Open Growth SDK - Salesforce Killer - For SaaS companies. Replace your Sales and Marketing team with ML/AI interactivity.
@stephenlb
stephenlb / dustin.js
Last active November 14, 2016 20:52
Stephen's Hash Function - used in PubNub's global Data Stream Network - note the original algorithm is written in ANSI C. This is a Translation for JavaScript Developers.
function hash( key, seed ) {
var seed = seed || 5381;
var len = Buffer.byteLength(key, 'utf8');
var data = key;
var nblocks = len / 16;
var h1 = seed;
var h2 = seed;
var h3 = seed;
var h4 = seed;
@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)