how to edit configuration file from cli

 php --ini | grep 'Loaded Configuration File'

 1994  nano /etc/php/8.1/cli/php.ini

 1995  sudo nano /path/to/php.ini

 1996  sudo nano /etc/php/8.1/cli/php.ini


edit ,save

ctrl x

y

ctrl t

select file


make logout in n minutes

 it will caliculate time gap bewtween each request

if it is request cross greater thatn 10 minutes

its logout

axios.interceptors.request.use(function (request) { const d = new Date(); let current_time =d.getTime(); let api_request_timeout = (60000)*(globalVariables.api_request_timeout); let timeout = current_time - parseInt(globalVariables.last_request_time_stamp); if (api_request_timeout <= timeout){ router.push({ name: "logout" }).catch(() => {}); } globalVariables.last_request_time_stamp =current_time; return request; } );)

route::resource

Route::resource('students', 'StudentController');



Verb          | URI                   | Action          | Route Name
--------------|-----------------------|-----------------|-----------------
GET           | /students             | index           | students.index
GET           | /students/create      | create          | students.create
POST          | /students             | store           | students.store
GET           | /students/{student}   | show            | students.show
GET           | /students/{student}/edit | edit          | students.edit
PUT/PATCH     | /students/{student}   | update          | students.update
DELETE        | /students/{student}   | destroy         | students.destroy

aws

 cloud - data storage platform in online

cloud computing -> delivering of computing serveices

including servers, storage, databases, networking, software, analytics and intelligence over the internet


google drive free upto 15 gb

grete rhan free limit->  u have to pay

pay if u need serivecs

use of cloud: if we wanna work or develop an application 

we can develop at our own pc with high specs

or 

go to internetn center, already application deplloyed in server, use taht code and do changes in code and deploy ->  processing of accesing data/application via internent

cloud providers

google cloud

azure

aws

digtal ocean


cloud has two models

service and deploymetn model(like private or shared hosting)



privat coloud -> upto this company
pubic cloud-> all are acceptable
hybrid cloud-> in an application _> something we can hide to publlic useres



aws 
it is best cloud provider
it is first among all clouds
it offers multiple services on different domains

it is hte combinatiioon of saas, iaas, pass

sass-software as services
iaas-infrstracutre
paas-platform

cost benefits
no upfront cost
pay as u go model
purchasing optons ( how many options need that much money use)








what is promise and what is async what sthe difference

 


Promises and the async/await syntax are both used for handling asynchronous operations in JavaScript. Here's an explanation of each and the difference between them:

  1. Promises:
    • A Promise is an object that represents the eventual completion (or failure) of an asynchronous operation and its resulting value.
    • Promises provide a way to write asynchronous code that is more readable and avoids callback hell.
    • A Promise can be in one of three states: pending, fulfilled, or rejected.
    • The core idea behind Promises is that they allow you to chain multiple asynchronous operations together and handle success or failure using the then and catch methods.
    • Promises are available in most modern JavaScript environments and are widely supported.

Example using Promises:



 s

function fetchData() {
  return new Promise((resolve, reject) => {
    setTimeout(() => {
      const data = 'Some data';
      resolve(data); // Resolve the Promise with the data
      // or reject(new Error('Error message')) to reject the Promise
    }, 2000);
  });
}

fetchData()
  .then(data => {
    console.log(data); // Handle the resolved value
  })
  .catch(error => {
    console.error(error); // Handle any errors
  });

s

  1. async/await:
    • async/await is a syntactic feature introduced in ES2017 (ES8) that allows you to write asynchronous code in a more synchronous-like manner.
    • It provides a more concise and readable way to work with Promises.
    • The async keyword is used to define an asynchronous function, which automatically returns a Promise.
    • Inside an async function, the await keyword is used to pause the execution and wait for a Promise to resolve, and then it retrieves the resolved value.
    • The await expression can only be used within an async function.

Example using async/await:

 s

function fetchData() {
  return new Promise((resolve, reject) => {
    setTimeout(() => {
      const data = 'Some data';
      resolve(data); // Resolve the Promise with the data
      // or reject(new Error('Error message')) to reject the Promise
    }, 2000);
  });
}

async function fetchDataAsync() {
  try {
    const data = await fetchData(); // Wait for the Promise to resolve
    console.log(data); // Handle the resolved value
  } catch (error) {
    console.error(error); // Handle any errors
  }
}

fetchDataAsync();

s


The main difference between Promises and async/await is the syntax and coding style. Promises use the then and catch methods to handle asynchronous results, while async/await provides a more sequential and synchronous-looking code structure by using the async and await keywords.

async/await is built on top of Promises and provides a more concise way to write asynchronous code. It is often considered more readable and easier to understand, especially when dealing with multiple asynchronous operations or when there is a need for sequential execution.

It's important to note that both Promises and async/await are powerful tools for handling asynchronous operations, and the choice between them depends on personal preference and the specific requirements of the project. 



type of state in promise



In the context of Promises, there are three possible states that a Promise can be in:

  1. Pending:

    • When a Promise is created, it is initially in the pending state.
    • This means that the asynchronous operation associated with the Promise is still in progress and has not yet resolved or rejected.
    • While in the pending state, the Promise can transition to either the fulfilled (resolved) or rejected state.
  2. Fulfilled (Resolved):

    • When the asynchronous operation associated with the Promise is successfully completed, the Promise transitions to the fulfilled state.
    • In the fulfilled state, the Promise is considered resolved, and it holds the resulting value or data produced by the asynchronous operation.
    • The resolved value can be accessed using the then method, which allows you to chain additional actions.
  3. Rejected:

    • If an error or exception occurs during the execution of the asynchronous operation, the Promise transitions to the rejected state.
    • In the rejected state, the Promise indicates that the operation failed and holds the reason or error object that describes the failure.
    • The rejection reason can be accessed using the catch method or the second argument of the then method.

Here's an example that demonstrates the different states of a Promise:




 s

const myPromise = new Promise((resolve, reject) => {
  setTimeout(() => {
    const randomNumber = Math.random();

    if (randomNumber < 0.5) {
      resolve(randomNumber); // Transition to the fulfilled state
    } else {
      reject(new Error('Random number is too large')); // Transition to the rejected state
    }
  }, 2000);
});

myPromise
  .then(result => {
    console.log('Fulfilled:', result); // Handle the resolved value
  })
  .catch(error => {
    console.error('Rejected:', error); // Handle the rejection reason
  });

s

In this example, the Promise is created with a simple asynchronous operation that generates a random number. If the random number is less than 0.5, the Promise resolves with the random number as the fulfilled value. Otherwise, if the random number is greater than or equal to 0.5, the Promise rejects with an error indicating that the random number is too large.

By chaining the then method, we handle the fulfilled state and log the resolved value. If an error occurs and the Promise is rejected, we handle the rejected state by catching the error using the catch method.

Understanding the different states of a Promise is important for handling asynchronous operations and managing the flow of your code.


call apply bind in javasript

 call calling funciton

aply -> with arguments

bind-> adding to this funciton


The call, apply, and bind methods are built-in methods in JavaScript that are used to manipulate the this value and invoke functions with a specific context. The spread operator (...) is a syntax feature introduced in ES6 that allows for expanding iterables (like arrays or strings) into individual elements. While the spread operator and these methods can be used in similar scenarios, they have different purposes and use cases. Let's explore each of them:

  1. call Method:

    • The call method is used to invoke a function with a specific this value and arguments provided individually.
    • It accepts the thisArg (the value to be used as this inside the function) as the first argument, followed by any additional arguments passed to the function.
    • Example: func.call(thisArg, arg1, arg2, ...)
  2. apply Method:

    • The apply method is similar to call but accepts the thisArg as the first argument and an array-like or iterable object containing the arguments as the second argument.
    • It is particularly useful when the arguments are already in an array or an array-like structure.
    • Example: func.apply(thisArg, [arg1, arg2, ...])
  3. bind Method:

    • The bind method is used to create a new function with a bound this value and, optionally, pre-filled arguments.
    • It returns a new function that, when called, has the provided this value and any specified arguments, with any additional arguments passed at the time of invocation.
    • Example: const boundFunc = func.bind(thisArg, arg1, arg2, ...)
  4. Spread Operator (...):

    • The spread operator is not a method but a syntax feature introduced in ES6.
    • It allows you to expand elements of an array, string, or other iterable objects into individual elements.
    • It can be used for array concatenation, function arguments, array destructuring, and more.
    • Example: const arr = [1, 2, 3]; const newArr = [...arr];

In summary, the call and apply methods are used to invoke functions with a specific this value and arguments, while the bind method creates a new function with a bound this value. On the other hand, the spread operator (...) is used for expanding arrays or iterables into individual elements. Each of these features serves a specific purpose and can be used in different scenarios depending on the desired behavior and requirements of your code.

Certainly! Here are some examples to illustrate the usage of call, apply, bind, and the spread operator:

  1. Using call:

 s

function greet(name) {
  console.log(`Hello, ${name}! My name is ${this.name}.`);
}

const person = {
  name: 'John'
};

greet.call(person, 'Alice'); 
// Output: Hello, Alice! My name is John.

s


  1. Using apply:

 s

function sum(a, b, c) {
  return a + b + c;
}

const numbers = [1, 2, 3];

const result = sum.apply(null, numbers);
console.log(result); 
// Output: 6

s

  1. Using bind:

 s

function multiply(a, b) {
  return a * b;
}

const multiplyByTwo = multiply.bind(null, 2);

const result = multiplyByTwo(5);
console.log(result); 
// Output: 10

s

  1. Using the spread operator:

 s

const arr1 = [1, 2, 3];
const arr2 = [4, 5, 6];

const combinedArray = [...arr1, ...arr2];
console.log(combinedArray); 
// Output: [1, 2, 3, 4, 5, 6]

const str = 'Hello';
const characters = [...str];
console.log(characters); 
// Output: ['H', 'e', 'l', 'l', 'o']

s

These examples demonstrate different scenarios where call, apply, bind, and the spread operator can be used. The call and apply methods allow you to invoke functions with a specific this value and arguments, while bind creates a new function with a bound this value. The spread operator ... is used to expand arrays or iterables into individual elements for various purposes.

 s

Event listening in react

 How we can listen to som eevents some envents fire like click or automatically user enters into input button , that is event on word type i...