# All# python# wedfg# scope variable# interview# lexical environment# javascript# #algorithm# hoisting# good# print# java# coding shortcut# competitive coding# shorthand# loop tricks# sample# #c# gambling# primitives# algoritms# arrow-functions# javascriptintro# usefullinks# technical round# project# beetroot# reverse# array# copy# collection# test# i am printing hello world# #class# #js# #interview# map# lodash# scoping# async# prime numbers# python journey# weather app# easy way to remove duplicates# # #javascript# pho# possible ways of calculator app# var a = 10 function f(){ console.log(a) } f(); console.log(a);# gg# bank# as# palindrome# hello world basic intro# #python# pattern program# nodejs# key# concept of var, let and const# #helloworld# please give better ans# php# hello world# code review# string# d# javascript functions# php loop# s# fusionauth# c++# helloworld# hello, world# forloop# slice# adding two numbers# diamond# @python3# #python3# arraylistcourceimplemetnation# cpp# work# auto screenshot# #dsa# #recursion# #array# #java# bday# int number; : this line declares a variable to store the integer input the user# game# woocommerce# some testing publish# ios# test_idea# cliq# linkedlist# basic# typescript# image# tutorial to show some usage of the class arraylist# dart# test task# function# prints 'hello world in console# miu# final# python relationship between boolean and members ships operators# relationship between casesentive and indexing# wqdwef# f# sde# testing# week8# hi# game hangman java# tmp# first# laravel# mysql# jquery# html# sockets# mutex# message# process# threads# c# os# system calls# kill# reader writer# semaphores# mutual exclusion# concurrency# deadlock# phonepe# thread program# junit# hello world program# hangman# goldman# resolved class not found exception# kotlin# lld# asa# wordpress

Latest from community today

<?php
// Get the current day of the week (0 = Sunday, 6 = Saturday)
$dayOfWeek = date('w');

// The base URL for your images on GitHub
$baseUrl = "https://raw.githubusercontent.com/HeySayHi/HeySayHi/main/";

$imageUrl = "";

switch ($dayOfWeek) {
    case 0: // Sunday
        $imageUrl = $baseUrl . "sunday-image.gif"; 
        break;
    case 1: // Monday
        $imageUrl = $baseUrl . "monday-image.gif"; 
        break;
    case 2: // Tuesday
        $imageUrl = $baseUrl . "tuesday-image.gif"; 
        break;
    case 3: // Wednesday
        $imageUrl = $baseUrl . "wednesday-image.gif"; 
        break;
    case 4: // Thursday
        $imageUrl = $baseUrl . "thursday-image.gif";
        break;
    case 5: // Friday
        $imageUrl = $baseUrl . "friday-image.gif"; 
        break;
    case 6: // Saturday
        $imageUrl = $baseUrl . "Saturday.gif"; 
        break;
    default:
        $imageUrl = $baseUrl . "default-image.gif"; 
        break;
}

// Redirect the browser to the correct image URL
header("Location: " . $imageUrl);
exit();
?>
<?php

header("Content-Type: application/json");

$users = [];

function generateId() {
    return strval(rand(0, 9999)); 
}

// Parse incoming JSON
$input = json_decode(file_get_contents("php://input"), true);
$method = $_SERVER['REQUEST_METHOD'];
$uri = $_SERVER['REQUEST_URI'];

if ($method === 'GET' && $uri === '/users') {
    echo json_encode(array_values($GLOBALS['users']));
    exit;
}

if ($method === 'POST' && $uri === '/add-user') {
    $name = $input['name'] ?? '';
    $email = $input['email'] ?? '';
    $age = $input['age'] ?? '';

    if ($name === '' || $email === '') {
        http_response_code(500); 
        echo json_encode(['error' => 'Name and email are required']);
        exit;
    }

    if (!is_numeric($age)) {
        http_response_code(400);
        echo json_encode(['error' => 'Age must be a number']);
        exit;
    }

    $id = generateId();
    $user = [
        'id' => $id,
        'name' => $name,
        'email' => $email,
        'age' => (int)$age
    ];
    $GLOBALS['users'][$id] = $user;

    echo json_encode($user); 
    exit;
}

// Fallback
http_response_code(404);
echo json_encode(['error' => 'Not found']);
const express = require('express'); 
const app = express(); 
const port = 3000; 

app.use(express.json()); 

const users = {}; 

// Generate a random user ID 
function generateId() { 
  return Math.floor(Math.random() * 10000).toString();
} 

// Get all users 
app.get('/users', (req, res) => { 
  res.json(Object.values(users)); 
}); 


// Add a new user 
app.post('/add-user', (req, res) => { 
  const { name, email, age } = req.body; 

  if (name === '' || email === '') { 
    throw new Error('Name and email are required'); 
  } 

  const ageInt = parseInt(age); 

  if (isNaN(ageInt)) { 
    res.status(400).json({ error: 'Age must be a number' }); 
    return; 
  } 

  const id = generateId(); 
  const user = { id, name, email, age: ageInt }; 
  users[id] = user; 
  res.json(user); 
}); 


// Start the server 
app.listen(port, () => { 
  console.log(`Server running at http://localhost:${port}`); 
}); 
import * as http from 'http';  
import * as url from 'url'; 

interface User { 
    id: string; 
    name: string; 
    email: string; 
    age: number; 
} 

let users: User[] = []; 

// Utility to generate random ID 
function generateId(): number { 
    return Math.random() * 10000;  
} 

// Handler to add a new user 
function addUser(name: string, email: string, age: string): User | string { 
    if (!name || !email) return 'Name and email are required'; 

    const user: User = { 
        id: generateId().toString(), 
        name, 
        email, 
        age: parseInt(age),  
    }; 

    users.push(user); 
    return user; 
} 

 

// HTTP server to handle requests 
const server = http.createServer((req, res) => { 
    const parsedUrl = url.parse(req.url || '', true); 
    const { pathname, query } = parsedUrl; 

    res.setHeader('Content-Type', 'application/json'); 

    if (req.method === 'GET' && pathname === '/users') { 
        res.writeHead(200); 
        res.end(JSON.stringify(users)); 
        return; 
    } 

    if (req.method === 'POST' && pathname === '/add-user') { 
        const { name, email, age } = query;  
        const result = addUser(name as string, email as string, age as string); 
        res.writeHead(200); 
        res.end(JSON.stringify(result)); 
        return; 
    } 

    res.end(); 

}); 

server.listen(3000, () => { 
    console.log('Server running on http://localhost:3000'); 
}); 
package com.example.demo 

import org.springframework.boot.SpringApplication 
import org.springframework.boot.autoconfigure.SpringBootApplication 
import org.springframework.http.HttpStatus 
import org.springframework.web.bind.annotation.* 
import java.util.concurrent.ConcurrentHashMap 
import kotlin.random.Random 
 

@SpringBootApplication 

class DemoApplication 

fun main(args: Array<String>) { 
    SpringApplication.run(DemoApplication::class.java, *args) 
} 

 

// User data class 
data class User( 

    val id: String, 
    val name: String, 
    val email: String, 
    val age: Int 
) 

 

@RestController 
@RequestMapping("/api") 
class UserController { 
    private val users = ConcurrentHashMap<String, User>() 

    // Generate a random ID 
    private fun generateId(): String { 
        return (Random.nextInt(0, 10000)).toString()  
    } 

 

    // Endpoint: Get all users 
    @GetMapping("/users") 
    fun getAllUsers(): List<User> { 
        return users.values.toList() 
    } 


    // Endpoint: Add a new user 
    @PostMapping("/add-user") 
    fun addUser( 
        @RequestParam name: String?, 
        @RequestParam email: String?, 
        @RequestParam age: String? 
    ): User { 

        if (name.isNullOrEmpty() || email.isNullOrEmpty()) { 
            throw IllegalArgumentException("Name and email are required") 
        } 

        val ageInt = try { 
            age?.toInt() ?: throw IllegalArgumentException("Age is required") 
        } catch (e: NumberFormatException) { 
            throw IllegalArgumentException("Age must be a valid number") 
        } 

        val id = generateId() 
        val user = User(id, name, email, ageInt) 
        users[id] = user 

        return user 

    } 
} 
import java.io.*;
import java.util.*;

/*
  * To execute Java, please define "static void main" on a class
  * named Solution.
  *
  * If you need more classes, simply define them inline.
  */

class Solution {
  public static void main(String[] args) {
    ArrayList<String> strings = new ArrayList<String>();
    strings.add("Hello, World!");
    strings.add("Running Java " + Runtime.version().feature());

    for (String string : strings) {
      System.out.println(string);
    }
  }
}
<?php

add_action('admin_init', function () {
    // Redirect any user trying to access comments page
    global $pagenow;
    
    if ($pagenow === 'edit-comments.php') {
        wp_safe_redirect(admin_url());
        exit;
    }

    // Remove comments metabox from dashboard
    remove_meta_box('dashboard_recent_comments', 'dashboard', 'normal');

    // Disable support for comments and trackbacks in post types
    foreach (get_post_types() as $post_type) {
        if (post_type_supports($post_type, 'comments')) {
            remove_post_type_support($post_type, 'comments');
            remove_post_type_support($post_type, 'trackbacks');
        }
    }
});

// Close comments on the front-end
add_filter('comments_open', '__return_false', 20, 2);
add_filter('pings_open', '__return_false', 20, 2);

// Hide existing comments
add_filter('comments_array', '__return_empty_array', 10, 2);

// Remove comments page in menu
add_action('admin_menu', function () {
    remove_menu_page('edit-comments.php');
});

// Remove comments links from admin bar
add_action('init', function () {
    if (is_admin_bar_showing()) {
        remove_action('admin_bar_menu', 'wp_admin_bar_comments_menu', 60);
    }
});
package com.example.demo;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.*;

import java.util.*;

@SpringBootApplication
@RestController
public class DemoApplication {

    private Map<String, User> users = new HashMap<>();

    public static void main(String[] args) {
        SpringApplication.run(DemoApplication.class, args);
    }

    // Endpoint to fetch all users
    @GetMapping("/users")
    public List<User> getUsers() {
        return new ArrayList<>(users.values());
    }

    // Endpoint to add a user
    @PostMapping("/add-user")
    public User addUser(@RequestParam String name, @RequestParam String email, @RequestParam String age) {
        if (name.isEmpty() || email.isEmpty()) {
            throw new IllegalArgumentException("Name and email are required");
        }

        int ageValue;
        try {
            ageValue = Integer.parseInt(age);
        } catch (NumberFormatException e) {
            throw new IllegalArgumentException("Age must be a number");
        }

        String id = UUID.randomUUID().toString();
        User user = new User(id, name, email, ageValue);
        users.put(id, user);
        return user;
    }
}

// User model class
class User {
    private String id;
    private String name;
    private String email;
    private int age;

    public User(String id, String name, String email, int age) {
        this.id = id;
        this.name = name;
        this.email = email;
        this.age = age;
    }

    // Getters and Setters
    public String getId() {
        return id;
    }

    public String getName() {
        return name;
    }

    public String getEmail() {
        return email;
    }

    public int getAge() {
        return age;
    }

    public void setId(String id) {
        this.id = id;
    }

    public void setName(String name) {
        this.name = name;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public void setAge(int age) {
        this.age = age;
    }
}

Featured content