Skip to content

Instantly share code, notes, and snippets.

Avatar
😀
Coding with Rust

Stephen Blum stephenlb

😀
Coding with Rust
View GitHub Profile
@stephenlb
stephenlb / sign-grant.html
Created May 28, 2021
Grant Signature PubNub Access Manager (PAM) HMAC SHA-256 - JavaScript
View sign-grant.html
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 / tls.sh
Last active Nov 16, 2020
Test TLS SSL Ciphers on a Server - Which Ciphers and TLS Protocols does the server support?
View tls.sh
#!/bin/zsh
## - - - - - - - - - - - - - - - - - - - - - - - - - - -
## Usage
## - - - - - - - - - - - - - - - - - - - - - - - - - - -
##
## ./tls.sh <SERVER_IP_OR_DOMAIN_NAME>
##
## ./tls.sh pubnub.com
## ./tls.sh ps.pndsn.com
@stephenlb
stephenlb / http2-request.py
Last active Jun 4, 2019
Make an HTTP/2 Request, works as a PIPE command into openssl s_client.
View http2-request.py
#!/usr/bin/env python
from __future__ import print_function
import struct
HTTP2_HEADER="PRI * HTTP/2.0\r\n\r\nSM\r\n\r\n"
# Does the thing for a frame
def frame(ty, flags, streamid, payload):
return struct.pack(">L", len(payload))[1:4] + struct.pack(">BBL", ty, flags, streamid) + payload
@stephenlb
stephenlb / subscribe.py
Created Aug 8, 2018
Python Subscribe: Basic Worker. Super Simple
View subscribe.py
import multiprocessing
import requests
SUB_KEY = 'demo'
CHANNELS = ['my_channel']
def main():
mp = multiprocessing.Process(target=subscriber)
mp.start()
mp.join()
@stephenlb
stephenlb / index.js
Created May 1, 2018 — forked from ajb413/index.js
audio lext test
View index.js
var AWS = require('aws-sdk');
AWS.config.update({
accessKeyId: "__id__",
secretAccessKey: "__secret__",
});
var lexruntime = new AWS.LexRuntime({region: 'us-east-1'});
@stephenlb
stephenlb / microsoft-translate-v3.js
Last active Apr 12, 2018
PubNub BLOCK for Microsoft's Translate V3 API
View microsoft-translate-v3.js
// Demo URL https://codepen.io/team/PubNub/pen/rdQMaN
// ALERT!
// YOU NEED TO ADD YOUR MICROSFOT API KEY 'Ocp-Apim-Subscription-Key'
//
// 1.) Click "My Secrets" button.
// 2.) Add a new Secret 'Ocp-Apim-Subscription-Key'
// 3.) Paste in your Microsoft Translator V3 API Key
// 4.) Save
// 5.) Restart/Start your Module
@stephenlb
stephenlb / pubnub-smart-contract.sol
Last active Jan 31, 2018
PubNub on Ethereum "Web3" Decentralized Network as a Smart Contract
View pubnub-smart-contract.sol
pragma solidity ^0.4.19;
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
// PubNub on Ethereum "Web3" Decentralized Network as a Smart Contract
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
contract PubNubV1 {
mapping(bytes32 => mapping(bytes32 => bytes32)) private channel_groups;
mapping(bytes32 => mapping(bytes32 => bytes32)) private channel_presence;
event Message(
@stephenlb
stephenlb / always-readme.md
Last active Jun 1, 2021
Solidity Smart Contract all-in-one that allows the crowd-sale of custom tokens for as long as the owner wallet balance is above zero. See readme for more details.
View always-readme.md

Simplified Modifiable ERC20 Token Details

Controllable Crowd-sale and transferable ownership allows you to change ownership and change exchange rates.

  • Owner Wallet receives ETH funds.
  • Owner Wallet holds TOKEN's for sale.
  • Moving tokens from owner wallet to another removes publicly purchaseable token inventory.
  • Custom Exchange Rate ETH for YOUR TOKEN. Default is 1:10 One ETH = 10 YOUR TOKEN.
  • Changable Exchange Rate at any time!
@stephenlb
stephenlb / cryptoDashboard.html
Last active Dec 13, 2020
Realtime Ticker Price Changes for Ethereum, Bitcoin and Litecoin.
View cryptoDashboard.html
<!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>
View pubnubheartrateios-captureframe
- (void)captureOutput:(AVCaptureOutput *)captureOutput didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer fromConnection:(AVCaptureConnection *)connection {
// if we're paused don't do anything
if(self.currentState==STATE_PAUSED) {
// reset our frame counter
self.validFrameCounter=0;
return;
}