Skip to content

Instantly share code, notes, and snippets.

@yuriy-o
yuriy-o / Самописні throttle & debounce function
Last active November 23, 2022 08:40
throttle & debounce function
/**
* Creates a throttled function that only invokes _throttledFunc_ at most once per every _timeout_ milliseconds
* https://youtu.be/9jtfYW6o1PE?t=4593
*
* @param {Function} throttledFunc
* @param {number} timeout
*
* @returns {Function}
*/
function throttle(throttledFunc, timeout) {
@yuriy-o
yuriy-o / bubble sorting
Created September 27, 2022 13:04
bubble sorting
// ---- bubble sorting ----
const langs = ['python', 'javascript', 'c++', 'haskel', 'php', 'ruby'];
langs.sort();
for (let i = 0; i < langs.length - 1; i += 1) {
for (let j = i + 1; j < langs.length; j += 1) {
const item1 = langs[i]; // python
const item2 = langs[j];
if (item2[0] < item1[0]) {
@yuriy-o
yuriy-o / QuickSort сортування
Created September 27, 2022 12:57
QuickSort сортування
// ---- quicksort ----
// function quicksort(numbers) {
// if (numbers.length < 2) return numbers;
// const pivot = numbers[0];
// const left = [];
// const right = [];
// for (let i = 1; i < numbers.length; i++) {
// numbers[i] < pivot ? left.push(numbers[i]) : right.push(numbers[i]);
@yuriy-o
yuriy-o / міксін з функцією перерахунку значення line-height
Created June 20, 2022 21:12
міксін з функцією перерахунку значення line-height
@mixin btn {
padding: 12px 20px;
max-width: 200px;
min-width: 160px;
min-height: 40px;
font-family: inherit;
font-weight: 600;
font-size: 12px;
line-height: 1.33;
@yuriy-o
yuriy-o / mixin для button
Created June 20, 2022 21:08
mixin для button
@mixin main-button($font, $font-size, $font-color, $border-size, $border-color, $padding, $transition-speed, $hover-color)
{
display:inline-block;
text-decoration:none;
text-transform:uppercase;
font-family: $font;
font-size: $font-size;
color:$font-color;
border:$border-size solid $border-color;
padding:$padding;
@yuriy-o
yuriy-o / Ретінізація фонових зображень
Created June 20, 2022 21:07
Ретінізація фонових зображень
.price {
background-image: url(../images/price/bg-price_sm.png),
linear-gradient(to bottom, #191c26, #191c26);
background-image: -webkit-image-set(url(../images/price/bg-price_sm.webp) 1x),
linear-gradient(to bottom, #191c26, #191c26);
// Завантаження ретінізованого 2х фонового зображення
@include mq(retina) {
background-image: url(../images/price/bg-price_sm@2x.png),
linear-gradient(to bottom, #191c26, #191c26);
@yuriy-o
yuriy-o / тег <picture> для зображень 1х, 2х, jpg та webp
Created June 20, 2022 21:06
тег <picture> для зображень 1х, 2х, jpg та webp
<picture>
<source
media="(min-width: 1280px)"
srcset="
./images/gallery/gallery-2_lg.webp 1x,
./images/gallery/gallery-2_lg@2x.webp 2x
"
type="image/webp"
/>
<source
@yuriy-o
yuriy-o / Миксин для адаптивки
Created June 19, 2022 21:15
Миксин для адаптивки
@mixin mq($type) {
$mobile: 480px;
$tablet: 768px;
$desktop: 1200px;
@if $type == 'mobile-only' {
@media screen and (max-width: #{$tablet - 0.02}) {
@content;
}
}
@yuriy-o
yuriy-o / Ярко жовтий колір коментарів. Код додати в settings.json
Last active June 19, 2022 21:16
Ярко жовтий колір коментарів. Код додати в settings.json
"editor.tokenColorCustomizations": {
"textMateRules": [
{
"scope": ["comment"],
"settings": {
"fontStyle": "italic",
"foreground": "#ffff35" // change color only for the comment text
}
}
// {
{
"printWidth": 100,
"tabWidth": 2,
"useTabs": false,
"semi": true,
"singleQuote": true,
"trailingComma": "es5",
"bracketSpacing": true,
"jsxBracketSameLine": false,
"arrowParens": "avoid",