Skip to content

Instantly share code, notes, and snippets.

View bvandgrift's full-sized avatar

Ben Vandgrift bvandgrift

View GitHub Profile
@bvandgrift
bvandgrift / pseudo-test.rb
Last active March 20, 2019 19:19
throwaway sketch for a maybe test
test "don't do unnecessary work for no change" do
# let's assume that there's an enqueue(evt) method which pulls an event into the
# processing pipeline, and that the enqueue method in turn calls a process(evt) method
# let's further assume that if an event has an attribute, once processed, we don't want
# to process it again for the same attribute value. so evt(attr:5), evt(attr:5), evt(attr:6) would
# generate two process() calls, not three.
pipeline = Pipeline.new() # or whatever
@bvandgrift
bvandgrift / fix-missing.sh
Last active December 5, 2020 04:30
cheap idempotent file fetching
#!/usr/bin/env bash
# given a single case id (e.g., 19820427023459I) will check to see if
# it exists in the output directory, otherwise fetch it --
# it won't store the file if there's a problem with the request
# usage: ./fix-missing.sh <case_id>
if [ `ls out/${1}.html 2> /dev/null` ]; then
exit
else
@bvandgrift
bvandgrift / can_pet.js
Last active February 23, 2022 16:43
simple decision logic demo for a friend's son currently javascripting
// more javascripty!
const FRIENDLY = {
MAYBE: 'pet at your own risk',
YES: 'ok to pet',
NO: 'do NOT pet'
}
class Pet {
constructor(name, isFriendly = FRIENDLY.MAYBE, sound = "UNKNOWN") {