- Delete unused or obsolete files when your changes make them irrelevant (refactors, feature removals, etc.), and revert files only when the change is yours or explicitly requested. If a git operation leaves you unsure about other agents' in-flight work, stop and coordinate instead of deleting.
- Before attempting to delete a file to resolve a local type/lint failure, stop and ask the user. Other agents are often editing adjacent files; deleting their work to silence an error is never acceptable without explicit approval.
- NEVER edit
.envor any environment variable files—only the user may change them. - Coordinate with other agents before removing their in-progress edits—don't revert or delete work you didn't author unless everyone agrees.
- Moving/renaming and restoring files is allowed.
- ABSOLUTELY NEVER run destructive git operations (e.g.,
git reset --hard,rm,git checkout/git restoreto an older commit) unless the user gives an explicit, written instruction in this conversation. Treat t
| /** | |
| * Cloudflare Worker for Server-Sent Events (SSE) | |
| * | |
| * This worker demonstrates how to set up an SSE endpoint | |
| * that sends an initial message and then periodic updates. | |
| */ | |
| // Listen for incoming requests | |
| addEventListener('fetch', event => { | |
| event.respondWith(handleRequest(event.request)); |
| #!/bin/bash | |
| # Usage: tracing::init [endpoint; default localhost:4317] | |
| function tracing::init() { | |
| export OTEL_EXPORTER_OTLP_ENDPOINT="${1:-${OTEL_EXPORTER_OTLP_ENDPOINT:-localhost:4317}}" | |
| } | |
| # Usage: tracing::auto::init [endpoint; default localhost:4317] | |
| function tracing::auto::init() { | |
| tracing::init |
| import Foundation | |
| import CoreImage | |
| /** | |
| Based on: https://gist.github.com/SheffieldKevin/566dc048dd6f36716bcd | |
| Updated for Swift 5.5 (Xcode 13) | |
| */ | |
| class ImageDiff { | |
| func compare(leftImage: CGImage, rightImage: CGImage) throws -> Int { |
| // | |
| // Thanks Kevin! | |
| // https://gist.github.com/SheffieldKevin/566dc048dd6f36716bcd | |
| // | |
| import CoreGraphics | |
| import CoreImage | |
| extension CGImage { | |
| from graphviz import Digraph | |
| import torch | |
| from torch.autograd import Variable, Function | |
| def iter_graph(root, callback): | |
| queue = [root] | |
| seen = set() | |
| while queue: | |
| fn = queue.pop() | |
| if fn in seen: |
| """ | |
| Play with saving . | |
| Closest: | |
| https://github.com/tensorflow/tensorflow/issues/616#issuecomment-205620223 | |
| """ | |
| import numpy as np | |
| import tensorflow as tf | |
| from tensorflow.python.platform import gfile |
| import torch | |
| import numpy as np | |
| import pickle | |
| f = open('/home/eriba/software/pytorch/examples-edgarriba/triplet/nan_test.pkl', 'rb') | |
| data = pickle.load(f) | |
| a = torch.from_numpy(data['a']).cuda() |
| from tf_logger import TFLogger | |
| """ Example of using TFLogger to save train & dev statistics. To visualize | |
| in tensorboard simply do: | |
| tensorboard --logdir /path/to/summaries | |
| This code does depend on Tensorflow, but does not require that your model | |
| is built using Tensorflow. For instance, could build a model in Chainer, then |
State machines are everywhere in interactive systems, but they're rarely defined clearly and explicitly. Given some big blob of code including implicit state machines, which transitions are possible and under what conditions? What effects take place on what transitions?
There are existing design patterns for state machines, but all the patterns I've seen complect side effects with the structure of the state machine itself. Instances of these patterns are difficult to test without mocking, and they end up with more dependencies. Worse, the classic patterns compose poorly: hierarchical state machines are typically not straightforward extensions. The functional programming world has solutions, but they don't transpose neatly enough to be broadly usable in mainstream languages.
Here I present a composable pattern for pure state machiness with effects,