Skip to content

Instantly share code, notes, and snippets.

View terehof's full-sized avatar
🙃

Sergey terehof

🙃
View GitHub Profile
// Get The Page ID You Need
get_option( 'woocommerce_shop_page_id' );
get_option( 'woocommerce_cart_page_id' );
get_option( 'woocommerce_checkout_page_id' );
get_option( 'woocommerce_pay_page_id' );
get_option( 'woocommerce_thanks_page_id' );
get_option( 'woocommerce_myaccount_page_id' );
get_option( 'woocommerce_edit_address_page_id' );
get_option( 'woocommerce_view_order_page_id' );
get_option( 'woocommerce_terms_page_id' );
@terehof
terehof / gist:d1e0526b315dada02a08419378d36abc
Last active November 6, 2017 11:16
ffmpeg terminal commands
//rotate video 90degrees clockwise
ffmpeg -i in.mov -vf "transpose=1" out.mov
//0 = 90CounterCLockwise and Vertical Flip (default)
//1 = 90Clockwise
//2 = 90CounterClockwise
//3 = 90Clockwise and Vertical Flip
@terehof
terehof / hash.js
Created September 13, 2016 10:24
Hash
Hash = {
// Получаем данные из адреса
get: function() {
var vars = {}, hash, splitter, hashes;
if (!this.oldbrowser()) {
var pos = window.location.href.indexOf('?');
hashes = (pos != -1) ? decodeURIComponent(window.location.href.substr(pos + 1)) : '';
splitter = '&';
}
else {
@terehof
terehof / gist:22af6bdc5c5f4583dca90101c5a5d1f0
Last active September 2, 2016 08:22
координаты клика относительно самого элемента
$('.elem').on('click', function (e) {
var elemW = $('.elem').width(),
elemH = $('.elem').height(),
xClick = e.pageX - $(this).offset().left,
yClick = e.pageY - $(this).offset().top,
xClickPercent = (xClick/elemW)*100,
yClickPercenr = (yClick/elemH)*100;
console.log('x = ' + xClickPercent + '%', 'y = ' + yClickPercenr + '%');
@terehof
terehof / Image Preloader
Created April 22, 2015 08:46
Very easy way to preload images which are needed later (e.g. when a hover is performed) (from css-tricks.com !!!)
$.preloadImages = function() {
for (var i = 0; i < arguments.length; i++) {
$("<img />").attr("src", arguments[i]);
}
}
$.preloadImages("hoverimage1.jpg","hoverimage2.jpg");
@terehof
terehof / group of checkboxes
Created March 17, 2015 12:58
группа чекбоксов (когда отмечаешь главный, дочерние тоже отмечаются)
$('body').on('change','[data-group]',function(){
var is_main = $(this).data('group-main');
is_main = is_main || 0;
var group = $(this).data('group');
var is_checked;
// Если дернули главный чекбокс
if(is_main)
{
// если его отметили, то отметим все дочерние
is_checked = false;
@terehof
terehof / validation numbers for input
Created March 17, 2015 12:56
validation number by class
$('body').on('keydown','.validate_numeric',function(e){
var specialKeys = new Array();
specialKeys.push(8,37,39,46,190);
var keyCode = e.which ? e.which : e.keyCode;
cl(keyCode);
var ret = ((keyCode >= 48 && keyCode <= 57) || specialKeys.indexOf(keyCode) != -1);
if(!ret)
return false;
});
// стрелки, цифры, бекспейс
@terehof
terehof / js smooth scroll for anchors
Last active January 24, 2017 22:16
jq snippet smooth scrolling for anchors
$(document).ready(function() {
$("a.scrollto").click(function () {
elementClick = $(this).attr("href")
destination = $(elementClick).offset().top;
$("html:not(:animated),body:not(:animated)").animate({scrollTop: destination}, 1100);
return false;
});
});
// add "<a href="#section-2" class="scrollto">Section 2</a>"
if(window.matchMedia('(max-width: 768px)').matches) {
$('.sub-menu-button').on('click',function(e) {
var subMenu = $(this).next('.sub-navigation');
if(subMenu.is(':visible')) {
subMenu.slideUp();
} else {
subMenu.slideDown();
}
return false;
});
@terehof
terehof / plug for ie<9
Created March 14, 2015 13:02
html snippets
<!--[if lt IE 9]>
<style>
.wrapper, footer, .header {
display: none;
}
body {
background: #fff;
}
</style>