Skip to content

Commit 9704f97

Browse files
Merge branch 'main' into issues
2 parents 030e146 + 2b05461 commit 9704f97

File tree

518 files changed

+36725
-1436
lines changed

Some content is hidden

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

518 files changed

+36725
-1436
lines changed

blog/authors.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,9 @@ santhosh-siddhardha:
6464
title: Software Engineer
6565
url: "https://github.com/Santhosh-Siddhardha"
6666
image_url: https://avatars.githubusercontent.com/u/103999924?v=4
67+
68+
nayanika-mukherjee:
69+
name: Nayanika Mukherjee
70+
title: Full Stack Developer
71+
url: "https://github.com/Nayanika1402"
72+
image_url: https://avatars.githubusercontent.com/u/132455412?v=4

blog/automating-tasks-with-python.md

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
---
2+
title: 'Automating Tasks with Python: Using the OS and Subprocess Modules'
3+
sidebar_label: Automating Tasks with Python
4+
authors: [nayanika-mukherjee]
5+
tags: [automation, Python, OS module, Subprocess module, technology]
6+
date: 2024-07-13
7+
hide_table_of_contents: true
8+
---
9+
10+
## Introduction
11+
12+
Automation is a powerful way to boost productivity and efficiency by minimizing manual intervention in repetitive tasks. Python, with its versatile libraries and modules, provides an excellent framework for task automation. This blog explores how to use Python's OS and Subprocess modules to automate various system-level tasks, including file and directory operations and executing system commands.
13+
14+
## What is Task Automation?
15+
16+
Task automation involves using software to perform tasks without human intervention. Python is a popular choice for automation due to its simplicity, readability, and extensive standard library. Common automation tasks include file management, data processing, and executing system commands. Automating these tasks can save time, reduce errors, and improve consistency.
17+
18+
## Using the OS Module for File and Directory Operations
19+
20+
The OS module in Python provides a way to interact with the operating system. It allows you to perform tasks such as creating, deleting, and modifying files and directories. Here are some key functions of the OS module:
21+
22+
### File Operations
23+
24+
- **Creating a File**: `os.open()` and `os.close()`
25+
- **Reading from a File**: `os.read()`
26+
- **Writing to a File**: `os.write()`
27+
- **Deleting a File**: `os.remove()`
28+
29+
### Directory Operations
30+
31+
- **Creating a Directory**: `os.mkdir()`
32+
- **Listing Directory Contents**: `os.listdir()`
33+
- **Changing the Current Directory**: `os.chdir()`
34+
- **Removing a Directory**: `os.rmdir()`
35+
36+
### Example: Creating and Listing Directories
37+
38+
```python
39+
import os
40+
41+
# Create a new directory
42+
os.mkdir('new_directory')
43+
44+
# Change the current directory
45+
os.chdir('new_directory')
46+
47+
# List contents of the current directory
48+
print(os.listdir('.'))
49+
```
50+
51+
## Running System Commands with the Subprocess Module
52+
53+
The Subprocess module allows you to spawn new processes, connect to their input/output/error pipes, and obtain their return codes. This is particularly useful for running system commands and scripts from within a Python program.
54+
55+
### Key Functions in the Subprocess Module
56+
57+
- **subprocess.run()**: Run a command and wait for it to complete.
58+
- **subprocess.Popen()**: Execute a child program in a new process.
59+
60+
### Example: Running a Simple Command
61+
62+
```python
63+
import subprocess
64+
65+
# Run a simple system command
66+
result = subprocess.run(['echo', 'Hello, World!'], capture_output=True, text=True)
67+
print(result.stdout)
68+
```
69+
70+
### Example: Executing a Script
71+
72+
```python
73+
import subprocess
74+
75+
# Execute a Python script
76+
result = subprocess.run(['python', 'script.py'], capture_output=True, text=True)
77+
print(result.stdout)
78+
```
79+
80+
## Combining OS and Subprocess Modules for Complex Tasks
81+
82+
You can combine the functionalities of the OS and Subprocess modules to automate more complex workflows. For example, you might use the OS module to navigate the file system and the Subprocess module to execute a series of commands or scripts based on the files and directories found.
83+
84+
### Example: Automating a Backup Process
85+
86+
```python
87+
import os
88+
import subprocess
89+
import shutil
90+
91+
# Create a backup directory
92+
backup_dir = 'backup'
93+
if not os.path.exists(backup_dir):
94+
os.mkdir(backup_dir)
95+
96+
# Copy files to the backup directory
97+
for file_name in os.listdir('.'):
98+
if os.path.isfile(file_name):
99+
shutil.copy(file_name, backup_dir)
100+
101+
# Compress the backup directory using a system command
102+
subprocess.run(['zip', '-r', 'backup.zip', backup_dir])
103+
```
104+
105+
## Conclusion
106+
107+
Automating tasks with Python using the OS and Subprocess modules can significantly enhance productivity by reducing the need for manual intervention in repetitive tasks. Whether you're managing files and directories or running system commands, these modules provide powerful tools for developing efficient automation scripts. By leveraging Python's capabilities, you can streamline workflows, improve accuracy, and free up time for more critical tasks.
108+
109+
With the foundational knowledge provided in this blog, you're well-equipped to start exploring and implementing your own task automation solutions using Python.
110+
111+
## Additional Resources
112+
113+
To further deepen your understanding of Python's automation capabilities, consider exploring the following resources:
114+
115+
- [Python's OS Module Documentation](https://docs.python.org/3/library/os.html)
116+
- [Python's Subprocess Module Documentation](https://docs.python.org/3/library/subprocess.html)
117+
- [Automate the Boring Stuff with Python](https://automatetheboringstuff.com/)
118+
119+
By delving into these materials, you'll gain more insights and practical skills to enhance your automation projects.

blog/Introduction to Cryptography and Cyber security.md renamed to blog/introduction-to-cryptography-and-cyber-security.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: 'Cryptography and Its Use in Cyber Security'
2+
title: "Cryptography and Its Use in Cyber Security"
33
sidebar_label: Cryptography and Cyber Security
44
authors: [pujan-sarkar]
55
tags: [cryptography, cyber security, encryption, technology]
@@ -81,4 +81,3 @@ Zero-knowledge proofs enable one party to prove to another that a statement is t
8181
## Conclusion
8282

8383
Cryptography is a cornerstone of cyber security, providing the means to protect data and maintain privacy in an increasingly interconnected world. As technology advances and new threats emerge, the field of cryptography will continue to evolve, offering innovative solutions to ensure the security and integrity of our digital lives. By understanding and implementing cryptographic techniques, individuals and organizations can safeguard their information and build a secure future.
84-

blog/introduction-to-web-assembly.md

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
---
2+
title: 'Introduction to WebAssembly: Enhancing Web Performance'
3+
sidebar_label: WebAssembly and Web Performance
4+
authors: [nayanika-mukherjee]
5+
tags: [webassembly, wasm, web performance, technology]
6+
date: 2024-07-21
7+
hide_table_of_contents: true
8+
---
9+
10+
## Introduction
11+
12+
WebAssembly (Wasm) is a binary instruction format that provides near-native performance for web applications. Designed as a portable compilation target for high-level languages like C, C++, and Rust, WebAssembly enables efficient execution of code on modern web browsers. This documentation introduces WebAssembly, its benefits, and how to get started with Wasm development.
13+
14+
## What is WebAssembly (Wasm)?
15+
16+
WebAssembly is a low-level, assembly-like language with a compact binary format that runs with near-native performance. It provides a new way to run code written in multiple languages on the web at near-native speed, allowing for powerful web applications.
17+
18+
## Why Use WebAssembly?
19+
20+
WebAssembly offers several advantages:
21+
22+
- **Performance:** Wasm code executes at near-native speeds, making it ideal for performance-critical applications like games, simulations, and complex calculations.
23+
- **Portability:** Code compiled to Wasm can run on any modern web browser, providing a consistent execution environment across different platforms.
24+
- **Interoperability:** Wasm integrates seamlessly with JavaScript, enabling the use of existing web technologies and frameworks.
25+
- **Security:** Wasm operates in a safe, sandboxed execution environment, reducing the risk of security vulnerabilities.
26+
27+
## How WebAssembly Works
28+
29+
WebAssembly works by compiling high-level code into a binary format that can be executed by the browser's virtual machine. The process involves several steps:
30+
31+
1. **Source Code:** Write your code in a high-level language like C, C++, or Rust.
32+
2. **Compilation:** Use a compiler to convert the source code into WebAssembly binary format (`.wasm` file).
33+
3. **Execution:** The browser's virtual machine executes the Wasm binary, providing near-native performance.
34+
35+
## Setting Up Your Environment
36+
37+
To start developing with WebAssembly, you'll need to set up your development environment. This includes installing the necessary tools and compilers.
38+
39+
### Setting Up a Development Environment
40+
41+
1. **Install Node.js:** Node.js is required for various Wasm development tools.
42+
2. **Install a Compiler:** Depending on your source language, install a suitable compiler. For C/C++, install Emscripten. For Rust, install the Rust toolchain.
43+
44+
### Compiling to WebAssembly
45+
46+
To compile your code to WebAssembly, follow these steps:
47+
48+
1. **Write Your Code:** Write your application in C, C++, Rust, or another supported language.
49+
2. **Compile:** Use your compiler to generate the Wasm binary. For example, with Emscripten, use the following command:
50+
```bash
51+
emcc your_code.c -o your_code.wasm
52+
```
53+
For Rust:
54+
```
55+
rustc --target wasm32-unknown-unknown -O your_code.rs
56+
```
57+
## Interfacing with JavaScript
58+
59+
WebAssembly can interact with JavaScript, enabling you to call Wasm functions from JavaScript and vice versa. Use the JavaScript WebAssembly API to load and instantiate Wasm modules.
60+
61+
## Debugging WebAssembly Code
62+
63+
Debugging Wasm code involves using browser developer tools and other utilities:
64+
65+
- Browser DevTools: Modern browsers provide debugging support for WebAssembly, including breakpoints, step execution, and variable inspection.
66+
- Source Maps: Generate source maps to map Wasm code back to the original source code for easier debugging.
67+
- Optimizing WebAssembly Performance
68+
69+
To optimize Wasm performance:
70+
71+
- Optimize Code: Write efficient, performance-oriented code in the source language.
72+
- Compiler Flags: Use compiler optimization flags to improve the performance of the generated Wasm binary.
73+
- Profiling: Use profiling tools to identify and address performance bottlenecks.
74+
75+
## Case Studies and Real-World Examples
76+
77+
Explore case studies and real-world examples of WebAssembly in action:
78+
79+
- Gaming: High-performance games running in the browser.
80+
- Data Visualization: Complex data visualizations with real-time interactivity.
81+
- Scientific Simulations: Web-based simulations for scientific research and education.
82+
83+
## Conclusion
84+
85+
WebAssembly is a powerful technology that enhances web performance and expands the capabilities of web applications. By leveraging Wasm, developers can build high-performance, portable, and secure applications that run seamlessly across different browsers and platforms. This documentation provides a comprehensive guide to getting started with WebAssembly, covering essential concepts, tools, and best practices.
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
---
2+
id: lesson-1
3+
title: "Advanced Forms in Angular"
4+
sidebar_label: Advanced Forms
5+
sidebar_position: 1
6+
description: "Advanced Forms in Angular"
7+
tags: [courses,Advanced-level,Form,Introduction]
8+
---
9+
10+
Angular's reactive forms provide powerful tools for creating complex form structures and handling user input efficiently. Here are some advanced concepts you can leverage in Angular forms.
11+
12+
#### Dynamic Forms
13+
14+
Dynamic forms allow you to create forms whose structure can change at runtime based on user actions or external data.
15+
16+
1. **Creating Dynamic Forms**:
17+
```typescript
18+
import { FormBuilder, FormGroup, FormArray } from '@angular/forms';
19+
import { Component } from '@angular/core';
20+
21+
@Component({
22+
selector: 'app-dynamic-form',
23+
templateUrl: './dynamic-form.component.html',
24+
})
25+
export class DynamicFormComponent {
26+
form: FormGroup;
27+
28+
constructor(private fb: FormBuilder) {
29+
this.form = this.fb.group({
30+
items: this.fb.array([])
31+
});
32+
}
33+
34+
get items(): FormArray {
35+
return this.form.get('items') as FormArray;
36+
}
37+
38+
addItem() {
39+
const item = this.fb.control('');
40+
this.items.push(item);
41+
}
42+
43+
removeItem(index: number) {
44+
this.items.removeAt(index);
45+
}
46+
}
47+
```
48+
49+
2. **Dynamic Form Template**:
50+
```html
51+
<form [formGroup]="form">
52+
<div formArrayName="items">
53+
<div *ngFor="let item of items.controls; let i = index">
54+
<input [formControlName]="i" placeholder="Item"/>
55+
<button (click)="removeItem(i)">Remove</button>
56+
</div>
57+
</div>
58+
<button (click)="addItem()">Add Item</button>
59+
</form>
60+
```
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
---
2+
id: lesson-2
3+
title: "Custom Form Controls"
4+
sidebar_label: Form Controls
5+
sidebar_position: 2
6+
description: "Custom Form Controls"
7+
tags: [courses,Advanced-level,Form Controls,Introduction]
8+
---
9+
10+
11+
12+
Creating custom form controls allows you to encapsulate complex form logic and UI in reusable components.
13+
14+
1. **Creating a Custom Control**:
15+
```typescript
16+
import { Component, forwardRef } from '@angular/core';
17+
import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';
18+
19+
@Component({
20+
selector: 'app-custom-input',
21+
template: `<input [(ngModel)]="value" (ngModelChange)="onChange($event)" />`,
22+
providers: [
23+
{
24+
provide: NG_VALUE_ACCESSOR,
25+
useExisting: forwardRef(() => CustomInputComponent),
26+
multi: true
27+
}
28+
]
29+
})
30+
export class CustomInputComponent implements ControlValueAccessor {
31+
value: string;
32+
33+
onChange = (value: string) => {};
34+
onTouched = () => {};
35+
36+
writeValue(value: string): void {
37+
this.value = value;
38+
}
39+
40+
registerOnChange(fn: any): void {
41+
this.onChange = fn;
42+
}
43+
44+
registerOnTouched(fn: any): void {
45+
this.onTouched = fn;
46+
}
47+
}
48+
```
49+
50+
2. **Using Custom Control in a Form**:
51+
```html
52+
<form [formGroup]="form">
53+
<app-custom-input formControlName="customField"></app-custom-input>
54+
</form>
55+
```
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
---
2+
id: lesson-3
3+
title: "Form Arrays"
4+
sidebar_label: Async
5+
sidebar_position: 3
6+
description: "Form Arrays"
7+
tags: [courses,Advanced-level,Form Arrays,Introduction]
8+
---
9+
10+
11+
Form arrays are used to manage an array of form controls or groups, allowing you to build complex forms.
12+
13+
1. **Creating a Form Array**:
14+
```typescript
15+
import { FormArray, FormGroup, FormBuilder } from '@angular/forms';
16+
17+
this.form = this.fb.group({
18+
users: this.fb.array([
19+
this.fb.group({ name: '', age: '' }),
20+
this.fb.group({ name: '', age: '' })
21+
])
22+
});
23+
```
24+
25+
2. **Template for Form Array**:
26+
```html
27+
<form [formGroup]="form">
28+
<div formArrayName="users">
29+
<div *ngFor="let user of form.get('users').controls; let i = index">
30+
<div [formGroupName]="i">
31+
<input formControlName="name" placeholder="Name"/>
32+
<input formControlName="age" placeholder="Age"/>
33+
</div>
34+
</div>
35+
</div>
36+
</form>
37+
```

0 commit comments

Comments
 (0)