Skip to content

Instantly share code, notes, and snippets.

@badsyntax
badsyntax / react-native-apple-m1.md
Last active March 16, 2026 08:07
Some tips to working with react-native 0.64 on an Apple M1 Silicon chip

My env:

  • cocoapods 1.10.1
  • xcode 12.4
  • macos big sur 11.2.3
  • react-native 0.64

iOS

The iOS simulator build won't "just work". If you get errors like ld: library not found for... or swift compiler errors, then you need to disable arm64 for the simulator build.

@badsyntax
badsyntax / playwright.patch
Created December 1, 2025 16:22
playwright not ending tests
diff --git a/node_modules/playwright/lib/runner/processHost.js b/node_modules/playwright/lib/runner/processHost.js
index a8ee4e7..8ce01c5 100644
--- a/node_modules/playwright/lib/runner/processHost.js
+++ b/node_modules/playwright/lib/runner/processHost.js
@@ -140,8 +140,20 @@ class ProcessHost extends import_events.EventEmitter {
this.send({ method: "__stop__" });
this._didSendStop = true;
}
- if (!this._didExitAndRanOnExit)
- await new Promise((f) => this.once("exit", f));
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
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) => {
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 / android_emulator_cli_ci.md
Last active May 28, 2025 12:31
start an android emulator with screen dimensions (specifically for use in CI)
# Install AVD files
yes | $ANDROID_HOME/tools/bin/sdkmanager --install 'system-images;android-29;default;x86'
yes | $ANDROID_HOME/tools/bin/sdkmanager --licenses

# Create emulator
echo "no" | $ANDROID_HOME/tools/bin/avdmanager create avd -n Pixel_API_29_AOSP -d pixel --package 'system-images;android-29;default;x86' --force

$ANDROID_HOME/emulator/emulator -list-avds
@badsyntax
badsyntax / email_validation.js
Created November 29, 2010 10:32
rfc822 email validation in JS
// See http://rosskendall.com/blog/web/javascript-function-to-check-an-email-address-conforms-to-rfc822
function isEmail(email){
return /^([^\x00-\x20\x22\x28\x29\x2c\x2e\x3a-\x3c\x3e\x40\x5b-\x5d\x7f-\xff]+|\x22([^\x0d\x22\x5c\x80-\xff]|\x5c[\x00-\x7f])*\x22)(\x2e([^\x00-\x20\x22\x28\x29\x2c\x2e\x3a-\x3c\x3e\x40\x5b-\x5d\x7f-\xff]+|\x22([^\x0d\x22\x5c\x80-\xff]|\x5c[\x00-\x7f])*\x22))*\x40([^\x00-\x20\x22\x28\x29\x2c\x2e\x3a-\x3c\x3e\x40\x5b-\x5d\x7f-\xff]+|\x5b([^\x0d\x5b-\x5d\x80-\xff]|\x5c[\x00-\x7f])*\x5d)(\x2e([^\x00-\x20\x22\x28\x29\x2c\x2e\x3a-\x3c\x3e\x40\x5b-\x5d\x7f-\xff]+|\x5b([^\x0d\x5b-\x5d\x80-\xff]|\x5c[\x00-\x7f])*\x5d))*$/.test( email );
}
@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)