Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
I may be slow to respond.

Bruno Tavares bltavares

💭
I may be slow to respond.
View GitHub Profile
@bltavares
bltavares / main.dart
Created Jul 5, 2022
elegant-sparkle-3214
View main.dart
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 Jul 5, 2022
elegant-sparkle-3214
View main.dart
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 Jul 5, 2022
elegant-sparkle-3214
View main.dart
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 Jul 4, 2022
silent-sunshine-7526
View main.dart
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 Jul 4, 2022
silent-sunshine-7526
View main.dart
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
View fast.rs
// 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() });
View Cargo.toml
[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']
View gist:f37af663cb6f9fb4bd30ccabb1453a2a
[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.
View main.rs
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);
}
});
View rust.rs
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>>`
}