Skip to content

Instantly share code, notes, and snippets.

View chy4egg's full-sized avatar
👋
Hi there

Aleksandr Mikhailov chy4egg

👋
Hi there
  • Conzylum
  • Nicosia, Cyprus
View GitHub Profile
@chy4egg
chy4egg / jQuery Smooth Scroll
Last active December 19, 2017 08:58
jQuery Smooth Scroll
$('a[href^="#"]').on("click", function(){
var the_id = $(this).attr("href");
$('html, body').animate({
scrollTop:$(the_id).offset().top
}, 'slow');
return false;
});
@chy4egg
chy4egg / Ajax mail send with mail.php
Last active December 19, 2017 08:58
Ajax mail send with mail.php
<!-- HTML -->
<form>
<!-- Hidden Required Fields -->
<input type="hidden" name="project_name" value="Site Name">
<input type="hidden" name="admin_email" value="tes-email@test-email.com">
<input type="hidden" name="form_subject" value="Form Subject">
<!-- END Hidden Required Fields -->
<input type="text" name="Name" placeholder="You name..." required><br>
@chy4egg
chy4egg / Action on scroll script (jQuery)
Last active March 30, 2017 10:45
Action on scroll script (jQuery)
// jQuery addClass on scroll
var section1 = $('.css-class').offset().top;
var section2 = $('.css-class-2').offset().top;
$(window).scroll(function(){
//section-1
if( $(window).scrollTop() > section1 ) {
$('.css-class').addClass('active'); //добавить класс, когда проскроллил элемент.
This is my Atom settings.
@chy4egg
chy4egg / sample
Last active December 19, 2017 10:05
Pug mixin
//- Declaration
mixin pet(name)
li.pet= name
//- Use
ul
+pet('cat')
@chy4egg
chy4egg / .vimrc
Last active December 19, 2017 10:39
.vimrc
" auto reload .vimrc when changed, this avoids reopening vim
autocmd! bufwritepost .vimrc source %
set nocompatible " be iMproved, required
filetype on " required
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" alternatively, pass a path where Vundle should install plugins
@chy4egg
chy4egg / function.js
Created December 28, 2017 11:26
Склонение именительных рядом с числительным
function (number) {
var cases = [2, 0, 1, 1, 1, 2];
var titles = ['год', 'года', 'лет'];
return number + " " + titles[(number % 100 > 4 && number % 100 < 20) ? 2 : cases[(number % 10 < 5) ? number % 10 : 5]];
}
@chy4egg
chy4egg / code.js
Last active March 14, 2018 07:20
Ограничение контента по высоте с добавлением отточия. (content height limit with '...' in the end)
function ellipsizeTextBox(id, height) {
var el = document.getElementById(id);
el.style.maxHeight = height;
var wordArray = el.innerHTML.split(' ');
if (height) {
el.style.maxHeight = height;
}
while(el.scrollHeight > el.offsetHeight) {
wordArray.pop();
el.innerHTML = wordArray.join(' ') + '...';
@chy4egg
chy4egg / code.js
Last active April 19, 2018 07:30
StickyBar (js) es6 + babel + jQuery
/**
* ENG
* Makes element fixed only for the mobile version of site (until 768px)
* @constructor
* @param {string} sTarget - target css-class for the element, which becomes fixed (.j-sticky-bar)
* @param {string} sFixedClass - the name of the css-class you want to add to the sTarget element (j-fixed)
* @param {sContent} sFixedClass - when sTarget becomes fixed, sContent element gets additional padding-top (body)
*/
/**
@chy4egg
chy4egg / formatData.js
Last active May 10, 2018 09:58
Data formatting methods (js) es6
const formatData = {
// Граммы переводит в килограммы
weight : function (weight) {
weight = parseFloat(weight);
let dimension = '';
if (weight < 1000) {
dimension = ' г';
} else {
dimension = ' кг';