Tag: #Silly

  • Reverse Word Puzzle JavaScript Game

    This script randomly selects a word from a list, reverses it, and challenges the player to guess the original word. It demonstrates basic Node.js functionality, including using the readline module for handling terminal input.

    Click to view script…
    // reverseWordPuzzle.js
    
    // List of words for the puzzle
    const words = ['apple', 'banana', 'orange', 'strawberry', 'grape', 'pineapple', 'kiwi'];
    
    // Function to reverse a given word
    function reverseWord(word) {
      return word.split('').reverse().join('');
    }
    
    // Function to pick a random word from the array
    function getRandomWord() {
      return words[Math.floor(Math.random() * words.length)];
    }
    
    // Main function to run the game
    function playGame() {
      const originalWord = getRandomWord();
      const reversedWord = reverseWord(originalWord);
      
      console.log("=== Reverse Word Puzzle ===");
      console.log(`Unscramble this reversed word: ${reversedWord}`);
    
      // Create an interface for user input
      const readline = require('readline');
      const rl = readline.createInterface({
        input: process.stdin,
        output: process.stdout
      });
    
      // Ask the user for their guess
      rl.question("Your guess: ", (answer) => {
        if(answer.trim().toLowerCase() === originalWord.toLowerCase()){
          console.log("Correct! Well done.");
        } else {
          console.log(`Incorrect. The correct word was: ${originalWord}`);
        }
        rl.close();
      });
    }
    
    // Start the game
    playGame();
  • Virtual Pet Simulator Python Script

    A simple virtual pet game where you can feed, play with, and put your pet to sleep—keep it happy and healthy or watch things go south.

    Click to view script…
    import time
    
    class VirtualPet:
        def __init__(self, name):
            self.name = name
            self.hunger = 5      # 0 means full, 10 means starving
            self.happiness = 5   # 0 means sad, 10 means happy
            self.energy = 5      # 0 means tired, 10 means full of energy
            self.alive = True
    
        def feed(self):
            if self.hunger > 0:
                self.hunger -= 1
                print(f"You fed {self.name}. Hunger is now {self.hunger}/10.")
            else:
                print(f"{self.name} isn't hungry right now!")
    
        def play(self):
            if self.energy > 0:
                self.happiness = min(10, self.happiness + 1)
                self.energy -= 1
                self.hunger = min(10, self.hunger + 1)
                print(f"You played with {self.name}. Happiness: {self.happiness}/10, Energy: {self.energy}/10, Hunger: {self.hunger}/10.")
            else:
                print(f"{self.name} is too tired to play.")
    
        def sleep(self):
            print(f"{self.name} is sleeping...")
            time.sleep(2)
            self.energy = min(10, self.energy + 3)
            self.hunger = min(10, self.hunger + 1)
            print(f"{self.name} woke up. Energy: {self.energy}/10, Hunger: {self.hunger}/10.")
    
        def status(self):
            print(f"\n{self.name}'s Status:")
            print(f"  Hunger: {self.hunger}/10")
            print(f"  Happiness: {self.happiness}/10")
            print(f"  Energy: {self.energy}/10")
    
        def update(self):
            # Stats change over time
            self.hunger = min(10, self.hunger + 1)
            self.happiness = max(0, self.happiness - 1)
            self.energy = max(0, self.energy - 1)
            if self.hunger == 10 or self.happiness == 0 or self.energy == 0:
                self.alive = False
                print(f"\nSadly, {self.name} has passed away due to neglect...")
    
    def main():
        pet_name = input("Name your pet: ")
        pet = VirtualPet(pet_name)
        print(f"Welcome, {pet.name}!")
        
        while pet.alive:
            pet.status()
            print("\nActions: feed | play | sleep | exit")
            action = input("What do you want to do? ").strip().lower()
            
            if action == "feed":
                pet.feed()
            elif action == "play":
                pet.play()
            elif action == "sleep":
                pet.sleep()
            elif action == "exit":
                print("Goodbye!")
                break
            else:
                print("Invalid action. Try again.")
            
            pet.update()
        
        print("Game over.")
    
    if __name__ == '__main__':
        main()
    
  • Matrix Rain Effect Python Script

    This Python script simulates the iconic digital rain from The Matrix in your terminal using the curses library. Green characters cascade down your screen, and press any key to exit the mesmerizing effect.

    Click to view script…
    import curses
    import random
    import time
    
    def matrix_rain(stdscr):
        # Hide the cursor and set non-blocking input
        curses.curs_set(0)
        stdscr.nodelay(True)
        stdscr.timeout(50)
        
        # Initialize colors if supported
        if curses.has_colors():
            curses.start_color()
            curses.init_pair(1, curses.COLOR_GREEN, curses.COLOR_BLACK)
    
        sh, sw = stdscr.getmaxyx()  # Get screen height and width
        # Initialize each column with a random starting row
        columns = [random.randint(0, sh - 1) for _ in range(sw)]
    
        while True:
            stdscr.erase()  # Clear the screen for fresh drawing
            for x in range(sw):
                y = columns[x]
                # Generate a random printable ASCII character
                char = chr(random.randint(33, 126))
                try:
                    if curses.has_colors():
                        stdscr.addch(y, x, char, curses.color_pair(1))
                    else:
                        stdscr.addch(y, x, char)
                except curses.error:
                    # Ignore errors when drawing outside of the screen bounds
                    pass
    
                # Move the column down; reset to the top if at the bottom
                columns[x] = y + 1 if y < sh - 1 else 0
    
            stdscr.refresh()
            time.sleep(0.05)  # Adjust the speed of the rain
    
            # Exit the loop if any key is pressed
            if stdscr.getch() != -1:
                break
    
    def main():
        curses.wrapper(matrix_rain)
    
    if __name__ == '__main__':
        main()
  • Rickroll Launcher AppleScript

    This AppleScript command uses a shell command to open a popular YouTube video in your default browser, effectively “Rickrolling” the user. It’s a playful example of how to execute shell scripts from within AppleScript.

    Click to view script…
    do shell script "open https://www.youtube.com/watch?v=dQw4w9WgXcQ"
  • Simulating a macOS Crash Using AppleScript

    This AppleScript launches the macOS screensaver to create the appearance of an unresponsive system, then plays a voice message saying, “Uh oh. Something went wrong.” The combination can be used for testing reactions or demonstrating AppleScript’s ability to control system functions.

    Click to view script…
    do shell script "open /System/Library/CoreServices/ScreenSaverEngine.app"
    delay 2
    say "Uh oh. Something went wrong."