-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #25 from milkiyd/order-resources-by-name
Sort resources by name
- Loading branch information
Showing
5 changed files
with
218 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,24 @@ | ||
#### Courses articles blogs | ||
|
||
- [Data Structure Visualizations - University of San Francisco](https://www.cs.usfca.edu/~galles/visualization/Algorithms.html) | ||
- [Data Structure - Geeks for Geeks](https://www.geeksforgeeks.org/data-structures/) | ||
- [Collection of Data Structure and Algorithms learning material - Google](https://techdevguide.withgoogle.com/paths/data-structures-and-algorithms/) | ||
- [Data Structure and Algorithms - CS50 Havard University](https://cs50.harvard.edu/law/2019/weeks/3/) | ||
- [Data Structure and Algorithms - Freecodecamp](https://www.freecodecamp.org/news/learn-data-structures-and-algorithms/) | ||
- [Data Structure and Algorithms - Tutorialspoint](https://www.tutorialspoint.com/data_structures_algorithms/index.htm) | ||
|
||
#### Videos tutorials | ||
|
||
- [Algorithms and Data Structures Tutorial - Full Course for Beginners - Freecodecamp](https://www.youtube.com/watch?v=8hly31xKli0) _5hours_ | ||
- [Complete Data Structures and Algorithms - Language: C - **Jenny's Lectures CS IT**](https://www.youtube.com/watch?v=AT14lCXuMKI&list=PLdo5W4Nhv31bbKJzrsKfMpo_grxuLl8LU) | ||
- [Programming & Data Structures - Language C - **Neso Academy**](https://www.youtube.com/watch?v=xLetJpcjHS0&list=PLBlnK6fEyqRj9lld8sWIUNwlKfdUoPd1Y) | ||
- [Data Structures - Full Course Using C and C++](https://www.youtube.com/watch?v=B31LgI4Y4DQ&t=8488s) _9hours+_ | ||
|
||
#### Where to have the assessment ? | ||
|
||
- [LeetCode](https://leetcode.com/) | ||
- [CoderByte](https://coderbyte.com/) | ||
- [HankerRank](https://www.hackerrank.com/dashboard) | ||
- [Project Euler](https://projecteuler.net/) | ||
- [Coding game](https://www.codingame.com/) | ||
- [CodeWars](https://www.codewars.com/) | ||
#### Courses articles blogs | ||
|
||
- [Collection of Data Structure and Algorithms learning material - Google](https://techdevguide.withgoogle.com/paths/data-structures-and-algorithms/) | ||
- [Data Structure - Geeks for Geeks](https://www.geeksforgeeks.org/data-structures/) | ||
- [Data Structure and Algorithms - CS50 Havard University](https://cs50.harvard.edu/law/2019/weeks/3/) | ||
- [Data Structure and Algorithms - Freecodecamp](https://www.freecodecamp.org/news/learn-data-structures-and-algorithms/) | ||
- [Data Structure and Algorithms - Tutorialspoint](https://www.tutorialspoint.com/data_structures_algorithms/index.htm) | ||
- [Data Structure Visualizations - University of San Francisco](https://www.cs.usfca.edu/~galles/visualization/Algorithms.html) | ||
|
||
#### Videos tutorials | ||
|
||
- [Algorithms and Data Structures Tutorial - Full Course for Beginners - Freecodecamp](https://www.youtube.com/watch?v=8hly31xKli0) | ||
- [Complete Data Structures and Algorithms - Language: C - **Jenny's Lectures CS IT**](https://www.youtube.com/watch?v=AT14lCXuMKI&list=PLdo5W4Nhv31bbKJzrsKfMpo_grxuLl8LU) | ||
- [Data Structures - Full Course Using C and C++](https://www.youtube.com/watch?v=B31LgI4Y4DQ&t=8488s) | ||
- [Programming & Data Structures - Language C - **Neso Academy**](https://www.youtube.com/watch?v=xLetJpcjHS0&list=PLBlnK6fEyqRj9lld8sWIUNwlKfdUoPd1Y) | ||
|
||
#### Where to have the assessment ? | ||
|
||
- [CoderByte](https://coderbyte.com/) | ||
- [CodeWars](https://www.codewars.com/) | ||
- [Coding game](https://www.codingame.com/) | ||
- [HankerRank](https://www.hackerrank.com/dashboard) | ||
- [LeetCode](https://leetcode.com/) | ||
- [Project Euler](https://projecteuler.net/) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
- [Secret of printf](https://www.academia.edu/10297206/Secrets_of_printf_) | ||
- [C programming: Example of C custom printf() function](https://www.w3resource.com/c-programming-exercises/c-snippets/implementing-custom-printf-function-in-c.php#:~:text=Implementin[…]%20is%20encountered) | ||
- [Creating a Custom printf Function in C: A Step-by-Step Guide by Noran Saber](https://medium.com/@noransaber685/creating-a-custom-printf-function-in-c-a-step-by-step-guide-432fd2ecf48a) | ||
- [ALX Printf Project: The Power of printf in C Programming by Amara Crystal](https://medium.com/@marameref/alx-printf-project-the-power-of-printf-in-c-programming-a-comprehensive-guide-5087f4677234) | ||
- [Easy to read documentation of the printf function](https://www.tutorialspoint.com/c_standard_library/c_function_printf.htm) | ||
- [ALX Printf Project: The Power of printf in C Programming by Amara Crystal](https://medium.com/@marameref/alx-printf-project-the-power-of-printf-in-c-programming-a-comprehensive-guide-5087f4677234) | ||
- [C programming: Example of C custom printf() function](https://www.w3resource.com/c-programming-exercises/c-snippets/implementing-custom-printf-function-in-c.php#:~:text=Implementin[…]%20is%20encountered) | ||
- [Creating a Custom printf Function in C: A Step-by-Step Guide by Noran Saber](https://medium.com/@noransaber685/creating-a-custom-printf-function-in-c-a-step-by-step-guide-432fd2ecf48a) | ||
- [Easy to read documentation of the printf function](https://www.tutorialspoint.com/c_standard_library/c_function_printf.htm) | ||
- [Secret of printf](https://www.academia.edu/10297206/Secrets_of_printf_) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,26 @@ | ||
- [Learning the shell](https://linuxcommand.org/lc3_learning_the_shell.php) | ||
- [Implement your own shell step by step by ehoneahobed](https://blog.ehoneahobed.com/building-a-simple-shell-in-c-part-1) | ||
- [Standford University : Shell project](https://www.scs.stanford.edu/21sp-cs111/proj/proj_shell.html) | ||
- [Shell explaned by nickolasteixeira](https://nickolasteixeira.medium.com/want-to-build-a-simple-shell-heres-how-you-do-it-75890647bae8) | ||
- [What happen after pressing enter on ls command by nickolasteixeira](https://nickolasteixeira.medium.com/what-happens-when-you-type-ls-c-and-hit-enter-in-your-shell-a9c789206c55) | ||
- [What's shell part 1 by indradhanush](https://indradhanush.github.io/blog/writing-a-unix-shell-part-1/) | ||
- [What's shell part 2 by indradhanush](https://indradhanush.github.io/blog/writing-a-unix-shell-part-2/) | ||
- [Code your shell in C by santiagobedoa](https://medium.com/@santiagobedoa/coding-a-shell-using-c-1ea939f10e7e) | ||
- [Shell by Linuxhint.com](https://linuxhint.com/create-simple-shell-c/#:~:text=Building%20a%20simple%20shell%20in,and%20the%20Unix%20operating%20system.) | ||
- [Brennan's method to write a shell in C](https://brennan.io/2015/01/16/write-a-shell-in-c/) | ||
- [Shell project step by step by muirujackson](https://medium.com/@muirujackson/shell-project-step-by-step-80aa31a71df0) | ||
- [Understanding important system calls in C by @noransaber](https://medium.com/@noransaber685/understanding-important-system-calls-in-c-fork-open-read-close-chdir-getline-and-access-2836cc761b17) | ||
- [shell, the standard command language interpreter](https://manpages.org/sh) | ||
- [sh, jsh - the standard command interpreter](https://heirloom.sourceforge.net/sh/sh.1.html) | ||
- [Developing a Linux based shell](https://www.geeksforgeeks.org/developing-linux-based-shell/?ref=rp) | ||
- [Let's Build a Linux Shell [Part I]](https://hackernoon.com/lets-build-a-linux-shell-part-i-bz3n3vg1) | ||
- [Shell Program Explained](https://www.youtube.com/watch?v=ubt-UjcQUYg) | ||
- [Unix Processes in C](https://www.youtube.com/watch?v=cex9XrZCU14&list=PLfqABt5AS4FkW5mOn2Tn9ZZLLDwA3kZUY) | ||
- [System Call Guide](https://youtu.be/2DscbZAdiko?si=cSjEeO3G1skgVdOl) | ||
- [Essential System Calls and Functions](https://medium.com/@noransaber685/essential-system-calls-and-functions-in-c-programming-explained-strtok-isatty-getpid-malloc-and-30f1f923a10d) | ||
- [Detecting Memory Leaks](https://medium.com/@muirujackson/step-by-step-guide-to-detect-specific-memory-leaks-issues-with-valgrind-memcheck-b9aa45b967c5) | ||
- [PLD Session on Simple Shell By Emmanuel Lomotey](https://mega.nz/file/hxB0GSAS#0NU_eKTfWZ-YQGHxIor-CFscP3E6pXeFdzvJKLwlNns) | ||
- [PLD SESSION SHELL PT. 2 By Emmanuel Lomotey](https://mega.nz/file/sp4RXIwI#33FtT6bQpYKpGfkgBMWCGKZ1-nNzIdklNIPbwiH2mm8) | ||
- [Unix Processes in C by CodeVault](https://www.youtube.com/playlist?list=PLfqABt5AS4FkW5mOn2Tn9ZZLLDwA3kZUY) | ||
- [Unix Processes in C by CodeVault](https://www.youtube.com/playlist?list=PLfqABt5AS4FkW5mOn2Tn9ZZLLDwA3kZUY) | ||
- [Write Your Own Shell by Jess-Inspired](https://www.youtube.com/playlist?list=PLxIRFba3rzLzxxZMMbrm_-mkI7mV9G0pj) | ||
- [Brennan's method to write a shell in C](https://brennan.io/2015/01/16/write-a-shell-in-c/) | ||
- [Code your shell in C by santiagobedoa](https://medium.com/@santiagobedoa/coding-a-shell-using-c-1ea939f10e7e) | ||
- [Detecting Memory Leaks](https://medium.com/@muirujackson/step-by-step-guide-to-detect-specific-memory-leaks-issues-with-valgrind-memcheck-b9aa45b967c5) | ||
- [Developing a Linux based shell](https://www.geeksforgeeks.org/developing-linux-based-shell/?ref=rp) | ||
- [Essential System Calls and Functions](https://medium.com/@noransaber685/essential-system-calls-and-functions-in-c-programming-explained-strtok-isatty-getpid-malloc-and-30f1f923a10d) | ||
- [Implement your own shell step by step by ehoneahobed](https://blog.ehoneahobed.com/building-a-simple-shell-in-c-part-1) | ||
- [Learning the shell](https://linuxcommand.org/lc3_learning_the_shell.php) | ||
- [Let's Build a Linux Shell [Part I]](https://hackernoon.com/lets-build-a-linux-shell-part-i-bz3n3vg1) | ||
- [PLD Session on Simple Shell By Emmanuel Lomotey](https://mega.nz/file/hxB0GSAS#0NU_eKTfWZ-YQGHxIor-CFscP3E6pXeFdzvJKLwlNns) | ||
- [PLD SESSION SHELL PT. 2 By Emmanuel Lomotey](https://mega.nz/file/sp4RXIwI#33FtT6bQpYKpGfkgBMWCGKZ1-nNzIdklNIPbwiH2mm8) | ||
- [sh, jsh - the standard command interpreter](https://heirloom.sourceforge.net/sh/sh.1.html) | ||
- [Shell by Linuxhint.com](https://linuxhint.com/create-simple-shell-c/#:~:text=Building%20a%20simple%20shell%20in,and%20the%20Unix%20operating%20system.) | ||
- [Shell explaned by nickolasteixeira](https://nickolasteixeira.medium.com/want-to-build-a-simple-shell-heres-how-you-do-it-75890647bae8) | ||
- [Shell Program Explained](https://www.youtube.com/watch?v=ubt-UjcQUYg) | ||
- [Shell project step by step by muirujackson](https://medium.com/@muirujackson/shell-project-step-by-step-80aa31a71df0) | ||
- [shell, the standard command language interpreter](https://manpages.org/sh) | ||
- [Standford University : Shell project](https://www.scs.stanford.edu/21sp-cs111/proj/proj_shell.html) | ||
- [System Call Guide](https://youtu.be/2DscbZAdiko?si=cSjEeO3G1skgVdOl) | ||
- [Understanding important system calls in C by @noransaber](https://medium.com/@noransaber685/understanding-important-system-calls-in-c-fork-open-read-close-chdir-getline-and-access-2836cc761b17) | ||
- [Unix Processes in C](https://www.youtube.com/watch?v=cex9XrZCU14&list=PLfqABt5AS4FkW5mOn2Tn9ZZLLDwA3kZUY) | ||
- [Unix Processes in C by CodeVault](https://www.youtube.com/playlist?list=PLfqABt5AS4FkW5mOn2Tn9ZZLLDwA3kZUY) | ||
- [Unix Processes in C by CodeVault](https://www.youtube.com/playlist?list=PLfqABt5AS4FkW5mOn2Tn9ZZLLDwA3kZUY) | ||
- [What happen after pressing enter on ls command by nickolasteixeira](https://nickolasteixeira.medium.com/what-happens-when-you-type-ls-c-and-hit-enter-in-your-shell-a9c789206c55) | ||
- [What's shell part 1 by indradhanush](https://indradhanush.github.io/blog/writing-a-unix-shell-part-1/) | ||
- [What's shell part 2 by indradhanush](https://indradhanush.github.io/blog/writing-a-unix-shell-part-2/) | ||
- [Write Your Own Shell by Jess-Inspired](https://www.youtube.com/playlist?list=PLxIRFba3rzLzxxZMMbrm_-mkI7mV9G0pj) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
import re | ||
|
||
|
||
class MarkdownLink: | ||
"""Represents a Markdown link with text and a URL. | ||
Attributes: | ||
title (str): The title of the section in which the link appears. | ||
text (str): The text associated with the link. | ||
link (str): The URL to which the link points. | ||
""" | ||
|
||
def __init__(self, title, text, link): | ||
"""Initializes a MarkdownLink instance with the provided text and link. | ||
Args: | ||
title (str): The title of the section in which the link appears. | ||
text (str): The text associated with the link. | ||
link (str): The URL to which the link points. | ||
""" | ||
|
||
self.title = title | ||
self.text = text | ||
self.link = link | ||
|
||
def __str__(self): | ||
"""Returns a user-friendly string representation of the MarkdownLink instance. | ||
Returns: | ||
str: A formatted string in the Markdown link format, e.g., "[text](link)". | ||
""" | ||
|
||
return f"{self.title} / [{self.text}]({self.link})" | ||
|
||
def __repr__(self): | ||
""" | ||
Returns a formal string representation of the MarkdownLink instance. | ||
Returns: | ||
str: A formatted string that represents the MarkdownLink instance. | ||
""" | ||
|
||
return f"- [{self.text}]({self.link})" | ||
|
||
def __lt__(self, other): | ||
""" | ||
Compares two MarkdownLink instances based on their title and text attributes for sorting. | ||
Args: | ||
other (MarkdownLink): Another MarkdownLink instance to compare with. | ||
Returns: | ||
bool: True if this instance's text is less than the other instance's text; False otherwise. | ||
""" | ||
|
||
return (self.title == other.title and self.text.lower() < other.text.lower()) | ||
|
||
def extract_links_from_md_file(file_content): | ||
""" | ||
Extracts Markdown links from the provided file content. | ||
Args: | ||
file_content (str): The content of a Markdown file as a string. | ||
Returns: | ||
list of MarkdownLink: A list of MarkdownLink objects representing the links found in the content. | ||
""" | ||
|
||
links = [] | ||
current_title = None | ||
|
||
for line in file_content.splitlines(): | ||
title_match = re.match(r"####\s+(.*)", line) # Match titles (assumes #### title format) | ||
if title_match: | ||
current_title = title_match.group(1) | ||
else: | ||
link_match = re.search(r"- \[(.*)\]\((.*)\)", line) # Match lines like "- [text](link)" | ||
if link_match: | ||
text = link_match.group(1) | ||
link = link_match.group(2) | ||
links.append(MarkdownLink(current_title, text, link)) | ||
|
||
return links | ||
|
||
def sort_links_in_md_file(markdown_file_path): | ||
""" | ||
Sorts Markdown links in a Markdown file alphabetically by their link text. | ||
Args: | ||
markdown_file_path (str): The path to the Markdown file to be sorted. | ||
Prints: | ||
str: A success message indicating that the links in the file have been sorted. | ||
""" | ||
|
||
try: | ||
with open(markdown_file_path, "r") as f: | ||
file_content = f.read() | ||
|
||
# Extract the links from the file content and sort them | ||
links = extract_links_from_md_file(file_content) | ||
links.sort() | ||
|
||
# Create the new file content | ||
new_file_content = "" | ||
current_title = None | ||
for link in links: | ||
if link.title != current_title: | ||
if current_title is not None: | ||
new_file_content += "\n" | ||
current_title = link.title | ||
new_file_content += f"#### {current_title}\n\n" | ||
new_file_content += f"{repr(link)}\n" | ||
|
||
# Write the new file content to the file | ||
with open(markdown_file_path, "w") as f: | ||
f.write(new_file_content) | ||
|
||
print(f"Links in {markdown_file_path} sorted successfully") | ||
|
||
# Handle errors | ||
except FileNotFoundError: | ||
print(f"File {markdown_file_path} not found") | ||
|
||
except PermissionError: | ||
print(f"Permission denied to open {markdown_file_path}") | ||
|
||
except Exception as e: | ||
print(f"Error: {e}") | ||
|
||
if __name__ == "__main__": | ||
RESOURCE_FILE_PATHS = [ | ||
"printf/resources.md", | ||
"simple-shell/learning-material.md", | ||
"dsa/resources/resources.md", | ||
] | ||
|
||
for resource_file_path in RESOURCE_FILE_PATHS: | ||
sort_links_in_md_file(resource_file_path) |