Skip to content
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

[Snippet] SASS function to convert px to rem #178

Merged
merged 13 commits into from
Jan 5, 2025
1 change: 1 addition & 0 deletions public/consolidated/cpp.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
]
},
{
"categoryName": "Debuging",
"name": "Debugging",
"snippets": [
{
Expand Down
13 changes: 13 additions & 0 deletions public/consolidated/scss.json
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,19 @@
"contributors": [],
"code": "@mixin line-clamp($number) {\n display: -webkit-box;\n -webkit-box-orient: vertical;\n -webkit-line-clamp: $number;\n overflow: hidden;\n}\n"
},
{
"title": "PX to REM Helper",
"description": "This function will convert px values to rem values.",
"author": "gihanrangana",
"tags": [
"function",
"pixel",
"rem",
"px-to-rem"
],
"contributors": [],
"code": "@function px-to-rem($px, $base: 16px) {\n @return ($px / $base) * 1rem;\n}\n\n// Usage:\ndiv {\n font-size: px-to-rem(12px); // Output: 0.75rem\n padding: px-to-rem(16px); // Output: 1rem\n margin: px-to-rem(32px) // Output 2rem\n}\n"
},
{
"title": "Text Gradient",
"description": "Adds a gradient color effect to text.",
Expand Down
29 changes: 29 additions & 0 deletions snippets/cpp/debuging/vector-print.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
title: Vector Print
description: Overloads the << operator to print the contents of a vector just like in python.
author: Mohamed-faaris
tags: printing,debuging,vector
---

```cpp
#include <iostream>
#include <vector>

template <typename T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) {
os << "[";
for (size_t i = 0; i < vec.size(); ++i) {
os << vec[i]; // Print each vector element
if (i != vec.size() - 1) {
os << ", "; // Add separator
}
}
os << "]";
return os; // Return the stream
}

// Usage:
std::vector<int> numbers = {1, 2, 3, 4, 5};
std::cout << numbers << std::endl; // Outputs: [1, 2, 3, 4, 5]

```
19 changes: 19 additions & 0 deletions snippets/scss/typography/px-to-rem-helper.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
title: PX to REM Helper
description: This function will convert px values to rem values.
author: gihanrangana
tags: function,pixel,rem,px-to-rem
---

```scss
@function px-to-rem($px, $base: 16px) {
@return ($px / $base) * 1rem;
}

// Usage:
div {
font-size: px-to-rem(12px); // Output: 0.75rem
padding: px-to-rem(16px); // Output: 1rem
margin: px-to-rem(32px) // Output 2rem
}
```
Loading