From a2fab03e6e27c9ed17f5917ab15bd6f34d8e1c75 Mon Sep 17 00:00:00 2001 From: majvax Date: Mon, 30 Dec 2024 18:15:42 +0100 Subject: [PATCH 1/3] Added vector manipulation in C++ --- public/data/cpp.json | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/public/data/cpp.json b/public/data/cpp.json index 48172189..257a6fbe 100644 --- a/public/data/cpp.json +++ b/public/data/cpp.json @@ -41,5 +41,45 @@ "author": "saminjay" } ] + }, + { + "categoryName": "Array Manipulation", + "snippets": [ + { + "title": "Transform Vector", + "description": "Transforms a vector using a function", + "code": [ + "#include ", + "#include ", + "", + "template ", + "auto transform(const std::vector& vec, F&& transformer) {", + " using U = std::invoke_result_t;", + " return vec", + " | std::views::transform(std::forward(transformer))", + " | std::ranges::to>();", + "}" + ], + "tags": ["cpp", "array", "transform", "utility"], + "author": "majvax" + }, + { + "title": "Filter Vector", + "description": "Filters a vector using a predicate function", + "code": [ + "#include ", + "#include ", + "", + "template ", + "auto filter(const std::vector& vec, P&& predicate) {", + " return vec", + " | std::views::filter(std::forward

(predicate))", + " | std::ranges::to>();", + "}" + ], + "tags": ["cpp", "array", "filter", "utility"], + "author": "majvax" + } + ] } ] From 773059df3ab0478ba4d25d738f1fe442967ef117 Mon Sep 17 00:00:00 2001 From: majvax Date: Tue, 31 Dec 2024 12:09:19 +0100 Subject: [PATCH 2/3] [Find File/Python] Fixed perf issue --- public/data/python.json | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/public/data/python.json b/public/data/python.json index b4c9c2b0..9a3e92bc 100644 --- a/public/data/python.json +++ b/public/data/python.json @@ -131,17 +131,13 @@ "import os", "", "def find_files(directory, file_type):", - " file_type = file_type.lower() # Convert file_type to lowercase", - " found_files = []", + " file_type = file_type.lower()", + " found_files = []", "", - " for root, _, files in os.walk(directory):", - " for file in files:", - " file_ext = os.path.splitext(file)[1].lower()", - " if file_ext == file_type:", - " full_path = os.path.join(root, file)", - " found_files.append(full_path)", - "", - " return found_files", + " for entry in os.scandir(directory):", + " if entry.is_file() and entry.name.lower().endswith(file_type):", + " found_files.append(entry.name)", + " return found_files", "", "# Example Usage:", "pdf_files = find_files('/path/to/your/directory', '.pdf')", From 719605ff8afb97fcf27a710fa349d7ec050237a7 Mon Sep 17 00:00:00 2001 From: majvax Date: Tue, 31 Dec 2024 12:19:43 +0100 Subject: [PATCH 3/3] Revert "Added vector manipulation in C++" This reverts commit a2fab03e6e27c9ed17f5917ab15bd6f34d8e1c75. --- public/data/cpp.json | 40 ---------------------------------------- 1 file changed, 40 deletions(-) diff --git a/public/data/cpp.json b/public/data/cpp.json index 257a6fbe..48172189 100644 --- a/public/data/cpp.json +++ b/public/data/cpp.json @@ -41,45 +41,5 @@ "author": "saminjay" } ] - }, - { - "categoryName": "Array Manipulation", - "snippets": [ - { - "title": "Transform Vector", - "description": "Transforms a vector using a function", - "code": [ - "#include ", - "#include ", - "", - "template ", - "auto transform(const std::vector& vec, F&& transformer) {", - " using U = std::invoke_result_t;", - " return vec", - " | std::views::transform(std::forward(transformer))", - " | std::ranges::to>();", - "}" - ], - "tags": ["cpp", "array", "transform", "utility"], - "author": "majvax" - }, - { - "title": "Filter Vector", - "description": "Filters a vector using a predicate function", - "code": [ - "#include ", - "#include ", - "", - "template ", - "auto filter(const std::vector& vec, P&& predicate) {", - " return vec", - " | std::views::filter(std::forward

(predicate))", - " | std::ranges::to>();", - "}" - ], - "tags": ["cpp", "array", "filter", "utility"], - "author": "majvax" - } - ] } ]