Skip to content

Instantly share code, notes, and snippets.

View belocer's full-sized avatar
💭
My blog. good-code.ru

Денис Белоцерковец belocer

💭
My blog. good-code.ru
View GitHub Profile
@belocer
belocer / index.html
Last active February 26, 2024 05:25
Cookie banner
<div class="cookie">
<p class="cookie__description">This website uses cookies to ensure you get the best experience on our website.</p>
<div class="cookie__link-btn">
<a href="{{ route('privacy-policy') }}" class="cookie__link">Cookie Settings</a>
<button class="cookie__accept-btn">Accept all cookies</button>
</div>
</div>
@belocer
belocer / index.js
Created August 3, 2022 13:59
Отдаёт base64 в замен на изображение
//Отдаёт Base64
function encodeImageFileAsURL(el) {
let file = el;
let reader = new FileReader();
reader.onloadend = function () {
return reader.result;
}
reader.readAsDataURL(file);
}
@belocer
belocer / README.md
Last active September 25, 2021 11:27
gulpfile

gulp4 / Landing Page / WordPress

Собрать сборку

gulp build

Запустить

gulp

@belocer
belocer / index.html
Created February 11, 2021 11:05
Обработка ошибок в Promise
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Promise Error</title>
<style>img {
max-width: 200px;
}</style>
@belocer
belocer / index.js
Created February 9, 2021 13:22
ES6 пример наследования
// ES6
class ProductES {
constructor(brand, price, discount) {
this.brand = brand;
this.price = price;
this.discount = discount;
}
get brand() {
return this._brand;
@belocer
belocer / index.html
Last active February 3, 2021 06:52
Vue.js убираем дёргания и отображение интерполяции при загрузки страницы.
<style>
[v-cloak] {
display: none;
}
</style>
<div id="app" v-cloak>
</div>
@belocer
belocer / js.js
Created February 3, 2021 06:50
Самописный map
const names = ['Denis', 'Ivan', 'Maks', 'Olga']
function mapArray(arr, fn) {
let res = []
for (let i = 0; i < arr.length; i++) {
res.push(fn(arr[i]));
}
return res;
}
@belocer
belocer / map.js
Last active October 6, 2020 10:54
Объект Map() Object Map()
let map = new Map();
map.set('42', 4222);
map.set(42, '4222');
map.set(44, '666');
console.log(map.get('42')); // 4222
console.log(map.has('42')); // true
console.log(map.has(43)); // false
console.log(map.size); // 3
console.log(map);
@belocer
belocer / index.js
Last active October 6, 2020 10:48
forEach filter map reduce find
let people = [
{name: 'Mihail', age: 15, budget: 100},
{name: 'Maria', age: 25, budget: 200},
{name: 'Miron', age: 35, budget: 300},
]
people.forEach((person, index, pArr) => {
console.log(person)
console.log(person.name)
console.log(person.age)
@belocer
belocer / index.html
Last active October 3, 2020 13:13
Retina
<img src="img/img_x1.jpg"
srcset="img/img_x2.jpg 2x img/img_x3.jpg 3x">
<img src="img/img_x1.jpg"
srcset="img/img_x2.jpg 500w img/img_x3.jpg 700w img/img_x4.jpg 1000w">