programming
book & learning resources
wanna chill or study? step into the zone.
cyber roomcool code snippets
typewriter Effect
// Typewriter effect
const text = "I'm ghost.init, synthwave entity & code dreamer.";
let index = 0;
function type() {
const target = document.getElementById('typeTarget');
if (index < text.length) {
target.textContent += text.charAt(index);
index++;
setTimeout(type, 50);
}
}
window.onload = type;
glitch generator
function glitchText(text) {
return text.split('').map(c => Math.random() > 0.2
? c
: String.fromCharCode(33 + Math.random() * 94)).join('');
}
console.log(glitchText("Reality is broken"));
clipboard copy snippet
navigator.clipboard.writeText('Hello, world!')
.then(() => console.log('Copied to clipboard'))
.catch(err => console.error('Error:', err));
dark mode toggle
document.getElementById('toggleDark').onclick = () => {
document.body.classList.toggle('dark');
};
terminal simulation ~ try me
>ghost.init@grid:~$
terminal code snippet
// Terminal Sim
const terminalInput = document.getElementById('terminal-input');
const terminalOutput = document.getElementById('terminal-output');
const commands = {
help: "Available commands: help, whoami, glitch \"your text\", clear",
whoami: "ghost.init // synthwave entity & code architect"
};
// Glitch function
function glitchText(input) {
return input.split('')
.map(c => Math.random() > 0.2
? c
: String.fromCharCode(33 + Math.random() * 94))
.join('');
}
terminalInput.addEventListener('keydown', function (e) {
if (e.key === 'Enter') {
const input = terminalInput.value.trim();
printLine(`> ${input}`);
const [cmd, ...args] = input.split(' ');
const argStr = args.join(' ').replace(/"/g, '');
if (cmd === 'clear') {
terminalOutput.innerHTML = '';
} else if (cmd === 'glitch') {
const textToGlitch = argStr || "No text provided.";
printLine(glitchText(textToGlitch), true);
} else if (commands[cmd]) {
printLine(commands[cmd]);
} else {
printLine(`Command not found: ${cmd}`);
}
terminalInput.value = '';
}
});
function printLine(text, isGlitched = false) {
const line = document.createElement('p');
line.textContent = text;
if (isGlitched) {
line.classList.add('glitched-output');
}
terminalOutput.appendChild(line);
terminalOutput.scrollTop = terminalOutput.scrollHeight;
}