Typing spike: learn it in five levels
Provided by xBraan1
A small program that types code into VS Code, saves it, reads it back and checks every character. You will use it to see how that works and where it goes wrong.
python typing_spike.py selfcheck
python typing_spike.py probe
Start here
This takes about 15 minutes. You need a Windows PC with Python 3.10 or newer and VS Code with the code command on PATH.
- Put
typing_spike.pyin a folder. Addtest_typing_spike.pytoo if you plan to reach Level 4. - Open a normal terminal there, not an administrator one, and run
python typing_spike.py selfcheck. It reports what it found and types nothing. - Run
python typing_spike.py probe. A new VS Code window opens, you press Enter in the terminal, and the script types one short file. The whole probe takes about ten seconds. Keep your hands off the keyboard, and hold Esc to stop. - Read the line that says PASS or FAIL. That is your first result. The levels below show what to do with it.
How it works
The gate runs before every chunk, so typing stops the moment VS Code loses focus or you hold Esc. The script trusts nothing until it has read the saved file back from disk.
Five levels
Open one level at a time and tick it when its last line is true for you. 0 of 5 levels done. Ticks stay on this device.
Level 0: Orientation0.5 h
Learn what the tool does and what it leaves alone.
- Read the diagram until you can say what each box does.
- Run
python typing_spike.py corpus --out corpusand open the five files. - Find places where an editor might change text as you type it: brackets, quotes, indentation, comment stars, HTML tags.
Provided by xBraan1
Level 1: Run it1.5 h
Get real results and learn to read them.
- Run
selfcheck, thenprobe, thenprobe --profile off. - Open
summary.txtandreport.jsonin the folder the script names at the end. - Open
workspace/.vscode/settings.jsonand find the settings that match the problem the second probe showed.
Provided by xBraan1
Level 2: Experiment2.5 h
Learn what changes the result. Write a prediction before each run.
- Run
sweep. It takes 15 to 20 minutes and finds the highest rate that stays clean. - Run
probe --chunk 4andprobe --chunk 96and compare. - Run
focus-testand click another window within ten seconds. - Disable one VS Code extension and run
probeagain. - Optional: start VS Code as administrator and run
probe.
Provided by xBraan1
Level 3: Read the code3 h
Follow one character from the corpus to the comparison, in five passes of about 35 minutes.
- The corpus and
TYPING_PROFILE. text_to_eventsand theINPUTstructures.WindowsBackend: the foreground check andSendInput.type_text,type_fileandcompare.- The
sweeplogic and the report files.
Answer these as you go. Why Unicode events? Why check focus before every chunk? Why read the file from disk instead of asking the editor? Why must INPUT be 40 bytes on 64-bit Windows?
Provided by xBraan1
Level 4: Change it3 h
Prove you understand it by changing it safely. Run python -m unittest -v test_typing_spike first so you know the starting point.
- Add a sixth language to the corpus, update the tests that count languages and run them.
- Make the fake editor in the tests auto-indent, and confirm that a test catches it.
- Add a new problem kind to
compareand cover it with a test.
Provided by xBraan1
A 10.5-hour day
The five levels add up to 10.5 hours. The tool types for about 1.5 of them. The other nine hours are you reading, predicting and writing, which is where the understanding comes from.
Each key is 30 minutes. Amber keys are the tool typing while you watch. Open keys are you.
Work in blocks of 50 minutes with 10 off. Four habits keep a long day useful.
- Predict first. Write what you expect before every run.
- One line per block. After each block, note what you expected and what happened.
- Alternate. Follow a run with reading and reading with writing, and avoid three of the same kind in a row.
- Park it. If you are stuck for 20 minutes, write the question down and move on.
10.5 hours is a ceiling. When a level’s last line is true, move on early.
Reading a result
| Shown | What it means and what to try |
|---|---|
PASS | The files match the source, line endings aside. Raise --rate in steps. |
EMPTY | Nothing reached the file. VS Code may be elevated, another window may have had focus, or the save did not happen. |
EXTRA | The editor added text. Look at auto-closing, auto-indent, suggestions and extensions. |
MISSING | Input was dropped. Lower --rate or --chunk. |
DIFFERENT | Same length, different characters. Lower the rate and look at extensions. |
ABORTED | The run stopped early. Read the detail line: Esc, a focus change or a SendInput error. |
Ground rules
- Run it on your own computer, from a normal terminal, and keep your hands off the keyboard while it types.
- It types only into VS Code, and only into files in its own work folder.
- Hold Esc to stop it at any time. Don’t leave it typing while you are away.
- Use it for learning and practice projects. Don’t use it where someone expects to watch you write the code yourself, such as exams, interviews or monitored work.