Snippets Collections
ssh-keygen -R 85.31.239.241  # Remove the old entry
ssh-keyscan 85.31.239.241 >> ~/.ssh/known_hosts  # Add the new entry
<p style={{ whiteSpace: "pre-line" }} className="text-[#FFF] opacity-90">
                 {question.answer}
</p>
import React, { useState } from 'react';

function EmailInput() {
  const [email, setEmail] = useState('');
  const [isValid, setIsValid] = useState(true);

  const validateEmail = (email) => {
    // Regular expression for email validation
    const emailPattern = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
    return emailPattern.test(email);
  };

  const handleChange = (event) => {
    const inputValue = event.target.value;
    setEmail(inputValue);
    setIsValid(validateEmail(inputValue));
  };

  return (
    <div>
      <label htmlFor="emailInput">Email:</label>
      <input
        type="text"
        id="emailInput"
        value={email}
        onChange={handleChange}
        style={{ borderColor: isValid ? 'initial' : 'red' }}
      />
      {!isValid && <p style={{ color: 'red' }}>Please enter a valid email address.</p>}
    </div>
  );
}

export default EmailInput;
/* Chrome, Safari, Edge, Opera */
input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

/* Firefox */
input[type=number] {
  -moz-appearance: textfield;
}
import React, { useState } from 'react';
import { Pagination } from 'antd';
import 'antd/dist/reset.css'; // Import Ant Design styles

const Test = () => {
  const itemsPerPage = 3; // Number of items (posts) to display per page

  const [currentPage, setCurrentPage] = useState(1);

  // Simulated array of posts
  const posts = [
    { id: 1, title: 'Post 1', content: 'Content of post 1' },
    { id: 2, title: 'Post 2', content: 'Content of post 2' },
    { id: 3, title: 'Post 3', content: 'Content of post 3' },
    { id: 4, title: 'Post 4', content: 'Content of post 4' },
    { id: 5, title: 'Post 5', content: 'Content of post 5' },
    { id: 6, title: 'Post 6', content: 'Content of post 6' },
    { id: 7, title: 'Post 7', content: 'Content of post 7' },
    { id: 8, title: 'Post 8', content: 'Content of post 8' },
    { id: 9, title: 'Post 9', content: 'Content of post 9' },
  ];

  const totalItems = posts.length;

  const handlePageChange = (newPage) => {
    if (newPage >= 1 && newPage <= Math.ceil(totalItems / itemsPerPage)) {
      setCurrentPage(newPage);
    }
  };

  const currentPosts = posts.slice(
    (currentPage - 1) * itemsPerPage,
    currentPage * itemsPerPage
  );

  return (
    <div className="container mx-auto p-4">
      <h1 className="text-2xl font-semibold mb-4">Paginated Posts</h1>
      {currentPosts.map((post) => (
        <div key={post.id} className="border p-4 mb-4">
          <h2 className="text-lg font-semibold">{post.title}</h2>
          <p>{post.content}</p>
        </div>
      ))}
      <div className="flex flex-row justify-between items-center rounded-xl mt-10 px-2 gap-5 md:px-8 py-3 border w-full">
        <button
          className={`border p-2 px-4 ${
            currentPage === 1 ? 'border-navy bg-navy text-white' : 'border-navy'
          } rounded-full`}
          onClick={() => handlePageChange(currentPage - 1)}
          disabled={currentPage === 1}
        >
          BACK
        </button>
        <div className="flex flex-wrap gap-3 mb-[21px] items-end text-navy">
          <Pagination
            current={currentPage}
            total={totalItems}
            pageSize={itemsPerPage}
            showSizeChanger={false}
            showLessItems={true}
            showQuickJumper={false}
            onChange={handlePageChange}
            itemRender={(current, type, originalElement) => {
              if (type === 'page') {
                return (
                  <button
                    className={`border p-2 px-4 ${
                      current === currentPage ? 'border-navy bg-navy text-white' : 'border-navy'
                    } rounded-full`}
                    style={{ cursor: 'pointer' }}
                    onClick={() => handlePageChange(current)}
                  >
                    {current}
                  </button>
                );
              } else if (type === 'jump-prev' || type === 'jump-next') {
                return (
                  <button
                    className=" p-2 px-3  rounded-full"
                    style={{ color: 'blue', cursor: 'pointer' }}
                    onClick={() => handlePageChange(currentPage + 1)}
                  >
                    .....
                  </button>
                );
              }
            }}
          />
        </div>
        <button
          className={`border p-2 px-4 ${
            currentPage === Math.ceil(totalItems / itemsPerPage)
              ? 'border-navy bg-navy text-white'
              : 'border-navy'
          } rounded-full`}
          onClick={() => handlePageChange(currentPage + 1)}
          disabled={currentPage === Math.ceil(totalItems / itemsPerPage)}
        >
          NEXT
        </button>
      </div>
    </div>
  );
};

export default Test;
Step 1 (This is the step one)
npm init
Step 2 (This is the step 2 install general dependencies)
npm i nodemon mongoose dotenv bcrypt jsonwebtoken cookie-parser express
Step 3 
Make following folders 
1) controllers
2) models
3) routes
4) utils
5) .env
6) server.js and then make change in package json file => "scripts": {
    "start": "nodemon index.js"
  },
    
Explore this=>https://github.com/safak/youtube2022/tree/mern-booking/api
npx create-react-app .

I have to write dot so that i install dependencies in cureent folder and then you can follow 
Docs.

Install this dependencies as well 

npm i react-router-dom@6.4.2 react-icons

And then make components folder, pages folder, Assests Folder.

And then Write code for routers in App.js
/* Hide scrollbar indicator */
::-webkit-scrollbar {
  width: 0;
  height: 0;
  background-color: transparent;
}

/* Optional: add a border around the scrollable content to indicate where scrolling is possible */
.scrollable-content {
  border: 1px solid #ccc;
}
Note that this method only works for WebKit browsers and does not affect other browsers. Therefore, it's recommended to use the overflow-y-auto class (or another appropriate Tailwind CSS utility class) to ensure consistent styling and behavior across all browsers.

Here's an example of how to use the overflow-y-auto class on an element:

html
Copy code
<div class="overflow-y-auto">
  <!-- content here -->
</div>
The overflow-y-auto class allows scrolling in the y-axis when the content overflows the container, and displays the scrollbar indicator only when necessary.





ls(Get list from current folder)
cd(To change directory)
cd .. (Back to folder)
mkdir( Make any folder)
rm (For remove)
pwd ( Print Directory Path )
mv ( To rename any folder)
touch indec.html style.css script.js (Makes files)

What is Git

{To start local repositry to write (git init)}

Git is simply version control of code we can get previous version of code.

(git log) to check all commits which have done in local repository(.git) which 
has snaps of your versions of code 
 

git checkout "241252154125125125125" (if we want to go previous version of code)
 
git checkout master ( To go to current version of code)

git branch branchname (It wil create branch) 

git log --oneline --all --graph  
This message indicates that your current branch is 10 commits behind the main branch. This means that the main branch has progressed further than your current branch and has 10 more commits that your branch does not have.

To update your branch with the changes from the main branch, you can use the git pull command. This will fetch the changes from the remote repository and merge them into your current branch.

Here are the steps you can follow:

Make sure you are on your current branch by running git branch. The current branch will be highlighted with an asterisk.
Run git pull origin main. This will fetch the changes from the main branch in the remote repository and merge them into your current branch.
Resolve any merge conflicts that may arise during the merge process. You will need to edit the conflicting files manually to resolve the conflicts.
Once you have resolved the conflicts, add the changes using git add . or git add <file> for each file you have resolved.
Commit the changes using git commit -m "Merge changes from main branch"
Push the changes to the remote repository using git push origin <your-branch-name>.
After these steps, your branch should be updated with the changes from the main branch.
git add . 
git commit -m "Added new functionality"
git push origin main
push code into specific branch


To push code into a specific branch in Git, you can follow these steps:

First, make sure you are in the correct branch by running the command:

git branch


This will show you the list of branches in your local repository, and the branch that you are currently on will be marked with an asterisk (*).

If you are not in the correct branch, switch to the desired branch using the command:
php

git checkout -b <branch-name>
Replace <branch-name> with the name of the branch you want to switch to.

Once you are in the correct branch, add the changes you want to commit using the command:
csharp
Copy code
git add .
This will add all the changes in your current directory to the staging area.

Commit the changes using the command:
sql

git commit -m "commit message"
Replace "commit message" with a brief description of the changes you made.

Finally, push the changes to the remote repository using the command:
perl

git push origin <branch-name>
Replace <branch-name> with the name of the branch you want to push the changes to.

That's it! Your code changes should now be pushed to the specified branch in the remote repository
star

Tue Sep 19 2023 20:14:24 GMT+0000 (Coordinated Universal Time)

#spreadoperator
star

Wed Aug 23 2023 07:58:12 GMT+0000 (Coordinated Universal Time)

#spreadoperator
star

Wed Aug 16 2023 07:28:53 GMT+0000 (Coordinated Universal Time)

#spreadoperator
star

Tue Aug 15 2023 12:30:00 GMT+0000 (Coordinated Universal Time)

#spreadoperator
star

Tue Aug 15 2023 08:20:48 GMT+0000 (Coordinated Universal Time)

#spreadoperator
star

Thu Aug 10 2023 09:31:20 GMT+0000 (Coordinated Universal Time)

#spreadoperator
star

Thu Apr 20 2023 07:03:03 GMT+0000 (Coordinated Universal Time)

#spreadoperator
star

Thu Apr 20 2023 06:28:19 GMT+0000 (Coordinated Universal Time)

#spreadoperator
star

Wed Apr 12 2023 06:38:11 GMT+0000 (Coordinated Universal Time)

#spreadoperator
star

Wed Apr 12 2023 00:24:01 GMT+0000 (Coordinated Universal Time)

#spreadoperator
star

Mon Mar 27 2023 12:01:59 GMT+0000 (Coordinated Universal Time)

#spreadoperator
star

Sat Mar 18 2023 14:28:27 GMT+0000 (Coordinated Universal Time)

#spreadoperator
star

Tue Mar 14 2023 18:16:59 GMT+0000 (Coordinated Universal Time)

#spreadoperator
star

Mon Mar 06 2023 20:13:11 GMT+0000 (Coordinated Universal Time)

#spreadoperator

Save snippets that work with our extensions

Available in the Chrome Web Store Get Firefox Add-on Get VS Code extension