I used to do this at every shop that had a C64 open for programming when the machine was on sale. It uses the Non-Maskable Interrupts to change the border colour very fast.
The code resides just above the screen at memory locations 2024 - 2032 (decimal).
INC $D020 # Increment the border colour
PHA # Push the accumulator onto the stack
LDA $DD0D # Read the timer control to acknowledge the NMI
PLA # Pull the accumulator from the stack
RTI # Return from interrupt
56580 and 56581 set the timer.
792 and 793 redirect the NMI to 2024
56590 starts the timer and 56589 resets the timer once it "underflows".
...
https://www.youtube.com/watch?v=YtHUrZdtOL0