Skip to content

Instantly share code, notes, and snippets.

var whileRow = new Sequence()
{
Activities = [
new Inline((context) =>
{
var enumerator = context.Get<IAsyncEnumerator<string>>(csvEnumerator)!;
var currentCsvRow = enumerator.Current;
Console.WriteLine(currentCsvRow);
}),
new Inline(async (context) => {
services.AddScoped<CommitStateHandler>();
// Add Elsa services to the container.
services.AddElsa(elsa =>
{
elsa.UseWorkflows(workflows =>
{
workflows.CommitStateHandler = sp => sp.GetRequiredService<CommitStateHandler>();
workflows.WithWorkflowExecutionPipeline(pipeline => pipeline
Exception has occurred: CLR/System.InvalidOperationException
Exception thrown: 'System.InvalidOperationException' in System.Private.CoreLib.dll: 'Timeouts are not supported on this stream.'
at System.IO.Stream.get_ReadTimeout()
at System.Text.Json.Serialization.Metadata.JsonPropertyInfo`1.GetMemberAndWriteJson(Object obj, WriteStack& state, Utf8JsonWriter writer)
at System.Text.Json.Serialization.Converters.ObjectDefaultConverter`1.OnTryWrite(Utf8JsonWriter writer, T value, JsonSerializerOptions options, WriteStack& state)
at System.Text.Json.Serialization.JsonConverter`1.WriteCore(Utf8JsonWriter writer, T& value, JsonSerializerOptions options, WriteStack& state)
at System.Text.Json.Serialization.Metadata.JsonTypeInfo`1.Serialize(Utf8JsonWriter writer, T& rootValue, Object rootValueBoxed)
at System.Text.Json.Serialization.Metadata.JsonTypeInfo`1.SerializeAsObject(Utf8JsonWriter writer, Object rootValue)
at System.Text.Json.Serialization.Metadata.JsonTypeInfo`1.Serialize(Utf8JsonWriter wri
@badsyntax
badsyntax / 0_Program.cs
Last active June 22, 2025 06:42
Elsa 3.4.0 configuration for running short lived workflows that don't require any persistence
var services = new ServiceCollection();
services.AddScoped<CommitStateHandler>();
services.AddElsa(elsa =>
{
elsa.UseWorkflows(workflows =>
{
workflows.CommitStateHandler = sp => sp.GetRequiredService<CommitStateHandler>();
@badsyntax
badsyntax / example.cs
Last active June 22, 2025 04:52
Download and process massive CSV files from Blob storage using IAsyncEnumerator in Elsa 3.4.0
using Azure.Storage.Blobs;
using Elsa.Extensions;
using Elsa.Workflows;
using Elsa.Workflows.Activities;
using Elsa.Workflows.Memory;
using Elsa.Workflows.Models;
using Sylvan.Data.Csv;
namespace ElsaConsole
{
@badsyntax
badsyntax / gist:375dfe6258695e5b488d0860ef47ad18
Created March 13, 2024 08:41
remove dotnet bin and obj
find . -iname "bin" -o -iname "obj" | xargs rm -rf
@badsyntax
badsyntax / useHasAncestorRoute.ts
Last active October 19, 2023 07:05
React Navigation hook to check if the current (nested) route has an ancestor route.
import type {
FormsStackParamList,
RootStackParamList,
} from '@your/app';
import type {
NavigationState,
ParamListBase,
PartialState,
Route,
} from '@react-navigation/native';
@badsyntax
badsyntax / cloc.sh
Created October 11, 2023 16:31
react native cloc
cloc --exclude-dir=vendor,.xcodeproj,xcuserdata,build,Pods,node_modules,.gradle,dist,yarn.lock,package-lock.json .
@badsyntax
badsyntax / QueryClientProvider.ts
Last active November 1, 2024 12:39
React Native, React Query Offline Persisted Queries & Mutations
import React, { type PropsWithChildren } from 'react';
import { PersistQueryClientProvider } from '@tanstack/react-query-persist-client';
import { onlineManager } from '@tanstack/react-query';
import { queryClient } from './queryClient';
import { storagePersister } from './storagePersister';
export function QueryClientProvider(props: PropsWithChildren) {
return (
<PersistQueryClientProvider
client={queryClient}
@badsyntax
badsyntax / paths.ts
Last active February 11, 2025 21:41
Fast & Flexible TypeScript dot notation key extraction that supports nested objects to a depth of 10
/**
* Example usage:
*
* // default depth of 3: (fastest)
* type keys = Paths<SomeNestedObject> // returns "property" | "nested.property" | "nested.nested.property"
*
* // depth of 10: (can be slow)
* type keys = Paths<SomeNestedObject, 10>
*
* // depth of 10 with keys of type string and number: (slowest)