Skip to content

Commit 8508752

Browse files
Merge pull request #178 from gihanrangana/px-to-rem
[Snippet] SASS function to convert px to rem
2 parents ae37cab + b8f2607 commit 8508752

File tree

4 files changed

+62
-0
lines changed

4 files changed

+62
-0
lines changed

public/consolidated/cpp.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
]
3434
},
3535
{
36+
"categoryName": "Debuging",
3637
"name": "Debugging",
3738
"snippets": [
3839
{

public/consolidated/scss.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,19 @@
156156
"contributors": [],
157157
"code": "@mixin line-clamp($number) {\n display: -webkit-box;\n -webkit-box-orient: vertical;\n -webkit-line-clamp: $number;\n overflow: hidden;\n}\n"
158158
},
159+
{
160+
"title": "PX to REM Helper",
161+
"description": "This function will convert px values to rem values.",
162+
"author": "gihanrangana",
163+
"tags": [
164+
"function",
165+
"pixel",
166+
"rem",
167+
"px-to-rem"
168+
],
169+
"contributors": [],
170+
"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"
171+
},
159172
{
160173
"title": "Text Gradient",
161174
"description": "Adds a gradient color effect to text.",

snippets/cpp/debuging/vector-print.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
---
2+
title: Vector Print
3+
description: Overloads the << operator to print the contents of a vector just like in python.
4+
author: Mohamed-faaris
5+
tags: printing,debuging,vector
6+
---
7+
8+
```cpp
9+
#include <iostream>
10+
#include <vector>
11+
12+
template <typename T>
13+
std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) {
14+
os << "[";
15+
for (size_t i = 0; i < vec.size(); ++i) {
16+
os << vec[i]; // Print each vector element
17+
if (i != vec.size() - 1) {
18+
os << ", "; // Add separator
19+
}
20+
}
21+
os << "]";
22+
return os; // Return the stream
23+
}
24+
25+
// Usage:
26+
std::vector<int> numbers = {1, 2, 3, 4, 5};
27+
std::cout << numbers << std::endl; // Outputs: [1, 2, 3, 4, 5]
28+
29+
```
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
title: PX to REM Helper
3+
description: This function will convert px values to rem values.
4+
author: gihanrangana
5+
tags: function,pixel,rem,px-to-rem
6+
---
7+
8+
```scss
9+
@function px-to-rem($px, $base: 16px) {
10+
@return ($px / $base) * 1rem;
11+
}
12+
13+
// Usage:
14+
div {
15+
font-size: px-to-rem(12px); // Output: 0.75rem
16+
padding: px-to-rem(16px); // Output: 1rem
17+
margin: px-to-rem(32px) // Output 2rem
18+
}
19+
```

0 commit comments

Comments
 (0)