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
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
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('students', 'StudentController');
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)
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:
then
and catch
methods.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
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.async
keyword is used to define an asynchronous function, which automatically returns a Promise.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.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:
Pending:
Fulfilled (Resolved):
then
method, which allows you to chain additional actions.Rejected:
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 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:
call
Method:
call
method is used to invoke a function with a specific this
value and arguments provided individually.thisArg
(the value to be used as this
inside the function) as the first argument, followed by any additional arguments passed to the function.func.call(thisArg, arg1, arg2, ...)
apply
Method:
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.func.apply(thisArg, [arg1, arg2, ...])
bind
Method:
bind
method is used to create a new function with a bound this
value and, optionally, pre-filled arguments.this
value and any specified arguments, with any additional arguments passed at the time of invocation.const boundFunc = func.bind(thisArg, arg1, arg2, ...)
Spread Operator (...
):
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:
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
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
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
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
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...