Implemented Prism.js Syntax Highlighting For Better Reading
Providing useful snippets is a real pleasure, especially when they’re well-written, effective, and safe to use. I’m excited to share that I’ve now added a feature that enhances the visual appeal of code snippets on the site, thanks to Prism.js Syntax Highlighting.
This improvement not only makes the snippets easier to read but also helps give you a clearer understanding of the code. Whether you’re a beginner or a seasoned coder, I hope this upgrade makes your experience smoother.
If you have any cool ideas for new features, I’m all ears! Feel free to drop your suggestions through the contact form. If I find something interesting and have a bit of free time, I’d be more than happy to turn your ideas into some useful code snippets.
<?php
// Simulate the passage of time
function simulateTime($minutes) {
echo "Simulating $minutes minutes...\n";
sleep($minutes * 60); // Simulate sleep time in seconds
}
// Function to simulate falling asleep
function fallAsleep($timeToFallAsleep) {
echo "You’re trying to fall asleep... drifting...\n";
simulateTime($timeToFallAsleep);
echo "You’re asleep! Time to dream...\n";
}
// Function to generate random dream scenarios
function dream($dreamTime) {
$dreams = [
"You’re at a pizza party with your best friends, but you’re the only one who can eat the pizza.",
"You're racing a turtle and winning.",
"You’re solving mysteries with a talking cat.",
];
echo "Dreaming... {$dreams[array_rand($dreams)]}\n";
simulateTime($dreamTime);
}
// Function to simulate deep sleep
function deepSleep($deepSleepTime) {
echo "You're in deep sleep... completely out of it.\n";
simulateTime($deepSleepTime);
}
// Function to handle the waking up process
function wakeUp() {
$wakeupMode = rand(1, 3); // Choose between 3 wake-up scenarios
switch ($wakeupMode) {
case 1:
echo "You slowly open your eyes, groggily. Still half asleep...\n";
break;
case 2:
echo "You wake up with a start, startled by a weird dream.\n";
break;
case 3:
echo "You wake up, look at the clock, and realize you overslept!\n";
break;
}
echo "You're awake! Time to face the day!\n";
}
// Main sleep cycle function
function sleepCycle() {
$fallAsleepTime = rand(30, 60); // Random fall asleep time between 30 and 60 minutes
$dreamTime = rand(10, 20); // Dreaming for 10 to 20 minutes
$deepSleepTime = rand(60, 120); // Deep sleep for 1 to 2 hours
fallAsleep($fallAsleepTime); // Simulate falling asleep
dream($dreamTime); // Simulate dreaming
deepSleep($deepSleepTime); // Simulate deep sleep
wakeUp(); // Simulate waking up
}
// Start the sleep cycle
sleepCycle();
?>/* Basic styling for sleep cycle */
body {
font-family: 'Arial', sans-serif;
background-color: #f0f8ff;
color: #333;
text-align: center;
padding: 20px;
}
h1 {
font-size: 2.5em;
color: #6a5acd;
margin-bottom: 20px;
}
/* Sleep and dream messages */
.sleep-phase, .dream-phase, .wake-up-phase {
display: inline-block;
font-size: 1.2em;
padding: 15px;
border-radius: 8px;
margin: 10px;
width: 60%;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
transition: all 0.3s ease-in-out;
}
/* Fall asleep phase */
.sleep-phase {
background-color: #87cefa;
color: #fff;
animation: fadeIn 1s ease-in-out;
}
/* Dream phase */
.dream-phase {
background-color: #ffb6c1;
color: #fff;
animation: fadeIn 1.5s ease-in-out;
}
/* Wake up phase */
.wake-up-phase {
background-color: #98fb98;
color: #333;
animation: fadeIn 2s ease-in-out;
}
/* Hover effects for each phase */
.sleep-phase:hover {
background-color: #4682b4;
cursor: pointer;
}
.dream-phase:hover {
background-color: #ff69b4;
cursor: pointer;
}
.wake-up-phase:hover {
background-color: #32cd32;
cursor: pointer;
}
/* Keyframe animations for fade in */
@keyframes fadeIn {
from {
opacity: 0;
transform: translateY(20px);
}
to {
opacity: 1;
transform: translateY(0);
}
}Written by Milan on 27th June 2025
