Skip to content

Instantly share code, notes, and snippets.

View lgrachov's full-sized avatar
😀
"deplete" is not a typo.

Lev Grachov lgrachov

😀
"deplete" is not a typo.
View GitHub Profile
@lgrachov
lgrachov / noDuplicateChars.js
Created October 18, 2024 21:47
Remove duplicate characters in a string.
function noDuplicateChars(str) {
return [...new Set(str.split(""))].join("")
}
@lgrachov
lgrachov / generateArtefact.sh
Created September 12, 2024 15:45
Create artefact for JavaScript code when executed
node index.js > artifact.txt
@lgrachov
lgrachov / quickSort.js
Created September 3, 2024 15:41
Short quick sort function
function quickSort(arr) {
if (arr.length <= 1) return arr;
const pivot = arr[arr.length - 1];
const left = arr.filter(el => el < pivot);
const right = arr.filter(el => el >= pivot).slice(0, -1);
return [...quickSort(left), pivot, ...quickSort(right)];
}
/* Usage */
const array = [3, 5, 6, 9, 8, 1, 2, 7, 4, 10];
@lgrachov
lgrachov / randomItemFromList.js
Created September 1, 2024 21:10
Get random item from list in JavaScript
const randomItemFromList = (list) => {
/* Simple helper function to get a random item from a list. */
return list[Math.floor(Math.random() * list.length)];
};
@lgrachov
lgrachov / sine_wave.py
Created August 18, 2024 23:10
Sine wave in Python
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.animation as animation
# Set up the figure and axis
fig, ax = plt.subplots()
x = np.linspace(0, 2 * np.pi, 100) # X values from 0 to 2π
line, = ax.plot(x, np.sin(x)) # Initial sine wave
ax.set_ylim(-1.5, 1.5) # Set y-axis limits
ax.set_title('Sine wave animation')
@lgrachov
lgrachov / index.html
Last active August 16, 2024 00:10
HTML boilerplate
<!doctype html>
<html lang="en-GB">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
</head>
<body>
<!-- Add your code here -->
</body>
@lgrachov
lgrachov / arrayToSelect.js
Created July 22, 2024 17:52
Convert array to select
const selects = [
{
name: "Select 1",
options: ["Option 1", "Option 2"],
},
{
name: 'Select 2',
options: ['Option 1, 'Option 2']
}
];
@lgrachov
lgrachov / fib.py
Created July 20, 2024 19:29
Fibonacci GUI in Python
# fib.py
# Written by Lev Grachov
# Import Tkinter
# If you get module not installed, then run this command:
# For Linux: `sudo apt-get install python3-tk`
# For Windows: `pip install tk`
# For macOS: `brew install python-tk`
from tkinter.simpledialog import askinteger
from tkinter import *
@lgrachov
lgrachov / README.markdown
Created July 8, 2024 21:30
Toggle screenshot shadow on macOS

Toggle screenshot shadow

This is a simple Bash script I made to toggle the screenshot shadow on Mac computers.

Requirements

Bash 2 or later macOS Mojave 10.14.0 or later

Usage

To toggle, just run the script. If it says access denied, run this command:

# You must be in the folder where you downloaded the .sh file
$ chmod +x toggleScreenshotShadow.sh
@lgrachov
lgrachov / Welcome! (.txt
Created September 5, 2023 11:19
Welcome!
@Leo Grachov@
Hello! I'm focused on *JavaScript*
development and love coding when
it's fun.