A community index of reusable code snippets — signed as open records on ATProto, searchable by language, and discoverable by anyone.
items
|> Task.async_stream(
&process/1,
timeout: 5_000,
on_timeout: :kill_task,
max_concurrency: 8
)
|> Stream.filter(&match?({:ok,_}, &1))
|> Enum.map(fn {:ok, v} -> v end)
for attempt in 0..max_retries {
match try_operation().await {
Ok(result) => return Ok(result),
Err(e) if attempt < max_retries-1 => {
let d = base * 2u32.pow(attempt);
tokio::time::sleep(d).await;
}
Err(e) => return Err(e),
}
}
const Event = z.discriminatedUnion("type", [
z.object({ type: z.literal("click"),
x: z.number(), y: z.number() }),
z.object({ type: z.literal("keydown"),
key: z.string(), mod: z.boolean() }),
]);
type Event = z.infer<typeof Event>;
No recipes found.
Sign in to share the first recipe.