Skip to content

Instantly share code, notes, and snippets.

View bltavares's full-sized avatar
💭
I may be slow to respond.

Bruno Tavares bltavares

💭
I may be slow to respond.
View GitHub Profile
@bltavares
bltavares / main.dart
Created July 5, 2022 23:06
elegant-sparkle-3214
import 'package:flutter/material.dart';
const Color darkBlue = Color.fromARGB(255, 18, 32, 47);
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@bltavares
bltavares / main.dart
Last active July 5, 2022 23:05
elegant-sparkle-3214
import 'package:flutter/material.dart';
const Color darkBlue = Color.fromARGB(255, 18, 32, 47);
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@bltavares
bltavares / main.dart
Created July 5, 2022 18:15
elegant-sparkle-3214
import 'package:flutter/material.dart';
const Color darkBlue = Color.fromARGB(255, 18, 32, 47);
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
@bltavares
bltavares / main.dart
Created July 4, 2022 18:55
silent-sunshine-7526
import 'package:flutter/material.dart';
void main() => runApp(const MyApp());
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
static const String _title = 'Flutter Code Sample';
@override
@bltavares
bltavares / main.dart
Created July 4, 2022 18:52
silent-sunshine-7526
import 'package:flutter/material.dart';
void main() => runApp(const MyApp());
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
static const String _title = 'Flutter Code Sample';
@override
// This concludes immediatlly, as expected
#[async_std::test]
async fn test_listerner_client() {
let addr = next_test_ip4();
// setup listener
let listener = UtpListener::bind(addr).await.unwrap();
// spawn a background task waiting for the connection
task::spawn(async move { listener.accept().await.unwrap() });
[package]
name = "async-internal-spawn"
version = "0.1.0"
authors = ["Ryan James Spencer <spencer.ryanjames@gmail.com>"]
edition = "2018"
[dependencies.async-std]
version = '1.6.2'
features = ['unstable']
[2020-07-16T01:38:29Z DEBUG colmeia_hypercore::network::hyperdrive] Metadata audit: Ok(Audit { valid_blocks: 4, invalid_blocks: 0 })
[2020-07-16T01:38:29Z DEBUG colmeia_hypercore::network::hyperdrive] Metadata len: 4
[2020-07-16T01:38:29Z DEBUG colmeia_hypercore::network::hyperdrive] Content audit: Ok(Audit { valid_blocks: 1, invalid_blocks: 0 })
[2020-07-16T01:38:29Z DEBUG colmeia_hypercore::network::hyperdrive] Content len: 1
[2020-07-16T01:38:29Z DEBUG colmeia_hypercore::observer::event] Error count reached maximum penalty. Bailing.
fn main() {
let client = hypercore_protocol::ProtocolBuilder::initiator().connect(tcp_stream);
let shared_client = Arc::new(async_std::sync::RwLock::new(client));
let bg_client = shared_client.clone();
let bg_task = task::spawn(async move {
while let Ok(e) = bg_client.write().await.loop_next().await {
dbg!(e);
}
});
@bltavares
bltavares / rust.rs
Last active February 8, 2020 16:32
pub fn with_discovery(&mut self, mechanisms: Vec<impl Stream<Item = SocketAddr>>) {
let stream = mechanisms
.into_iter()
.fold(stream::pending(), |init, item| init.merge(item));
/// mismatched types
/// expected struct `async_std::stream::pending::Pending<_>`
/// found struct `async_std::stream::stream::merge::Merge<async_std::stream::pending::Pending<_>, impl Stream<Item = SocketAddr>>`
}