Random Cat Facts

          
          <!DOCTYPE html>
            <html lang="en">
              <head>
                <meta charset="UTF-8">
                <meta name="viewport" content="width=device-width, initial-scale=1.0">
                <title>Random Cat Facts</title>
              </head>
              <body>
                <h1>Random Cat Facts</h1>
                <p id="catFact">Loading...</p>
                <button onclick="getRandomCatFact()">Get Another Fact</button>

                <script>
                  function getRandomCatFact() {
                    const apiUrl = 'https://catfact.ninja/fact';

                    // Fetch data from the API
                    fetch(apiUrl)
                        .then(response => response.json())
                        .then(data => {
                            // Update the content with the fetched cat fact
                            document.getElementById('catFact').innerText = data.fact;
                        })
                        .catch(error => {
                            console.error('Error fetching cat fact:', error);
                            document.getElementById('catFact').innerText = 'Failed to fetch cat fact';
                        });
                  }

                  // Initial fetch when the page loads
                  getRandomCatFact();
                </script>
              </body>
            </html>
          
        

First Date Questions (Drupal Module)

          
            /**
              * Implements hook_menu().
              */
            function first_date_questions_menu() {
              $items = array();

              $items['first-date-questions'] = array(
                'title' => 'First Date Questions Form',
                'page callback' => 'drupal_get_form',
                'page arguments' => array('first_date_questions_form'),
                'access arguments' => array('access content'),
                'type' => MENU_NORMAL_ITEM,
              );

              return $items;
            }

            /**
              * Form constructor for the first date questions form.
              */
            function first_date_questions_form($form, &$form_state) {
              $form['question_1'] = array(
                '#type' => 'textfield',
                '#title' => t('What is your favorite movie?'),
                '#required' => TRUE,
              );

              $form['question_2'] = array(
                '#type' => 'textfield',
                '#title' => t('What is your dream travel destination?'),
                '#required' => TRUE,
              );

              $form['question_3'] = array(
                '#type' => 'textfield',
                '#title' => t('If you could have dinner with anyone, living or dead, who would it be?'),
                '#required' => TRUE,
              );

              $form['submit'] = array(
                '#type' => 'submit',
                '#value' => t('Submit Answers'),
              );

              return $form;
            }

            /**
              * Form submission handler for the first date questions form.
              */
            function first_date_questions_form_submit($form, &$form_state) {
              // Process the submitted data, e.g., save it to the database.
              // For simplicity, we'll just print the data here.
              drupal_set_message('First date questions submitted:');
              drupal_set_message('Question 1: ' . $form_state['input']['question_1']);
              drupal_set_message('Question 2: ' . $form_state['input']['question_2']);
              drupal_set_message('Question 3: ' . $form_state['input']['question_3']);
            }
          
        
          
            name: 'First Date Questions'
            type: module
            description: 'A custom module that asks first date questions.'
            core_version_requirement: ^8 || ^9 || ^10
            package: Custom
            version: VERSION
          
        

Force Password Reset (Drupal Module)

          
          /**
           * Implements hook_help().
           */
          function force_password_reset_help($route_name, \Drupal\Core\Routing\RouteMatchInterface $route_match) {
            switch ($route_name) {
              case 'help.page.force_password_reset':
                return '

' . t('Enforces password reset for users after 90 days.') . '

'; } } /** * Implements hook_cron(). */ function force_password_reset_cron() { // Get the timestamp for 90 days ago. $timestamp_90_days_ago = strtotime('-90 days'); // Query users who haven't reset their password in the last 90 days. $query = \Drupal::entityQuery('user') ->condition('status', 1) // Active users only ->condition('access', $timestamp_90_days_ago, '<'); // Users who haven't logged in for 90 days $uids = $query->execute(); // Reset the password for each user. foreach ($uids as $uid) { $user = \Drupal\user\Entity\User::load($uid); $user->setPassword(user_password()); $user->save(); } }
          
            name: 'Force Password Reset'
            type: module
            description: 'Enforces password reset for users after 90 days.'
            package: Custom
            version: 1.0
            core_version_requirement: ^8 || ^9 || ^10
          
        

Job Application (Drupal Module)

          
          /**
           * Implements hook_menu().
           */
          function job_application_menu() {
            $items = array();

            $items['job-application'] = array(
              'title' => 'Job Application Form',
              'page callback' => 'drupal_get_form',
              'page arguments' => array('job_application_form'),
              'access arguments' => array('access content'),
              'type' => MENU_NORMAL_ITEM,
            );

            return $items;
          }

          /**
           * Form constructor for the job application form.
           */
          function job_application_form($form, &$form_state) {
            $form['name'] = array(
              '#type' => 'textfield',
              '#title' => t('Your Name'),
              '#required' => TRUE,
            );

            $form['email'] = array(
              '#type' => 'email',
              '#title' => t('Email Address'),
              '#required' => TRUE,
            );

            $form['resume'] = array(
              '#type' => 'file',
              '#title' => t('Resume (PDF only)'),
              '#required' => TRUE,
            );

            $form['submit'] = array(
              '#type' => 'submit',
              '#value' => t('Submit Application'),
            );

            return $form;
          }

          /**
           * Form submission handler for the job application form.
           */
          function job_application_form_submit($form, &$form_state) {
            // Process the submitted data, e.g., save it to the database.
            // For simplicity, we'll just print the data here.
            drupal_set_message('Job application submitted. Name: ' . $form_state['input']['name'] . ', Email: ' . $form_state['input']['email']);
          }
          
        
          
            name: 'Job Application'
            type: module
            description: 'A custom module for job applications.'
            core_version_requirement: ^8 || ^9 || ^10
            package: Custom
            version: VERSION