Skip to content

Instantly share code, notes, and snippets.

View lolgesten's full-sized avatar
🌴
barcelona

Martin Algesten lolgesten

🌴
barcelona
View GitHub Profile
@lolgesten
lolgesten / tokio.rs
Last active March 30, 2021 16:52
futures::io::AsyncRead/AsyncWrite conversion to tokio::io::AsyncRead/AsyncWrite
use futures_io::{AsyncRead, AsyncWrite};
use std::fmt;
use std::io;
use std::pin::Pin;
use std::task::{Context, Poll};
use tokio::io::AsyncRead as TokioAsyncRead;
use tokio::io::AsyncWrite as TokioAsyncWrite;
pub trait Stream: AsyncRead + AsyncWrite + Unpin + Send + 'static {}
@lolgesten
lolgesten / jws.rs
Last active December 30, 2018 12:17
JWS in rust
#!/usr/bin/env run-cargo-script
//! ```cargo
//! [package]
//! edition = "2018"
//!
//! [dependencies]
//! openssl = "*"
//! base64 = "*"
//! ```
extern crate futures;
extern crate tokio;
use futures::*;
use std::sync::Arc;
use std::sync::Mutex;
use std::thread;
use std::time::Duration;
// Test stream struct.
@lolgesten
lolgesten / tokio-streams.rs
Last active May 29, 2018 07:48
Tokio streams (and futures) example without I/O
extern crate futures;
extern crate tokio;
// instead of tokio::prelude, which also re-exports streams and futures,
// we use the futures crate directly to get access to futures::sync::mspc
use futures::*;
use std::thread;
use std::time::Duration;
@lolgesten
lolgesten / readme.ts
Last active May 5, 2018 14:52 — forked from staltz/readme.ts
callbag-typescript-proof-of-concept
// tslint:disable no-expression-statement no-let
/**
* Callbag loves TypeScript
*
* Copy-paste this into http://www.typescriptlang.org/play/index.html
*/
enum CallbagOper {
Greet,
/// <reference types="mocha"/>
/// <reference types="node" />
import xs from '../../src/index';
import * as assert from 'assert';
describe.only('xs.from', () => {
it('should have the correct order in an observable', (done: any) => {
const START_STATE = {
ver: 0, // counts up to see out of order