Skip to content

Instantly share code, notes, and snippets.

View njvack's full-sized avatar

Nate Vack njvack

View GitHub Profile
@njvack
njvack / mtcars.csv
Created February 23, 2026 19:15
mtcars
mpg cyl disp hp drat wt qsec vs am gear carb
21 6 160 110 3.9 2.62 16.46 0 1 4 4
21 6 160 110 3.9 2.875 17.02 0 1 4 4
22.8 4 108 93 3.85 2.32 18.61 1 1 4 1
21.4 6 258 110 3.08 3.215 19.44 1 0 3 1
18.7 8 360 175 3.15 3.44 17.02 0 0 3 2
18.1 6 225 105 2.76 3.46 20.22 1 0 3 1
14.3 8 360 245 3.21 3.57 15.84 0 0 3 4
24.4 4 146.7 62 3.69 3.19 20 1 0 4 2
22.8 4 140.8 95 3.92 3.15 22.9 1 0 4 2
@njvack
njvack / anscbome.csv
Created February 23, 2026 19:06
anscombe
d1_x d1_y d2_x d2_y d3_x d3_y d4_x d4_y
10 8.04 10 9.14 10 7.46 8 6.58
8 6.95 8 8.14 8 6.77 8 5.76
13 7.58 13 8.74 13 12.74 8 7.71
9 8.81 9 8.77 9 7.11 8 8.84
11 8.33 11 9.26 11 7.81 8 8.47
14 9.96 14 14 14 8.84 8 7.04
6 7.24 6 6.13 6 6.08 8 5.25
4 4.26 4 3.1 4 5.39 19 12.5
12 10.84 12 9.13 12 8.15 8 5.56
@njvack
njvack / happy_birthday.csv
Created February 23, 2026 04:44
happy birthday
X Y
9 18
9 19
9 20
9 21
9 22
9 23
9 24
13 18
13 19
@njvack
njvack / main.py
Created January 22, 2026 05:22
probability thing
import random
import sys
def main(width: int, mj: int, iters=1000000):
x = [0] * (width + (mj) - 1)
for _ in range(iters):
mins = random.randrange(width)
jitter = random.randrange(mj)
@njvack
njvack / focus_highlighter.js
Created June 27, 2025 17:55
Paste this in the console to get outlines and notifications of focus change events on your page
document.addEventListener('focusin', (e) => {
// Remove previous highlight
document.querySelectorAll('.debug-focus').forEach(el => el.classList.remove('debug-focus'));
// Add highlight to current element
e.target.classList.add('debug-focus');
console.log(e.target);
});
// Add CSS for the highlight
const style = document.createElement('style');
@njvack
njvack / sessionize.bash
Last active April 4, 2025 14:33
Use dtach + script + cat to make a "pick up where I left off" session management tool
#!/bin/bash
USAGE="sessionize: Build a disconnection-tolerant interactive session
Usage: sessionize [session_name] [command ...]
With no arguments, lists active sessions
If session_name is specified, either create or attach to it and run $SHELL as
an interactive login shell.
@njvack
njvack / make_factors.py
Last active February 21, 2025 22:18
Make files for REDCap-based multifactorial designs
#!/usr/bin/env python
# Copyright 2025 Board of Regents of the University of Wisconsin System
# Written by Nate Vack <njvack@wisce.edu> at the Center for Healthy Minds
"""
Generates multi-factorial randomization lists for REDCap.
Takes three parameters:
* list_length (the approximate length of the list you want to generate
* factor_count (the number of factors in your multifactorial design)
@njvack
njvack / mosaic.py
Last active October 17, 2024 17:39
MRI Image Mosaic generator
#!/usr/bin/env python
# Copyright 2024 Board of Regents of the Universities of Wisconsin
# Written by Nate Vack <njvack@wisc.edu>
"""MRI Image Mosaic.
Makes an MxN mosaic of images, intended for checking things like defacing
and alignment.
@njvack
njvack / ema_gen.py
Created June 27, 2024 17:36
EMA Scheduling
#!/usr/bin/env python
"""
Simple EMA schedule generator. Outputs to stdout.
Usage:
ema_gen.py [options] <record_id> <sched_field> <start_time> <days> <samples_per_day> <sampling_min> <gap_min>
ema_gen.py interval_test <iters> <num_samples> <sampling_minutes> <gap_minutes>
Options:
#!/usr/bin/env python
"""
Takes a REDCap CSV file and splits it into:
* A file for each event
* A file for repeated instruments in events where they happen
So, if your data has events 'scr,' 'pre,' and 'post', and 'pre' and 'post'
each have a repeated instument called 'meds', you can expect