Skip to content

Instantly share code, notes, and snippets.

View scytacki's full-sized avatar

Scott Cytacki scytacki

  • Concord Consortium
  • Medford, MA
View GitHub Profile

It is tempting to use default positive values for object properties. This can make the code more readable when in most cases the value should be positive. However it is easy to accidentally pass undefined for the value. That then makes the value the function sees true. So now the function behaves the opposite way you probably intended when you called it.

More details here:

function doSomething({enabled = true}) { 
  console.log("enabled", enabled);
}
const check = true;
const valueThatMightBeDefined = undefined;
@scytacki
scytacki / prompt.md
Created January 26, 2026 14:04
Fix npm and cypress Claude prompt

Check if you can run npm --version in the Bash tool. If it fails, diagnose and fix the shell environment for this Claude Code session by doing the following:

  1. Check if ELECTRON_RUN_AS_NODE is set (this interferes with Electron apps like Cypress). Check if nvm exists at $HOME/.nvm/nvm.sh but isn't being sourced.

  2. If either issue exists, create a SessionStart hook to fix them permanently:

    • Create ~/.claude/hooks/setup-env.sh (make it executable) with:
      #!/bin/bash
      ENV_BEFORE=$(export -p | sort)
      export NVM_DIR="$HOME/.nvm"
<html>
<head>
<script src="https://docs.getgrist.com/grist-plugin-api.js"></script>
<!-- React 18 from CDN -->
<script src="https://unpkg.com/react@18/umd/react.development.js"></script>
<script src="https://unpkg.com/react-dom@18/umd/react-dom.development.js"></script>
<!-- Babel Standalone for JSX at runtime -->
<script src="https://unpkg.com/@babel/standalone/babel.min.js"></script>
@scytacki
scytacki / count-mst-actions-views.mjs
Created November 15, 2025 14:01
A script to count the MST action and view blocks in each MST model in a repository.
#!/usr/bin/env node
import fs from 'fs';
import path from 'path';
import { fileURLToPath } from 'url';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
/**
@scytacki
scytacki / MST_Typescript_Enums.md
Last active November 3, 2025 15:14
Notes on using enums in typescript, especially when using a runtime type system like MST.

Almost every time I want to use an enum in Typescript with MST I go down a rabbit hole reading https://www.typescriptlang.org/docs/handbook/enums.html So just for reference here are my notes from my most recent investigation:

Avoiding the concept of enumerations entirely

export const DotPlotMode_CONTINUAL = "continual";
export const DotPlotMode_EACH_DOT = "each-dot";
export const DotPlotModeValues = [DotPlotMode_CONTINUAL, DotPlotMode_EACH_DOT] as const;
export type DotPlotMode = typeof DotPlotModeValues[number];
export const isDotPlotMode = (value: unknown): value is DotPlotMode => {
===== LOG STARTED: 09.04.2023 22:42:21=====
=====Version=1.98.0 Build=400980 P=False NoDelayELM327Init=False
====Connection profile=Volkswagen EV MEB: ID.3, ID.4, ID.5, ID.6, ID.Buzz, Enyaq, Q4 E-tron, Cupra Born, etc.
[Connection type: BluetoothLE; DeviceName=WiC_34b472ef7c09]
[Connecting to 00000000-0000-0000-0000-4986fff740c4]
[Connected to 00000000-0000-0000-0000-4986fff740c4]
ATZ
ATE0
WITH activities_1 AS (SELECT *, cardinality(questions) AS num_questions FROM "report-service"."activity_structure" WHERE structure_id = '534002d3-0a86-48ad-8b36-d3c902f08cf0'),
activities_2 AS (SELECT *, cardinality(questions) AS num_questions FROM "report-service"."activity_structure" WHERE structure_id = '43b612a2-db8c-4f50-987c-e2d4f465f2c5'),
activities_3 AS (SELECT *, cardinality(questions) AS num_questions FROM "report-service"."activity_structure" WHERE structure_id = '360fe0a4-df2a-4ff0-911b-b4524cf3928b'),
unique_user_class AS (
SELECT class_id, user_id,
arbitrary(student_id) as student_id,
arbitrary(student_name) as student_name,
@scytacki
scytacki / issue-with-slider.txt
Created August 23, 2022 17:46
Exception when moving around time travel slider
tool-tile.tsx?803e:149 Uncaught TypeError: Cannot read properties of undefined (reading 'type')
at new ToolTileComponent (tool-tile.tsx?803e:149:1)
at constructClassInstance (react-dom.development.js?61bb:12716:1)
at updateClassComponent (react-dom.development.js?61bb:17425:1)
at beginWork (react-dom.development.js?61bb:19073:1)
at HTMLUnknownElement.callCallback (react-dom.development.js?61bb:3945:1)
at Object.invokeGuardedCallbackDev (react-dom.development.js?61bb:3994:1)
at invokeGuardedCallback (react-dom.development.js?61bb:4056:1)
at beginWork$1 (react-dom.development.js?61bb:23964:1)
at performUnitOfWork (react-dom.development.js?61bb:22776:1)
@scytacki
scytacki / list_lara_admins_users.rb
Created August 17, 2022 14:33
List LARA admins users
require('csv')
users = User.where(is_admin: true)
output = CSV.generate { |csv|
users.each{ |user|
csv << [
user.id,
user.email,
user.last_sign_in_at
# First pass off this missed interactives that had no answerPrompt field in their JSON
# this is a revised version of that first pass to pick up these new ones
# Get interactives without answer prompt fields that were not modified after the new interactive
# was released
ManagedInteractive.where(library_interactive_id: 41).where("authored_state not like '%\"answerPrompt\":%'").where("legacy_ref_id is null").where("updated_at < '2022-08-05 14:22'").count
def add_describe_the_drawing
mis_processed = 0
managed_interactives = ManagedInteractive.where(library_interactive_id: 41).where("authored_state not like '%\"answerPrompt\":%'").where("legacy_ref_id is null").where("updated_at < '2022-08-05 14:22'")
mis_to_process = managed_interactives.count