Skip to content

Instantly share code, notes, and snippets.

View SashaKolbasov's full-sized avatar

Alex SashaKolbasov

View GitHub Profile
@SashaKolbasov
SashaKolbasov / script.js
Last active March 31, 2019 16:03
Thousands Separator
var price = Math.floor(price) + '';
price = price.replace(/(\d)(?=(\d\d\d)+([^\d]|$))/g, '$1 ');
function sep(n){return n.replace(/(\d)(?=(\d\d\d)+([^\d]|$))/g,'$1 ');}
function rmm(min,max){return Math.floor(Math.random()*(max-min+1))+min;}
@SashaKolbasov
SashaKolbasov / script.js
Last active May 16, 2018 14:49
Easy Accordion.
// js-acc
var accItems = $('.js-acc > .item');
var accTitles = $('.js-acc > .item > .title');
accItems.removeClass('open').find('.desc').slideUp();
accItems.eq(0).addClass('open').find('.desc').slideDown();
accTitles.on('click', function() {
var parent = $(this).parent('.item');
if (parent.hasClass('open')) {
parent.removeClass('open').find('.desc').slideUp();
} else {
@SashaKolbasov
SashaKolbasov / index.html
Last active July 19, 2017 16:45
Yandex Placemark
<script src="https://api-maps.yandex.ru/2.1/?lang=ru_RU" type="text/javascript"></script>
<a class="mapFly" data-flyx="59.9178326" data-flyy="30.3937128">Санкт-петербург</a>
<a class="mapFly" data-flyx="55.755826" data-flyy="37.6173">Москва</a>
<script type="text/javascript">
ymaps.ready(init);
function init() {
@SashaKolbasov
SashaKolbasov / index.html
Last active March 27, 2017 17:02
Fixing Header inside the page
<div id="header" class="header">
<div id="headerWrap" class="header__wrap">
</div>
</div>
@SashaKolbasov
SashaKolbasov / index.html
Last active March 27, 2017 16:56
Upload Photo/File
<label class="attach attachInput">
<span>Загрузите ваше фото</span>
<input type="file" name="photo" class="photo" accept="image/*" required />
</label>
@SashaKolbasov
SashaKolbasov / php.php
Last active May 2, 2017 16:53
Insert String without whitespaces
<a href="tel:<?php $phone = get_field('blog_header_phone', 4); echo str_replace(" ", "", $phone); ?>">
<?php echo $phone; ?>
</a>
@SashaKolbasov
SashaKolbasov / php.php
Created May 3, 2017 16:35
Sort Array by field
<?php
function cmp($a, $b) { return strcmp($a["cat_letter"], $b["cat_letter"]); }
usort($infoCats, "cmp");
?>
@SashaKolbasov
SashaKolbasov / index.html
Last active January 6, 2019 16:30
Pause YouTube video
<iframe src="https://www.youtube.com/embed/XXX?enablejsapi=1" frameborder="0" allowfullscreen></iframe>
<iframe src="https://www.youtube.com/embed/fjjkcWP4heM?rel=0&amp;controls=0&amp;showinfo=0&amp;start=5&amp;enablejsapi=1" frameborder="0" allowfullscreen></iframe>
<iframe src="https://www.youtube-nocookie.com/embed/knfrxj0T5NY" frameborder="0" allow="accelerometer; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
@SashaKolbasov
SashaKolbasov / hooks.php
Last active May 17, 2018 18:18
Own WordPress hooks
// page tags
<?php get_header(); ?>
<?php get_footer(); ?>
<?php bloginfo('template_url'); ?>/
<?php /* Template Name: Index */ ?>
<?php get_template_part('partname'); ?>
<?php get_template_part('template-parts/content-post', get_post_type()); ?>
<?php wp_head(); ?>
<?php wp_footer(); ?>
@SashaKolbasov
SashaKolbasov / index.html
Last active October 24, 2017 23:34
Custom + / - Input field
<div class="input input-number">
<button class="minus">‐</button>
<input type="number" name="" id="" class="" value="1">
<button class="plus">+</button>
</div>