Skip to content

Instantly share code, notes, and snippets.

View Vterebenin's full-sized avatar

Valentin Vterebenin

  • Andersenlab
  • 06:52 (UTC +03:00)
View GitHub Profile
function curry(callback, ...oldParameters) {
return function(...parameters) {
const nextParameters = [...oldParameters, ...parameters]
if (nextParameters.length >= callback.length) {
return callback(...nextParameters)
}
return curry(callback, ...nextParameters)
}
@Vterebenin
Vterebenin / pageInit.js
Last active August 9, 2019 10:46
Отложенная загрузка карты
if ($("#js-map-loader").length) {
map = $("#js-map-loader") // айдишник блока в котором будет карта
$(window).scroll(function () {
if ($(window).scrollTop() > (map.offset().top - $(window).height())) {
if ($("#js-map-loader iframe").length === 0) {
// аппендим код карты
$("#js-map-loader").append("<iframe frameborder='0' height='1080' src='https://yandex.ru/map-widget/v1/?um=constructor%3A12e7ecd65e53d92c0026ea8421b362b4a4ba635f1cbdf5899bc3273afb1bc21b&amp;source=constructor' width='100%'></iframe>")
}
} else {
return false
@Vterebenin
Vterebenin / videos.css
Created July 31, 2019 14:14
Отложенная загрузка видео с ютьюб.
.youtube {
background-position: center;
background-repeat: no-repeat;
position: relative;
display: block;
overflow: hidden;
transition: all 200ms ease-out;
cursor: pointer;
}
@Vterebenin
Vterebenin / app.css
Created July 30, 2019 06:26
Constant width to height ratio
.constant-width-to-height-ratio {
background: #333;
width: 50%;
}
.constant-width-to-height-ratio::before {
content: '';
padding-top: 100%;
float: left;
}
.constant-width-to-height-ratio::after {
@Vterebenin
Vterebenin / app.css
Created July 30, 2019 06:25
pretty text underline
.pretty-text-underline {
display: inline;
text-shadow: 1px 1px #f5f6f9, -1px 1px #f5f6f9, -1px -1px #f5f6f9, 1px -1px #f5f6f9;
background-image: linear-gradient(90deg, currentColor 100%, transparent 100%);
background-position: bottom;
background-repeat: no-repeat;
background-size: 100% 1px;
}
.pretty-text-underline::-moz-selection {
background-color: rgba(0, 150, 255, 0.3);
@Vterebenin
Vterebenin / app.js
Created July 22, 2019 05:56
компонент автоссылки/ autolink component#react
ReactDOM.render(
<AutoLink text='foo bar baz http://example.org bar' />,
document.getElementById('root')
);
@Vterebenin
Vterebenin / settings.json
Created January 29, 2019 12:57
1. Установить postCSS sorting в VS code. 2.В файл настроек VS code вставить этот фрагмент. (0.0.1b не работает с препроцессорами)
{
// ЗДЕСЬ КАКИЕ ЛИБО ВАШИ НАСТРОЙКИ
//postcss sorting
"postcssSorting.config": {
"order": [
"custom-properties",
"dollar-variables",
"declarations",
"at-rules",
"rules"
@Vterebenin
Vterebenin / index.js
Created November 22, 2018 21:27
fetchAPI via async
const getResource = async (url) => {
// await мы будем ждать пока результат не будет доступен.
const res = await fetch(url);
// если произошла ошибка сервера и один из статусов реально не доступен.
if (!res.ok) {
throw new Error(`Could not fetch ${url}` +
`, received ${res.status}`);
}
const body = await res.json();
return body;
@Vterebenin
Vterebenin / button.css
Last active December 14, 2018 12:35
typical govno
/*----------------*/
.b-callback-button {
margin: 0;
border: 1px solid red;
padding: 16px 40px;
vertical-align: top;
min-width: 140px;
display: inline-block;
border-radius: 50px;
background-color: transparent;