Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Snippets c++ #103

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
saminjay merged 21 commits into quicksnip-dev:main from majvax:snippets-c++
Jan 7, 2025
Merged

Snippets c++ #103

saminjay merged 21 commits into quicksnip-dev:main from majvax:snippets-c++
Jan 7, 2025

Conversation

Copy link
Collaborator

@majvax majvax commented Jan 1, 2025
edited
Loading

Description

Added Snippets for c++

-> Array manipulation

  • transform that apply a function to each item of a vector
  • filter, to filter a vector based on a predicate

-> File handling

  • find_files and find_files_recursive to find files based on a predicate (example included)
  • list_directories (self explanatory)

-> String manipulation

  • is_palindrome (self explanatory) related to Add cpp basics #83
  • transform can be overloaded with the one for the vector, does basically the same.
  • filter same a transform

Type of Change

  • ✨ New snippet
  • 🛠 Improvement to an existing snippet
  • 🐞 Bug fix
  • 📖 Documentation update
  • 🔧 Other (please describe):

Checklist

  • I have tested my code and verified it works as expected.
  • My code follows the style and contribution guidelines of this project.
  • Comments are added where necessary for clarity.
  • Documentation has been updated (if applicable).
  • There are no new warnings or errors from my changes.

Copy link

netlify bot commented Jan 1, 2025
edited
Loading

Deploy Preview for quicksnip ready!

Name Link
🔨 Latest commit c0d6f04
🔍 Latest deploy log https://app.netlify.com/sites/quicksnip/deploys/6777b09479f1ff0008d27b19
😎 Deploy Preview https://deploy-preview-103--quicksnip.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link
Collaborator

@saminjay saminjay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not all std library implementations have some of the functions you used, e.g. from_sys in chrono.
Mention which library you used or some build instruction in comments or description

Copy link
Collaborator Author

majvax commented Jan 2, 2025
edited
Loading

@saminjay done

Copy link
Collaborator

@Mathys-Gasnier Mathys-Gasnier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a big fan of the double filter and transform, one for vectors and the other for strings...

Copy link
Collaborator Author

majvax commented Jan 2, 2025

Not a big fan of the double filter and transform, one for vectors and the other for strings...

They can be overloaded.

I could abstract more the filter one to englobe both the vector and the string using another typename and std::decay_t

for the transform function however I need to make a choice between returning the same container as the one passed as parameters or the different containers but the same type
(I don't know if i'm clear enough)

both having the same name shouldn't be a problem since they belong to different categories (respectively array manipulation and string manipulation)

I can also simply change the name to filter_string and/or filter_vector and same with transform

Copy link
Collaborator Author

majvax commented Jan 2, 2025

added tag which standard is used
I checked and std23 is needed where ranges::to is used, see this link for reference
and for the example where clock::from_sys is used, see this link for reference

It should now be ready to be merged excepting any new questions

Copy link
Collaborator

@Mathys-Gasnier Mathys-Gasnier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As we are updating guidelines, some of your snippets will need quick changes to their formatting:

  • Capitalizing and following all Usage with : (So it looks like Usage:)
  • Having a Usage section for each snippet

// Usage:
std::vector<int> vec = {1, 2, 3, 4, 5};
std::vector<int> transformed = transform(vec, [](int i){ return i * 2; });
// transformed containes 2, 4, 6, 8, 10
Copy link
Collaborator

@Mathys-Gasnier Mathys-Gasnier Jan 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo

Copy link
Collaborator Author

majvax commented Jan 4, 2025

@saminjay could you review the code again please ?

@majvax majvax dismissed saminjay’s stale review January 4, 2025 18:34

not relevant anymore

@majvax majvax added mergeable Reviewed and ready to be merged Snippets labels Jan 4, 2025
@saminjay saminjay merged commit 3dee709 into quicksnip-dev:main Jan 7, 2025
saminjay pushed a commit to saminjay/quicksnip that referenced this pull request Jan 7, 2025
* [C++] added snippet
* [C++] added 3 snippets for string.
* Added missing chrono header
* fixed tags
* fixed exemple needing std=c++20
* Fixed Usage to accommodate to new guidelines
* Fixed all tags + type
* Revert "Fixed all tags + type"
This reverts commit aebefde.
* Fixed type and all tags
* fixed gh check failing
* Update consolidated snippets
* Update consolidated snippets
* Update consolidated snippets
* Revert "Merge remote-tracking branch 'origin/main' into snippets-c++"
This reverts commit 4708bd9, reversing
changes made to a959e95.
* Update consolidated snippets
---------
Co-authored-by: GitHub Action <action@github.com>
ACR1209 pushed a commit to ACR1209/quicksnip that referenced this pull request Jan 10, 2025
* [C++] added snippet
* [C++] added 3 snippets for string.
* Added missing chrono header
* fixed tags
* fixed exemple needing std=c++20
* Fixed Usage to accommodate to new guidelines
* Fixed all tags + type
* Revert "Fixed all tags + type"
This reverts commit aebefde.
* Fixed type and all tags
* fixed gh check failing
* Update consolidated snippets
* Update consolidated snippets
* Update consolidated snippets
* Revert "Merge remote-tracking branch 'origin/main' into snippets-c++"
This reverts commit 4708bd9, reversing
changes made to a959e95.
* Update consolidated snippets
---------
Co-authored-by: GitHub Action <action@github.com>
ACR1209 pushed a commit to ACR1209/quicksnip that referenced this pull request Jan 10, 2025
Fix cuz description was messed up
Consolidate for the Prime Number Description
Updated combinations.md
Removing end of line prettier config as it's not needed anymore
snippets: hex to rgb color
snippets: rgb to hsl color
snippets: hsl to rgb color
refactor: optimized rgb to hsl color
fix: hex to rgb color
Added Sorting and Search Algorithms to C (quicksnip-dev#199)
Update consolidated snippets
Updating to use vite HMR to consolidate snippets
Changing status check in plugin
Snippets c++ (quicksnip-dev#103)
* [C++] added snippet
* [C++] added 3 snippets for string.
* Added missing chrono header
* fixed tags
* fixed exemple needing std=c++20
* Fixed Usage to accommodate to new guidelines
* Fixed all tags + type
* Revert "Fixed all tags + type"
This reverts commit aebefde.
* Fixed type and all tags
* fixed gh check failing
* Update consolidated snippets
* Update consolidated snippets
* Update consolidated snippets
* Revert "Merge remote-tracking branch 'origin/main' into snippets-c++"
This reverts commit 4708bd9, reversing
changes made to a959e95.
* Update consolidated snippets
---------
Co-authored-by: GitHub Action <action@github.com>
java date-time formatting snippets
added duration formatting
removed language from tags
enforced formatting requirements
Renamed and improved python truncate snippet
Renamed from `truncate-string.py` to `truncate.py`
Replaced "..." with ellipses("...") to only use one character
Implemented toggle for the `suffix` "..." on string with default of `True`
Update reverse-string.md
Added type hints
Renamed `remove-specific-characters.md` to `remove-characters.md`
Improved accuracy of Description for `convert-string-to-ascii` for better functional representation
Renamed `convert-string-to-ascii.md` to `convert-string-to-unicode.md`
Replaced ASCII with Unicode
Kept `ascii` tag as it is a subset of unicode and to minimize search errors
Fixed issue quicksnip-dev#192
Update CONTRIBUTING.md
Added a `not` on line 68 in "Does that snippet have a real, and practical use case ?" to prevent useless snippets from being acceptable and useful snippets from being denied.
Rectified loss of attribution
recovered old attribution in the python snippet`truncate` to axorax and added the contributors tag.
truncate.md reconformed to PEP 8
removed Tab
Update truncate.md
Replaced "..." with "..."
Updated Description to match
Update reverse-string.md
followed change request
Miner miner mods refactor 1 (quicksnip-dev#2)
2nd integration
feat: update snippet button and modal
increased the size of the snippet modal, added a bit more responsitivity too
removed the gray filter on the snippet button
feat: add minimum width to modal
Added bash as a new language, also added a category and a snippet (quicksnip-dev#204)
* Added a bash as a new language, also added a category and a snippet
* Fixed the snippet to make it more like a snippet
* Deleted public/consolidated/ and put code into a function
* Deleted public/consolidated/
Update calculate-compound-interest.md
Create Calculate-factorial.md
Rename Calculate-factorial.md to calculate-factorial.md
Update calculate-factorial.md
Delete snippets/python/math-and-numbers/calculate-factorial.md
refacto(css/pulse-animation): add 'alternate' and edit keyframes
Added Rust category and a snippet
[Snippet] [Fix] Added a bash snippet (quicksnip-dev#219)
* removed bash icon
* fix comments of a script
* added kill_prev snippet
* followed guidelines
Remove language tag in guidelines
math - remap function
math - remap function to most languages
remap to linearMapping, args renamed
fix all mistakes,typos
added array manipulation snippets
removed unnecessary snippets
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Reviewers

@saminjay saminjay saminjay approved these changes

@Mathys-Gasnier Mathys-Gasnier Mathys-Gasnier approved these changes

Assignees
No one assigned
Labels
mergeable Reviewed and ready to be merged Snippets
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /