From a4155c0a29f97b2dd86601ca54056cf61702a6f1 Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Thu, 22 Aug 2024 08:29:18 +0000 Subject: [PATCH 1/2] Restyled by prettier-markdown --- ...00\231s Guide to the Top 5 React Hooks.md" | 84 +-- blog/Cybersecurity-in-Cloud-Computing.md | 24 + blog/DOM manipulation in JavaScript.md | 114 ++- .../index.md | 23 +- blog/Getting started with PostgreSQL.md | 308 +++++--- blog/Getting-started-with-nextJS.md | 63 +- blog/Introduction in Python Development.md | 6 +- ...ion to Cyber Security and Web Explosion.md | 2 +- blog/JavaScript ES6 features.md | 10 +- ...l for Natural Language Processing Tasks.md | 4 +- blog/Mastering Data Structures in Python.md | 3 +- blog/Mastering Design Patterns in Java.md | 27 +- blog/Mastering OOP concepts in JAVA.md | 152 ++-- blog/Mastering SOLID principles in Java.md | 41 +- .../Quantum computing and it's application.md | 8 +- blog/Web-Development-with-Django.md | 83 ++- blog/ai-in-healthcare.md | 7 +- blog/automating-tasks-with-python.md | 2 +- ...ding-and-deploying-progressive-web-apps.md | 59 +- ...pment with-microservices-and-kubernetes.md | 15 +- blog/composable-architecture.md | 7 +- ...ainerization-with-docker-and-kubernetes.md | 27 +- blog/debugging.md | 26 +- blog/developing-cross-platform-apps.md | 23 +- .../index.md | 13 +- blog/from-ftp-client-to-github-action.md | 4 +- blog/getting-started-with-mern/index.md | 702 +++++++++--------- .../index.md | 6 +- blog/getting-started-with-nlp.md | 8 +- ...ng-started-with-serverless-architecture.md | 38 +- blog/getting-started-with-vite/index.md | 2 +- blog/git-best-practicies.md | 4 +- blog/install-mongodb-linux.md | 2 +- blog/install-mongodb-windows.md | 2 +- ...he-Linux-development-and-cyber-security.md | 7 +- blog/introduction-to-web-assembly.md | 6 +- ...integration-and-application-development.md | 33 +- ...everaging-gpt-models-for-microfrontends.md | 3 +- blog/microservices-architecture.md | 19 +- blog/piracy-preserving-ai.md | 32 +- blog/react-js.md | 59 +- blog/reactjs-mongodb-chrome-extension.md | 80 +- blog/sed-normalize-md-file-with-regex.md | 6 +- blog/sql.md | 45 +- .../data-types/primitive-types/string.md | 33 +- .../data-types/primitive-types/undefined.md | 12 +- 46 files changed, 1290 insertions(+), 944 deletions(-) diff --git "a/blog/Beginner\342\200\231s Guide to the Top 5 React Hooks.md" "b/blog/Beginner\342\200\231s Guide to the Top 5 React Hooks.md" index 937914baa..44d17cf88 100644 --- "a/blog/Beginner\342\200\231s Guide to the Top 5 React Hooks.md" +++ "b/blog/Beginner\342\200\231s Guide to the Top 5 React Hooks.md" @@ -1,5 +1,5 @@ --- -title: 'A Beginner’s Guide to the Top 5 React Hooks' +title: "A Beginner’s Guide to the Top 5 React Hooks" sidebar_label: React hooks authors: [dharshibalasubramaniyam] 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 ### Importing useState hook from react: ```js -import { useState } from 'react'; +import { useState } from "react"; ``` ### Declaring a state variable named count with an initial value of 0, @@ -61,6 +61,7 @@ const Counter = () => { ); }; ``` + - 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. - Note: We cannot update a state variable like, count = count +1 @@ -71,29 +72,26 @@ const Counter = () => { ```js const Counter = () => { - const [person, setPerson] = useState({id: '1', name: 'John', age: 25}); + const [person, setPerson] = useState({ id: "1", name: "John", age: 25 }); const updateName = (newName) => { - setPerson(prevState => { + setPerson((prevState) => { return { ...prevState, name: newName }; }); }; const updateAge = (newAge) => { - setPerson(prevState => { + setPerson((prevState) => { return { ...prevState, age: newAge }; }); }; - return ( -
- {/* form to update name and age */} -
- ); + return
{/* form to update name and age */}
; }; ``` ## 2. ‘useEffect’ hook + - 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. ### componentDidMount @@ -105,7 +103,7 @@ const Counter = () => { ```js useEffect(() => { // Perform initialization or side effects - console.log("The component is rendered initially.") + console.log("The component is rendered initially."); }, []); ``` @@ -118,7 +116,7 @@ useEffect(() => { ```js useEffect(() => { // Effect runs after every render - console.log("The component is rendered.") + console.log("The component is rendered."); }); ``` @@ -127,7 +125,7 @@ useEffect(() => { ```js useEffect(() => { // Perform side effects after state or props update - console.log("dependency1 or dependency2 have updated.") + console.log("dependency1 or dependency2 have updated."); }, [dependency1, dependency2]); ``` @@ -140,10 +138,10 @@ useEffect(() => { ```js useEffect(() => { // Perform side effects - console.log("dependency is updated.") + console.log("dependency is updated."); return () => { // Cleanup tasks - console.log("The component is unmounted.") + console.log("The component is unmounted."); }; }, [dependency]); ``` @@ -158,7 +156,7 @@ useEffect(() => { ```js // themeContext.js -import React, { createContext } from 'react'; +import React, { createContext } from "react"; export const ThemeContext = createContext(null); ``` @@ -169,11 +167,11 @@ export const ThemeContext = createContext(null); ```js function App() { - const theme = 'dark'; + const theme = "dark"; return ( - + ); } @@ -184,20 +182,21 @@ function App() { - Now, any component within the provider can access the context using the useContext hook. ```js -import React, { useContext } from 'react'; -import ThemeContext from './ThemeContext'; +import React, { useContext } from "react"; +import ThemeContext from "./ThemeContext"; function MyComponent() { const theme = useContext(ThemeContext); - return
- Content -
; + return ( +
+ Content +
+ ); } ``` @@ -218,25 +217,21 @@ const Counter = () => { // Step 1: Define initial state const initialState = { count: 0 }; - return ( -
- content -
- ); + return
content
; }; ``` ### Reducer Function - 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. - + ```js // Step 2: Define reducer function const reducer = (state, action) => { switch (action.type) { - case 'increment': + case "increment": return { count: state.count + 1 }; - case 'decrement': + case "decrement": return { count: state.count - 1 }; default: throw new Error(); @@ -251,15 +246,15 @@ const reducer = (state, action) => { ```js const Counter = () => { const initialState = { count: 0 }; - + // Step 3: Use useReducer hook const [state, dispatch] = useReducer(reducer, initialState); return (
Count: {state.count} - - + +
); }; @@ -276,7 +271,7 @@ const Counter = () => { Example 1 ```js -import React, { useRef } from 'react'; +import React, { useRef } from "react"; function MyComponent() { // 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 Example 2 ```js -import React, { useState, useRef } from 'react'; +import React, { useState, useRef } from "react"; function Counter() { // State for storing the count @@ -320,10 +315,10 @@ function Counter() { if (intervalIdRef.current !== null) { return; // If already running, do nothing } - + // Start the counter intervalIdRef.current = setInterval(() => { - setCount(prevCount => prevCount + 1); + setCount((prevCount) => prevCount + 1); }, 1000); }; @@ -333,7 +328,7 @@ function Counter() { if (intervalIdRef.current === null) { return; // If not running, do nothing } - + // Stop the counter clearInterval(intervalIdRef.current); intervalIdRef.current = null; @@ -350,6 +345,7 @@ function Counter() { export default Counter; ``` + - We have a state variable count that stores the current count. - 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. - 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. diff --git a/blog/Cybersecurity-in-Cloud-Computing.md b/blog/Cybersecurity-in-Cloud-Computing.md index c44bfa756..bca73d018 100644 --- a/blog/Cybersecurity-in-Cloud-Computing.md +++ b/blog/Cybersecurity-in-Cloud-Computing.md @@ -11,89 +11,113 @@ In this guide, we will explore the key aspects of cybersecurity in cloud computi ## Overview + 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. ## Table of Contents ## 1. Introduction to Cloud Computing + 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. ## 2. Common Cloud Security Threats ### Data Breaches + Data breaches in the cloud can occur due to misconfigured storage, weak authentication, or vulnerabilities in the cloud infrastructure. ### Insider Threats + Insider threats involve malicious activities by employees or other trusted individuals who have access to sensitive data. ### Account Hijacking + Attackers can gain unauthorized access to cloud accounts through phishing, brute force attacks, or exploiting vulnerabilities. ### Denial of Service (DoS) Attacks + DoS attacks overwhelm cloud services with traffic, causing disruptions and potentially leading to data loss. ## 3. Cloud Security Models ### Shared Responsibility Model + 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. ### Security as a Service (SECaaS) + SECaaS delivers security services through the cloud, offering solutions like antivirus, intrusion detection, and security monitoring. ## 4. Best Practices for Cloud Security ### Data Encryption + Encrypt data both in transit and at rest to protect it from unauthorized access. ### Identity and Access Management (IAM) + Implement strong IAM practices, including multi-factor authentication (MFA) and least privilege access, to control who can access cloud resources. ### Regular Audits and Compliance + Conduct regular security audits and ensure compliance with relevant standards and regulations. ### Secure Application Development + Follow secure coding practices and regularly update applications to fix security vulnerabilities. ## 5. Cloud Security Frameworks and Standards ### NIST Cloud Computing Security + The National Institute of Standards and Technology (NIST) provides guidelines and best practices for securing cloud environments. ### ISO/IEC 27017 + This international standard offers guidelines for information security controls specific to cloud services. ### CSA Cloud Controls Matrix + The Cloud Security Alliance (CSA) provides a framework of security controls tailored to cloud computing environments. ## 6. Implementing Cloud Security ### Choosing a Secure Cloud Provider + Select a cloud provider with strong security measures, certifications, and a proven track record. ### Configuring Security Settings + Properly configure security settings, such as firewalls, encryption, and access controls, to protect cloud resources. ### Monitoring and Incident Response + Implement continuous monitoring and establish an incident response plan to quickly detect and respond to security incidents. ## 7. Case Studies of Cloud Security Breaches ### Analysis of Major Incidents + Examine major cloud security breaches to understand how they occurred and the impact they had. ### Lessons Learned + Learn from past incidents to improve security measures and prevent similar breaches in the future. ## 8. Future Trends in Cloud Security ### AI and Machine Learning + Artificial intelligence and machine learning can enhance cloud security by detecting and responding to threats in real-time. ### Quantum Computing + Quantum computing poses new challenges and opportunities for cloud security, particularly in the field of encryption. ### Zero Trust Architecture + Zero trust architecture assumes that threats can come from both outside and inside the network, and it implements strict access controls and continuous monitoring. ## 9. Conclusion + 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. diff --git a/blog/DOM manipulation in JavaScript.md b/blog/DOM manipulation in JavaScript.md index 61adde58e..3a93c3b75 100644 --- a/blog/DOM manipulation in JavaScript.md +++ b/blog/DOM manipulation in JavaScript.md @@ -1,5 +1,5 @@ --- -title: 'DOM manipulation in JavaScript' +title: "DOM manipulation in JavaScript" sidebar_label: DOM-manipulation-in-JavaScript authors: [dharshibalasubramaniyam] tags: [dom, javascript] @@ -17,30 +17,30 @@ In web development, the Document Object Model (DOM) is a crucial aspect of creat - This model allows developers to interact with the document programmatically via scripting languages like JavaScript. -- When a web page is loaded, the browser parses the HTML and creates the DOM. +- When a web page is loaded, the browser parses the HTML and creates the DOM. - The DOM represents the document as a tree of nodes, where each node is an object representing a part of the document: -*Document Node*: Represents the entire document. +_Document Node_: Represents the entire document. -*Element Nodes*: Represent HTML elements like `
`, `

`, ``, etc. +_Element Nodes_: Represent HTML elements like `

`, `

`, ``, etc. -*Text Nodes*: Contain the text content within elements. +_Text Nodes_: Contain the text content within elements. -*Attribute Nodes*: Represent the attributes of HTML elements (`class`, `id`, `src` etc.). +_Attribute Nodes_: Represent the attributes of HTML elements (`class`, `id`, `src` etc.). For example, consider the following HTML: ```html - + - + Example with Attributes - - + +

Hello, World!

This is a paragraph.

- + ``` @@ -62,7 +62,7 @@ Document │ └── "This is a paragraph." ``` -The DOM plays a central role in web development by enabling developers to create dynamic and interactive web pages. +The DOM plays a central role in web development by enabling developers to create dynamic and interactive web pages. - Access and manipulate elements: Developers can use JavaScript to select, modify, and create HTML elements. @@ -70,7 +70,7 @@ The DOM plays a central role in web development by enabling developers to create - Modify styles: Through the DOM, developers can change the CSS styles of elements dynamically. -## 2. DOM Manipulation +## 2. DOM Manipulation ### 2.1. Accessing Elements @@ -80,16 +80,15 @@ The DOM plays a central role in web development by enabling developers to create
Hello, World!
``` - ```js // Get the element with the ID 'myElement' -const element = document.getElementById('myElement'); +const element = document.getElementById("myElement"); // Log the element to the console console.log(element); ``` -- To get elements by their class, we can use the `getElementsByClassName` method. This method returns a live HTMLCollection of elements with the specified class name. +- To get elements by their class, we can use the `getElementsByClassName` method. This method returns a live HTMLCollection of elements with the specified class name. ```html
First Element
@@ -99,14 +98,14 @@ console.log(element); ```js // Get the elements with the class name 'myClass' -const elements = document.getElementsByClassName('myClass'); +const elements = document.getElementsByClassName("myClass"); // Log the elements to the console console.log(elements); // Optionally, you can iterate over the elements as well for (let i = 0; i < elements.length; i++) { - console.log(elements[i]) + console.log(elements[i]); } ``` @@ -116,8 +115,8 @@ for (let i = 0; i < elements.length; i++) {

Hello, World!

This is a paragraph.

-

Another paragraph inside a div.

-

Second paragraph inside a div.

+

Another paragraph inside a div.

+

Second paragraph inside a div.

``` @@ -127,7 +126,7 @@ const paragraphs = document.getElementsByTagName("p"); // Loop through and log the text content of each

element for (let i = 0; i < paragraphs.length; i++) { - console.log(paragraphs[i].textContent); + console.log(paragraphs[i].textContent); } ``` @@ -150,7 +149,6 @@ const paragraphInDiv = document.querySelector("div p"); - The `querySelectorAll` method in JavaScript allows you to select and retrieve a list (or NodeList) of all elements that match a specified CSS selector within the document or within a specific element. Unlike `querySelector`, which returns only the first matching element, `querySelectorAll` returns a NodeList containing all matching elements. ```js - // Select all

elements in the document const paragraphs = document.querySelectorAll("p"); @@ -162,8 +160,8 @@ const introElements = document.querySelectorAll(".intro"); // Select all

  • elements inside the