try nix-shell -p mariadb-connector-c
to have mysql_config
in scope
from selenium import webdriver | |
from selenium.webdriver.chrome.service import Service as ChromeService | |
from webdriver_manager.chrome import ChromeDriverManager | |
import base64 | |
options = webdriver.ChromeOptions() | |
options.add_argument('--headless') | |
url = "https://google.com" |
package io.policarp | |
import java.io.{BufferedWriter, FileWriter} | |
import java.nio.file.Paths | |
import cats.implicits._ | |
import cats.kernel.Semigroup | |
import io.circe.Printer | |
import io.circe.syntax._ | |
import tapir.docs.openapi._ |
object Main extends App { | |
val l = List(IO(println(1).asRight), IO(println(2).asRight), IO("foo".asLeft), IO(println(4).asRight)) | |
val io = l.foldLeft[IO[Either[String, Unit]]](IO(Right(())))((prev, next) => { | |
prev.flatMap({ | |
case Left(err) => IO(Left(err)) | |
case Right(_) => next | |
}) | |
}) |
I will quickly show how I got bindgen (https://rust-lang.github.io/rust-bindgen) to generate the bindings to Fuse (libfuse) with the current stable release of Rust. By doing so, this should demonstrate how to bootstrap writing your own Fuse file system in Rust.
I do realise that there are some crates that already exist that aid in making Fuse drivers in Rust, but this was more or less an excuse to also try out bindgen, which I don't believe those existing libraries utilise.
I will be using:
- rust and cargo 1.33
- bindgen 0.48.1
- the libfuse source headers from https://github.com/libfuse/libfuse
import java.util | |
import com.sksamuel.avro4s.RecordFormat | |
import org.apache.avro.generic.GenericRecord | |
import org.apache.kafka.common.serialization.{Deserializer, Serde, Serializer} | |
object Avro4s { | |
implicit class CaseClassSerde(inner: Serde[GenericRecord]) { | |
def forCaseClass[T](implicit recordFormat: RecordFormat[T]): Serde[T] = { | |
val caseClassSerializer: Serializer[T] = new Serializer[T] { |
Well, I wouldn't say it's exactly the same sequencing in terms of FP languages like Scala et al., but it does the job for the given collection types in Rust; invert something of type F<G<A>>
into G<F<A>>
.
Usually, we'd expect F
and G
as types that are iterable and applicative. In the case of Rust, what I seem to understand from the standard library is that it is expected that there exists a trait implementation—FromIterator
—that should allow G
to be treated like an applicative. Since collect()
is already iterating over a collection of G<A>
, it's straightforward for an implementation of FromIterator
for F
to turn the results (i.e. a collection of them) of the first FromIterator
into a G<F<A>>
—which is what it does.
let opt = vec![Some(1), Some(2), Some(3)];
let sequenced = opt.into_iter().collect::<Option<Vec<i32>>>();
print!("{:?}", sequenced); // Some([1, 2, 3])
pub struct PagedVec<'a, A: 'a> { | |
indexes: usize, | |
page_length: usize, | |
pages: Vec<Vec<&'a A>>, | |
} | |
impl<'a, A> PagedVec<'a, A> { | |
pub fn from(vec: &'a Vec<A>, page_length: usize) -> PagedVec<'a, A> { | |
PagedVec { | |
indexes: vec.len(), |