Skip to content

Commit 495f787

Browse files
authored
Merge branch 'main' into sql
2 parents d328bc2 + ac0424f commit 495f787

File tree

674 files changed

+47613
-1652
lines changed

Some content is hidden

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

674 files changed

+47613
-1652
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Auto Content on Labels
2+
3+
on:
4+
issues:
5+
types: [opened]
6+
pull_request:
7+
types: [opened]
8+
9+
jobs:
10+
addContent:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Check for Labels
14+
id: check_labels
15+
run: echo "::set-output name=labels::${{ toJson(github.event.issue.labels) }}"
16+
17+
- name: Add Guidance Comment
18+
if: ${{ contains(steps.check_labels.outputs.labels, 'dsa-solution') }}
19+
uses: actions/github-script@v7
20+
with:
21+
github-token: ${{ secrets.GITHUB_TOKEN }}
22+
script: |
23+
const issueOrPR = github.context.payload.issue || github.context.payload.pull_request;
24+
const comment = `
25+
Hello there! 🌟 It looks like you've added the \`dsa-solution\` label.
26+
Please refer to our guidance on Data Structures & Algorithms solutions here: [DSA Solution Guidance](https://github.com/orgs/CodeHarborHub/discussions/3369#discussion-6940372).
27+
Thank you!
28+
`;
29+
github.issues.createComment({
30+
issue_number: issueOrPR.number,
31+
owner: github.context.repo.owner,
32+
repo: github.context.repo.repo,
33+
body: comment
34+
});

.github/workflows/auto_assign.yml

Lines changed: 0 additions & 62 deletions
This file was deleted.

.github/workflows/lighthouse-report.yml

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,19 @@ jobs:
4040
with:
4141
urls: |
4242
http://localhost:3000
43-
http://localhost:3000/docs/javascript/basic-javascript
43+
http://localhost:3000/docs
4444
http://localhost:3000/docs/category/javascript
45+
http://localhost:3000/courses
46+
http://localhost:3000/courses/category/reactjs
47+
http://localhost:3000/dsa-problems
48+
http://localhost:3000/dsa-problems/category/leetcode-problems
49+
http://localhost:3000/dsa-solutions
50+
http://localhost:3000/dsa-solutions/category/leetcode-solutions
4551
http://localhost:3000/blog
46-
http://localhost:3000/blog/getting-started-with-mern
47-
http://localhost:3000/blog/tags/mern-stack
48-
http://localhost:3000/blog/tags
52+
http://localhost:3000/showcase
53+
http://localhost:3000/community
54+
http://localhost:3000/docs/tags
55+
http://localhost:3000/product
4956
configPath: ./.github/workflows/lighthouserc.json
5057
uploadArtifacts: true
5158
temporaryPublicStorage: true
@@ -69,4 +76,4 @@ jobs:
6976
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
7077
number: ${{ github.event.pull_request.number }}
7178
header: lighthouse
72-
message: ${{ steps.format_lighthouse_score.outputs.comment }}
79+
message: ${{ steps.format_lighthouse_score.outputs.comment }}
Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,22 @@
11
// @ts-check
22

3-
/** @typedef {Record<'performance' | 'accessibility' | 'best-practices' | 'seo', number>} LighthouseSummary */
3+
/**
4+
* @typedef {Record<'performance' | 'accessibility' | 'best-practices' | 'seo',
5+
* number>} LighthouseSummary
6+
*/
47

58
/** @type {Record<keyof LighthouseSummary, string>} */
69
const summaryKeys = {
7-
performance: 'Performance',
8-
accessibility: 'Accessibility',
9-
'best-practices': 'Best Practices',
10-
seo: 'SEO',
10+
performance: "Performance",
11+
accessibility: "Accessibility",
12+
"best-practices": "Best Practices",
13+
seo: "SEO",
1114
};
1215

1316
/** @param {number} rawScore */
1417
const scoreEntry = (rawScore) => {
1518
const score = Math.round(rawScore * 100);
16-
// eslint-disable-next-line no-nested-ternary
17-
const scoreIcon = score >= 90 ? '🟢' : score >= 50 ? '🟠' : '🔴';
19+
const scoreIcon = score >= 90 ? "🟢" : score >= 50 ? "🟡" : "🔴";
1820
return `${scoreIcon} ${score}`;
1921
};
2022

@@ -26,7 +28,7 @@ function createURL(url) {
2628
try {
2729
return new URL(url);
2830
} catch (e) {
29-
throw new Error(`Can't create URL for string=${url}`, {cause: e});
31+
throw new Error(`Can't create URL for string=${url}`, { cause: e });
3032
}
3133
}
3234

@@ -36,19 +38,19 @@ function createURL(url) {
3638
* @param {LighthouseSummary} param0.summary
3739
* @param {string} param0.reportUrl
3840
*/
39-
const createMarkdownTableRow = ({url, summary, reportUrl}) =>
41+
const createMarkdownTableRow = ({ url, summary, reportUrl }) =>
4042
[
4143
`| [${createURL(url).pathname}](${url})`,
4244
.../** @type {(keyof LighthouseSummary)[]} */ (
4345
Object.keys(summaryKeys)
4446
).map((k) => scoreEntry(summary[k])),
45-
`[Report](${reportUrl}) |`,
46-
].join(' | ');
47+
`[📄](${reportUrl}) |`,
48+
].join(" | ");
4749

4850
const createMarkdownTableHeader = () => [
49-
['| URL', ...Object.values(summaryKeys), 'Report |'].join(' | '),
50-
['|---', ...Array(Object.keys(summaryKeys).length).fill('---'), '---|'].join(
51-
'|',
51+
["| URL 🌐", ...Object.values(summaryKeys), "📊 |"].join(" | "),
52+
["|---", ...Array(Object.keys(summaryKeys).length).fill("---"), "---|"].join(
53+
"|",
5254
),
5355
];
5456

@@ -57,7 +59,7 @@ const createMarkdownTableHeader = () => [
5759
* @param {Record<string, string>} param0.links
5860
* @param {{url: string, summary: LighthouseSummary}[]} param0.results
5961
*/
60-
const createLighthouseReport = ({results, links}) => {
62+
const createLighthouseReport = ({ results, links }) => {
6163
const tableHeader = createMarkdownTableHeader();
6264
const tableBody = results.map((result) => {
6365
const testUrl = /** @type {string} */ (
@@ -72,13 +74,15 @@ const createLighthouseReport = ({results, links}) => {
7274
});
7375
});
7476
const comment = [
75-
'### ⚡️ Lighthouse report for the deploy preview of this PR',
76-
'',
77+
"### ⚡️ Lighthouse Report for the Deploy Preview of this PR 🚀",
78+
"",
79+
`🔗 Site: [CodeHarborHub](https://github.com/CodeHarborHub/codeharborhub.github.io) | [Live Site](https://codeharborhub.github.io/)`,
80+
"",
7781
...tableHeader,
7882
...tableBody,
79-
'',
83+
"",
8084
];
81-
return comment.join('\n');
85+
return comment.join("\n");
8286
};
8387

8488
export default createLighthouseReport;

assets/Aho_Corasick_algo.png

11.2 KB
Loading

assets/Burrows_Wheeler_Transform.png

30 KB
Loading

assets/Manachers_Algorithm.png

76.6 KB
Loading

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-

0 commit comments

Comments
 (0)