Skip to content

Instantly share code, notes, and snippets.

View stephenhand's full-sized avatar

Stephen Hand stephenhand

  • Galway, Ireland
View GitHub Profile
@stephenhand
stephenhand / monorepo-nuget-publish.yml
Last active July 5, 2021 17:03
Github actions workflow to publish packages to Nuget from a monorepo based on the tag name
name: Release Package
on:
release:
types: [published]
env:
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
jobs:
@stephenhand
stephenhand / BearSslMqttStateMachine.h
Created June 16, 2019 15:50
The, lightweight, zero allocations Paho MQTT Embedded C/C++ client ( https://www.eclipse.org/paho/clients/c/embedded/ https://github.com/eclipse/paho.mqtt.embedded-c ) and the lightweight zero allocations BearSSL TLS implementation ( https://bearssl.org/ ), a marriage made in heaven right? Here's some (C++) code to get them working together
#if !defined(BEARSSLMQTTSTATEMACHINE_H)
#define BEARSSLMQTTSTATEMACHINE_H
#include <bearssl.h>
//Almost the same as the 'simple I/O' state machine included in BearSSL, but with the state logic modified to fit the MQTT use case
namespace BearSslMqttStateMachine
{
/* see bearssl_ssl.h */
void init(br_sslio_context *ctx,
@stephenhand
stephenhand / SynchronousVolley.java
Last active September 18, 2018 17:55
A class that permits the use of synchronous blocking HTTP requests in volley. It also makes no use of the main thread whilst handling requests (which volley does by default, even RequestFuture runs the code to make the response object available on the main thread). Instead it configures its own looper thread to process responses on.
package ie.com.handysolutions.android.http;
import android.content.Context;
import android.os.Handler;
import android.os.Looper;
import com.android.volley.ExecutorDelivery;
import com.android.volley.Network;
import com.android.volley.Request;
import com.android.volley.RequestQueue;
@stephenhand
stephenhand / StreamInputStream.java
Last active August 15, 2019 07:47
InputStream implementation that takes a Java 8 Stream of byte arrays as a data source. Allows you to take any stream, map them to a stream of byte arrays, then once you wrap that stream in a 'StreamInputStream', you can pass it into any API that expects the Java InputStream API.
package com.handysolutions.functional;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Spliterator;
import java.util.stream.Stream;
/**
* An implementation of an InputStream that takes a Java 8 stream of byte arrays as its input