Skip to content

Commit 313f441

Browse files
authored
Merge branch 'dostonnabotov:main' into main
2 parents 53ce70c + 50f31a7 commit 313f441

File tree

10 files changed

+139
-42
lines changed

10 files changed

+139
-42
lines changed

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ Here’s an example for JavaScript:
117117
title: Format Date
118118
description: Formats a date in 'YYYY-MM-DD' format.
119119
author: dostonnabotov
120-
tags: javascript,date,format
120+
tags: date,format
121121
---
122122

123123
```js

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ Here's an example for JavaScript:
6363
title: Format Date
6464
description: Formats a date in 'YYYY-MM-DD' format.
6565
author: dostonnabotov
66-
tags: javascript,date,format
66+
tags: date,format
6767
---
6868

6969
```js

snippets/bash/icon.svg

Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
title: Kill Previous Instances
3+
description: Kill all previous instances of a script
4+
author: saminjay
5+
tags: kill,process,background
6+
---
7+
8+
```bash
9+
function kill_prev() {
10+
# $$ contains current pid (grep ignore so it doesn't suicide)
11+
local processes
12+
readarray -t processes < <(pgrep -f "$0" | grep -v "$$")
13+
kill "${processes[@]}" >/dev/null 2>&1
14+
}
15+
16+
# Usage:
17+
# Add this function to your background running script
18+
# It will make sure that only one instance of your script is running at a time
19+
kill_prev
20+
```
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
---
2+
title: System Resource Monitor
3+
description: Monitors system resources (CPU, RAM, disk, users)
4+
author: sponkurtus2
5+
tags: file,system
6+
---
7+
8+
```bash
9+
system_resources () {
10+
echo "CPU Load: $(top -bn1 | grep "Cpu(s)" | awk '{print $2}')%"
11+
echo "Memory Used: $(free -m | awk 'NR==2{printf "%.2f%%", $3*100/$2}')"
12+
echo "Disk Used: $(df -h / | awk 'NR==2{print $5}')"
13+
echo "Active Users: $(who | wc -l)"
14+
}
15+
16+
system_resources "$@"
17+
18+
# Usage:
19+
chmod a+x system-resource-monitor.sh # First make it executable for all the users
20+
21+
./system-resource-monitor.sh # It will print the following system resources (CPU, RAM, disk, and active users)
22+
```

snippets/css/animations/pulse-animation.md

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,22 @@ title: Pulse Animation
33
description: Adds a smooth pulsing animation with opacity and scale effects
44
author: AlsoKnownAs-Ax
55
tags: animation,pulse,pulse-scale
6+
contributors: alanb4rt
67
---
78

89
```css
910
.pulse {
10-
animation: pulse 2s ease-in-out infinite;
11+
animation: pulse 1s ease-in-out infinite alternate;
1112
}
1213

1314
@keyframes pulse {
14-
0% {
15+
from {
1516
opacity: 0.5;
1617
transform: scale(1);
1718
}
18-
50% {
19+
to {
1920
opacity: 1;
2021
transform: scale(1.05);
2122
}
22-
100% {
23-
opacity: 0.5;
24-
transform: scale(1);
25-
}
2623
}
2724
```
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
---
2+
title: Get Desktop Enviroment
3+
description: Get the Desktop Enviroment that the user is currently using.
4+
author: sponkurtus2
5+
tags: linux,file
6+
---
7+
8+
```rust
9+
fn get_desktop_env() -> String {
10+
// Return empty string if no X display is available
11+
if env::var("DISPLAY").is_err() {
12+
return String::new();
13+
}
14+
15+
// Check common desktop environment variables.
16+
for env_var in &[
17+
"XDG_SESSION_DESKTOP",
18+
"XDG_CURRENT_DESKTOP",
19+
"DESKTOP_SESSION",
20+
] {
21+
if let Ok(de) = env::var(env_var) {
22+
return de;
23+
}
24+
}
25+
26+
// As fallback, try to get desktop name from last word of last line in .xinitrc
27+
let path = format!("{}/.xinitrc", env::var("HOME").unwrap_or_default());
28+
if let Ok(mut file) = File::open(&path) {
29+
let mut buf = String::new();
30+
if file.read_to_string(&mut buf).is_ok() {
31+
if let Some(last_line) = buf.lines().last() {
32+
let last_word = last_line.split(' ').last().unwrap_or("");
33+
return last_word.to_string();
34+
}
35+
}
36+
}
37+
38+
// Return "N/A" if no desktop environment could be detected
39+
String::from("N/A")
40+
}
41+
42+
// Usage:
43+
get_desktop_env(); // Returns: the desktop enviroment that the user actually has e.g. i3.
44+
```

src/components/CodePreview.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ const CodePreview = ({ language = "markdown", code }: Props) => {
4040
language={language}
4141
style={theme === "dark" ? oneDark : oneLight}
4242
wrapLines={true}
43-
customStyle={{ margin: "0", maxHeight: "20rem" }}
43+
customStyle={{ margin: "0", maxHeight: "32rem" }}
4444
>
4545
{code}
4646
</SyntaxHighlighter>

src/components/SnippetModal.tsx

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -61,29 +61,31 @@ const SnippetModal: React.FC<Props> = ({
6161
<CloseIcon />
6262
</Button>
6363
</div>
64-
<CodePreview language={slugify(language)} code={snippet.code} />
65-
<p>
66-
<b>Description: </b>
67-
{snippet.description}
68-
</p>
69-
<p>
70-
Contributed by{" "}
71-
<a
72-
href={`https://github.com/${snippet.author}`}
73-
target="_blank"
74-
rel="noopener noreferrer"
75-
className="styled-link"
76-
>
77-
@{snippet.author}
78-
</a>
79-
</p>
80-
<ul role="list" className="modal__tags">
81-
{snippet.tags.map((tag) => (
82-
<li key={tag} className="modal__tag">
83-
{tag}
84-
</li>
85-
))}
86-
</ul>
64+
<div className="modal__body | flow">
65+
<CodePreview language={slugify(language)} code={snippet.code} />
66+
<p>
67+
<b>Description: </b>
68+
{snippet.description}
69+
</p>
70+
<p>
71+
Contributed by{" "}
72+
<a
73+
href={`https://github.com/${snippet.author}`}
74+
target="_blank"
75+
rel="noopener noreferrer"
76+
className="styled-link"
77+
>
78+
@{snippet.author}
79+
</a>
80+
</p>
81+
<ul role="list" className="modal__tags">
82+
{snippet.tags.map((tag) => (
83+
<li key={tag} className="modal__tag">
84+
{tag}
85+
</li>
86+
))}
87+
</ul>
88+
</div>
8789
</motion.div>
8890
</motion.div>,
8991
modalRoot

src/styles/main.css

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -550,22 +550,19 @@ abbr {
550550
border-radius: var(--br-lg);
551551
padding: 0.75em;
552552
text-align: start;
553-
filter: grayscale(100%);
554553

555554
&:is(:hover, :focus-visible) {
556-
outline: 3px solid var(--clr-border-primary);
557-
filter: grayscale(0);
555+
outline: 2px solid var(--clr-border-primary);
558556
}
559557
}
560558

561559
.snippet__preview {
562560
width: 100%;
563561
overflow: hidden;
564-
aspect-ratio: 10 / 3;
562+
aspect-ratio: 9 / 3;
565563
background-color: var(--clr-bg-secondary);
566564
/* background-image: var(--gradient-secondary); */
567565
border: 1px solid var(--clr-border-primary);
568-
border-radius: var(--br-md);
569566
position: relative;
570567
padding-inline: 1em;
571568
display: grid;
@@ -599,20 +596,34 @@ body:has(.modal-overlay) {
599596

600597
.modal {
601598
background-color: var(--clr-bg-secondary);
602-
padding: 2rem;
603-
width: 90%;
604-
max-width: 800px;
599+
width: fit-content;
600+
min-width: 50%;
601+
max-width: 1000px;
602+
max-height: 90%;
605603
border-radius: var(--br-lg);
606604
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
605+
gap: 0;
607606
position: relative;
608-
gap: 1rem;
607+
overflow: auto;
609608
}
610609

611610
.modal__header {
611+
z-index: 50;
612612
display: flex;
613+
position: sticky;
614+
top: 0;
613615
align-items: center;
614616
justify-content: space-between;
615617
gap: 1rem;
618+
padding: 1rem 1.5rem;
619+
background-color: var(--clr-bg-secondary);
620+
border-radius: var(--br-lg);
621+
}
622+
623+
.modal__body {
624+
padding: 1.5rem;
625+
padding-top: 0;
626+
gap: 1rem;
616627
}
617628

618629
.code-preview {

0 commit comments

Comments
 (0)