🤓 Code Snippets
Share and store your most common code snippets. Use our snippet explanation generator to use AI to try and explain the code.
const arithmeticProgression = (n, lim) =>
Array.from({ length: Math.ceil(lim / n) }, (_, i) => (i + 1) * n );
arithmeticProgression(5, 25); // [5, 10, 15, 20, 25]
2
How to install WSL on Windows
powershell
wsl –install
2
My first web page
html
<!DOCTYPE html>
<html>
<head>
<title>My First Web Page</title>
</head>
<body>
<h1>Asslam O Alikum! World</h1>
</body>
</html>
3
Split an array
javascript
const splitInto = n => (accm, value) => accm.every(e => e.length === n) ?
[...accm, [value]] :
[...accm.slice(0, -1), [...accm[accm.length - 1], value]]
2
from os import system
system('echo "Hello, world!"')
3
from itertools import cycle
my_list = ['list element 1', 'list element 2']
for list_element in cycle(my_list):
print(list_element)
"""
The above for loop would output:
list element 1
list element 2
list element 1
list element 2
list element 1
list element 2
and so on...
"""
2
def find_factorial(num):
result = 1
count = 1
while count <= num:
result *= count
count += 1
return result
2
/*****
*
* Here is the HTML that should trigger the following method:
* <button wire:click="removeMe">Remove</button>
* Thsi will call the removeMe() method inside a Livewire controller
*
*****/
public function removeMe()
{
$this->image = '';
}
const validateNumber = n => !isNaN(parseFloat(n)) && isFinite(n) && Number(n) == n;
validateNumber('10'); // true
2
External link to CSS
html
<link rel="stylesheet" type="text/css" href="">
1
Load More