Skip to content

Commit 3173658

Browse files
authored
Merge pull request #4333 from CodeHarborHub/restyled/dev-3
Restyle Dev 3: new content in Js Data Type || new update in blog
2 parents 7e55e32 + 7af1bce commit 3173658

File tree

46 files changed

+1290
-944
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+1290
-944
lines changed

blog/Beginner’s Guide to the Top 5 React Hooks.md

Lines changed: 40 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: 'A Beginner’s Guide to the Top 5 React Hooks'
2+
title: "A Beginner’s Guide to the Top 5 React Hooks"
33
sidebar_label: React hooks
44
authors: [dharshibalasubramaniyam]
55
tags: [react.js, react-hooks]
@@ -36,7 +36,7 @@ In this beginner’s guide, we’ll explore the top 5 React hooks that every Rea
3636
### Importing useState hook from react:
3737

3838
```js
39-
import { useState } from 'react';
39+
import { useState } from "react";
4040
```
4141

4242
### Declaring a state variable named count with an initial value of 0,
@@ -61,6 +61,7 @@ const Counter = () => {
6161
);
6262
};
6363
```
64+
6465
- In above example, when the button is clicked, the onClick event handler calls the setCount function with the updated value of count (count + 1), causing the component to re-render with the new state value.
6566

6667
- Note: We cannot update a state variable like, count = count +1
@@ -71,29 +72,26 @@ const Counter = () => {
7172

7273
```js
7374
const Counter = () => {
74-
const [person, setPerson] = useState({id: '1', name: 'John', age: 25});
75+
const [person, setPerson] = useState({ id: "1", name: "John", age: 25 });
7576

7677
const updateName = (newName) => {
77-
setPerson(prevState => {
78+
setPerson((prevState) => {
7879
return { ...prevState, name: newName };
7980
});
8081
};
8182

8283
const updateAge = (newAge) => {
83-
setPerson(prevState => {
84+
setPerson((prevState) => {
8485
return { ...prevState, age: newAge };
8586
});
8687
};
8788

88-
return (
89-
<div>
90-
{/* form to update name and age */}
91-
</div>
92-
);
89+
return <div>{/* form to update name and age */}</div>;
9390
};
9491
```
9592

9693
## 2. ‘useEffect’ hook
94+
9795
- The useEffect hook in React enables functional components to perform side effects, such as data fetching, DOM manipulation, or subscriptions. It replaces lifecycle methods like componentDidMount, componentDidUpdate, and componentWillUnmount in class components.
9896

9997
### componentDidMount
@@ -105,7 +103,7 @@ const Counter = () => {
105103
```js
106104
useEffect(() => {
107105
// Perform initialization or side effects
108-
console.log("The component is rendered initially.")
106+
console.log("The component is rendered initially.");
109107
}, []);
110108
```
111109

@@ -118,7 +116,7 @@ useEffect(() => {
118116
```js
119117
useEffect(() => {
120118
// Effect runs after every render
121-
console.log("The component is rendered.")
119+
console.log("The component is rendered.");
122120
});
123121
```
124122

@@ -127,7 +125,7 @@ useEffect(() => {
127125
```js
128126
useEffect(() => {
129127
// Perform side effects after state or props update
130-
console.log("dependency1 or dependency2 have updated.")
128+
console.log("dependency1 or dependency2 have updated.");
131129
}, [dependency1, dependency2]);
132130
```
133131

@@ -140,10 +138,10 @@ useEffect(() => {
140138
```js
141139
useEffect(() => {
142140
// Perform side effects
143-
console.log("dependency is updated.")
141+
console.log("dependency is updated.");
144142
return () => {
145143
// Cleanup tasks
146-
console.log("The component is unmounted.")
144+
console.log("The component is unmounted.");
147145
};
148146
}, [dependency]);
149147
```
@@ -158,7 +156,7 @@ useEffect(() => {
158156

159157
```js
160158
// themeContext.js
161-
import React, { createContext } from 'react';
159+
import React, { createContext } from "react";
162160

163161
export const ThemeContext = createContext(null);
164162
```
@@ -169,11 +167,11 @@ export const ThemeContext = createContext(null);
169167

170168
```js
171169
function App() {
172-
const theme = 'dark';
170+
const theme = "dark";
173171

174172
return (
175173
<ThemeContext.Provider value={theme}>
176-
<MyComponent/>
174+
<MyComponent />
177175
</ThemeContext.Provider>
178176
);
179177
}
@@ -184,20 +182,21 @@ function App() {
184182
- Now, any component within the provider can access the context using the useContext hook.
185183

186184
```js
187-
import React, { useContext } from 'react';
188-
import ThemeContext from './ThemeContext';
185+
import React, { useContext } from "react";
186+
import ThemeContext from "./ThemeContext";
189187

190188
function MyComponent() {
191189
const theme = useContext(ThemeContext);
192190

193-
return <div
194-
style={{
195-
background: theme === 'dark' ?
196-
'#222' : '#fff' }
197-
}
198-
>
199-
Content
200-
</div>;
191+
return (
192+
<div
193+
style={{
194+
background: theme === "dark" ? "#222" : "#fff",
195+
}}
196+
>
197+
Content
198+
</div>
199+
);
201200
}
202201
```
203202

@@ -218,25 +217,21 @@ const Counter = () => {
218217
// Step 1: Define initial state
219218
const initialState = { count: 0 };
220219

221-
return (
222-
<div>
223-
content
224-
</div>
225-
);
220+
return <div>content</div>;
226221
};
227222
```
228223

229224
### Reducer Function
230225

231226
- You define a reducer function. This function takes two arguments: the current state and an action, and returns the new state based on the action. The reducer function is responsible for updating the state.
232-
227+
233228
```js
234229
// Step 2: Define reducer function
235230
const reducer = (state, action) => {
236231
switch (action.type) {
237-
case 'increment':
232+
case "increment":
238233
return { count: state.count + 1 };
239-
case 'decrement':
234+
case "decrement":
240235
return { count: state.count - 1 };
241236
default:
242237
throw new Error();
@@ -251,15 +246,15 @@ const reducer = (state, action) => {
251246
```js
252247
const Counter = () => {
253248
const initialState = { count: 0 };
254-
249+
255250
// Step 3: Use useReducer hook
256251
const [state, dispatch] = useReducer(reducer, initialState);
257252

258253
return (
259254
<div>
260255
Count: {state.count}
261-
<button onClick={() => dispatch({ type: 'increment' })}>+</button>
262-
<button onClick={() => dispatch({ type: 'decrement' })}>-</button>
256+
<button onClick={() => dispatch({ type: "increment" })}>+</button>
257+
<button onClick={() => dispatch({ type: "decrement" })}>-</button>
263258
</div>
264259
);
265260
};
@@ -276,7 +271,7 @@ const Counter = () => {
276271
Example 1
277272

278273
```js
279-
import React, { useRef } from 'react';
274+
import React, { useRef } from "react";
280275

281276
function MyComponent() {
282277
// Create a ref to store a DOM element
@@ -305,7 +300,7 @@ In this example, myInputRef is created using useRef, and it's attached to the in
305300
Example 2
306301

307302
```js
308-
import React, { useState, useRef } from 'react';
303+
import React, { useState, useRef } from "react";
309304

310305
function Counter() {
311306
// State for storing the count
@@ -320,10 +315,10 @@ function Counter() {
320315
if (intervalIdRef.current !== null) {
321316
return; // If already running, do nothing
322317
}
323-
318+
324319
// Start the counter
325320
intervalIdRef.current = setInterval(() => {
326-
setCount(prevCount => prevCount + 1);
321+
setCount((prevCount) => prevCount + 1);
327322
}, 1000);
328323
};
329324

@@ -333,7 +328,7 @@ function Counter() {
333328
if (intervalIdRef.current === null) {
334329
return; // If not running, do nothing
335330
}
336-
331+
337332
// Stop the counter
338333
clearInterval(intervalIdRef.current);
339334
intervalIdRef.current = null;
@@ -350,6 +345,7 @@ function Counter() {
350345

351346
export default Counter;
352347
```
348+
353349
- We have a state variable count that stores the current count.
354350
- We create a ref named intervalIdRef using useRef(null). This ref will be used to store the ID returned by setInterval so that we can later clear the interval.
355351
- startCounter function starts a timer using setInterval and increments the count every second. It first checks if the counter is already running to avoid starting multiple timers simultaneously.

blog/Cybersecurity-in-Cloud-Computing.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,89 +11,113 @@ In this guide, we will explore the key aspects of cybersecurity in cloud computi
1111
<!-- truncate -->
1212

1313
## Overview
14+
1415
Cloud computing offers scalable resources and convenience, but it also introduces unique cybersecurity challenges. This guide covers key aspects of cybersecurity in cloud computing, including common threats, best practices, and security frameworks.
1516

1617
## Table of Contents
1718

1819
## 1. Introduction to Cloud Computing
20+
1921
Cloud computing provides on-demand delivery of computing resources over the internet, enabling businesses to scale and innovate quickly. However, this flexibility comes with cybersecurity challenges that need to be addressed to protect sensitive data and applications.
2022

2123
## 2. Common Cloud Security Threats
2224

2325
### Data Breaches
26+
2427
Data breaches in the cloud can occur due to misconfigured storage, weak authentication, or vulnerabilities in the cloud infrastructure.
2528

2629
### Insider Threats
30+
2731
Insider threats involve malicious activities by employees or other trusted individuals who have access to sensitive data.
2832

2933
### Account Hijacking
34+
3035
Attackers can gain unauthorized access to cloud accounts through phishing, brute force attacks, or exploiting vulnerabilities.
3136

3237
### Denial of Service (DoS) Attacks
38+
3339
DoS attacks overwhelm cloud services with traffic, causing disruptions and potentially leading to data loss.
3440

3541
## 3. Cloud Security Models
3642

3743
### Shared Responsibility Model
44+
3845
The shared responsibility model divides security responsibilities between the cloud provider and the customer. Providers secure the infrastructure, while customers are responsible for securing their data and applications.
3946

4047
### Security as a Service (SECaaS)
48+
4149
SECaaS delivers security services through the cloud, offering solutions like antivirus, intrusion detection, and security monitoring.
4250

4351
## 4. Best Practices for Cloud Security
4452

4553
### Data Encryption
54+
4655
Encrypt data both in transit and at rest to protect it from unauthorized access.
4756

4857
### Identity and Access Management (IAM)
58+
4959
Implement strong IAM practices, including multi-factor authentication (MFA) and least privilege access, to control who can access cloud resources.
5060

5161
### Regular Audits and Compliance
62+
5263
Conduct regular security audits and ensure compliance with relevant standards and regulations.
5364

5465
### Secure Application Development
66+
5567
Follow secure coding practices and regularly update applications to fix security vulnerabilities.
5668

5769
## 5. Cloud Security Frameworks and Standards
5870

5971
### NIST Cloud Computing Security
72+
6073
The National Institute of Standards and Technology (NIST) provides guidelines and best practices for securing cloud environments.
6174

6275
### ISO/IEC 27017
76+
6377
This international standard offers guidelines for information security controls specific to cloud services.
6478

6579
### CSA Cloud Controls Matrix
80+
6681
The Cloud Security Alliance (CSA) provides a framework of security controls tailored to cloud computing environments.
6782

6883
## 6. Implementing Cloud Security
6984

7085
### Choosing a Secure Cloud Provider
86+
7187
Select a cloud provider with strong security measures, certifications, and a proven track record.
7288

7389
### Configuring Security Settings
90+
7491
Properly configure security settings, such as firewalls, encryption, and access controls, to protect cloud resources.
7592

7693
### Monitoring and Incident Response
94+
7795
Implement continuous monitoring and establish an incident response plan to quickly detect and respond to security incidents.
7896

7997
## 7. Case Studies of Cloud Security Breaches
8098

8199
### Analysis of Major Incidents
100+
82101
Examine major cloud security breaches to understand how they occurred and the impact they had.
83102

84103
### Lessons Learned
104+
85105
Learn from past incidents to improve security measures and prevent similar breaches in the future.
86106

87107
## 8. Future Trends in Cloud Security
88108

89109
### AI and Machine Learning
110+
90111
Artificial intelligence and machine learning can enhance cloud security by detecting and responding to threats in real-time.
91112

92113
### Quantum Computing
114+
93115
Quantum computing poses new challenges and opportunities for cloud security, particularly in the field of encryption.
94116

95117
### Zero Trust Architecture
118+
96119
Zero trust architecture assumes that threats can come from both outside and inside the network, and it implements strict access controls and continuous monitoring.
97120

98121
## 9. Conclusion
122+
99123
Securing cloud environments is crucial for protecting sensitive data and maintaining trust. By understanding the unique challenges of cloud security and implementing best practices, organizations can leverage the benefits of cloud computing while minimizing risks.

0 commit comments

Comments
 (0)