Skip to content

Instantly share code, notes, and snippets.

😀
Coding with Rust

Stephen Blum stephenlb

😀
Coding with Rust
View GitHub Profile
@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 Aug 2, 2020
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 May 5, 2018
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;
}
@stephenlb
stephenlb / 1.js
Created Nov 15, 2017 — forked from ptrhub901/1.js
Streaming Sensor Readings to a Realtime Gauge Chart
View 1.js
var five = require("johnny-five");
var board = new five.Board();
var pubnub = new PubNub({
subscribeKey: "mySubscribeKey",
publishKey: "myPublishKey",
ssl: true
})
@stephenlb
stephenlb / publishMsg.c
Created Nov 15, 2017 — forked from ptrhub901/publishMsg.c
Code chunks from project javamon
View publishMsg.c
// Publish the value using PubNub
static void publishMsg (void)
{
// Check values for I2C line error...
if (TWI_msg[0] > 99 || TWI_msg[1] > 99) {
TWI_fullMsg = 10000;
}
// Ignore very small values
else if (TWI_msg[0] == 0 && TWI_msg[1] < 50) {
TWI_fullMsg = 0;
You can’t perform that action at this time.