Created
January 8, 2023 02:34
-
-
Save SourceCode/be84d56dfb210a03dc46258ed494e20f to your computer and use it in GitHub Desktop.
Render binary time representation into the chrome console
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Use in chrome console | |
function RenderBinary() { | |
const zeroChar = '🟢'; | |
const oneChar = '🟠'; | |
let frameNum = 0; | |
let pos = 0; | |
let timeStr = ''; | |
let date = new Date(); | |
let hours = date.getHours(); | |
let minutes = date.getMinutes(); | |
let seconds = date.getSeconds(); | |
timeStr += (hours >>> 0).toString(2).padStart(4, '0'); | |
timeStr += (minutes >>> 0).toString(2).padStart(6, '0'); | |
timeStr += (seconds >>> 0).toString(2).padStart(6, '0'); | |
let interval = setInterval(() => { | |
frameNum = (frameNum + 1) % 2; | |
console.clear(); | |
let output = ''; | |
for (let i = 0; i < 16; i++) { | |
for (let j = 0; j < 16; j++) { | |
if (timeStr[(i * 16 + j + pos) % timeStr.length] === '0') { | |
output += zeroChar; | |
} else { | |
output += oneChar; | |
} | |
} | |
output += '\n'; | |
} | |
console.log(output); | |
pos++; | |
if (pos >= timeStr.length) { | |
pos = 0; | |
} | |
}, 250); | |
} | |
RenderBinary(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment