Skip to content

Instantly share code, notes, and snippets.

View dmichael's full-sized avatar

David Michael dmichael

View GitHub Profile
@dmichael
dmichael / httpclient.go
Last active October 18, 2023 20:07
Light wrapper for the Go http client adding (essential) timeouts for both connect and readwrite.
package httpclient
import (
"net"
"net/http"
"time"
)
type Config struct {
ConnectTimeout time.Duration

Redux WebSocket Middleware: Example

This Gist provides some code examples of how to implement WebSocket stream handling using a Redux middleware. Please be aware that this is only provided as an example and that critical things like exception handling have not been implemented.

A more complete version has been packaged, tested, and is available on GitHub as redux-websocket. This library has also been published to npm at @giantmachines/redux-websocket.

Middleware

This module represents the foundation of the middleware and implements the ideas presented above. The exported function is used during the creation of the Redux store (see the following snippet).

{
"claims": [
{
"url": "http://celo-332ef5f5-7664-47c0-a798-d404d039aad6.bison.run:8080",
"timestamp": 1579006108,
"type": "ATTESTATION_SERVICE_URL"
},
{
"timestamp": 1579006110,
"type": "ACCOUNT",
{
"claims": [
{
"url": "http://celo-0f01b123-4f79-4db3-b81d-8ce185716a6f.bison.run:8080",
"timestamp": 1579211383,
"type": "ATTESTATION_SERVICE_URL"
},
{
"timestamp": 1579211648,
"type": "ACCOUNT",
{"claims":[{"timestamp":1579006113,"type":"ACCOUNT","address":"0xDbc52f9E934145E2e3172aEAD59303328BBAd2D1"}],"meta":{"address":"0xc5636B98Fd6ddfF3a7bb239E9729D75338E9a61f","signature":"0x7d4ed41d60493f924fa7cd53ed0a7424d07069d3ad43283b68116e729be4aa145f85d96edd5534b2eeb0b39192758166796ac2280a881fab5fffcae2e07aca6a1b"}}
@dmichael
dmichael / celo-stake-off.md
Created December 6, 2019 20:16
Celo Stake Off

CELO_VALIDATOR_GROUP_ADDRESS=c5636b98fd6ddff3a7bb239e9729d75338e9a61f CELO_VALIDATOR_ADDRESS=dbc52f9e934145e2e3172aead59303328bbad2d1

Keybase proof

I hereby claim:

  • I am dmichael on github.
  • I am dmichael (https://keybase.io/dmichael) on keybase.
  • I have a public key ASBeTozA--Pqbk2tqs8b_OOmQu675NOHNMRPoHSTtO9EDgo

To claim this, I am signing this object:

type: sender
params:
symbol: XZC
to: aKNsk9tYEjwL8hUpTfD6rF5WJFPgaM1eG5
amount: 7.5
every: 5 days
# Bitcoin+Lightning node running on mainnet
services:
bitcoin: {}
lnd_bitcoin: {}
@dmichael
dmichael / gist:1362424
Created November 13, 2011 18:11
Sigmoid Gradient
function g = sigmoid(z)
g = sigmoid = 1.0 ./ (1.0 + exp(-z));
end
function g = sigmoidGradient(z)
g = sigmoid(z) .* (1 - sigmoid(z));
end