Skip to content

Instantly share code, notes, and snippets.

@Yelakelly
Yelakelly / .editorconfig
Created September 18, 2018 16:32
Editor config
root = true
# Unix-style newlines with a newline ending every file
[*]
end_of_line = lf
insert_final_newline = true
# Matches multiple files with brace expansion notation
# Set default charset
[*.{js,py}]
@Yelakelly
Yelakelly / .sql
Created March 2, 2018 21:55
Wordpress - select all acf fields by post category
---- "wp_term_relationships.term_taxonomy_id" - is the id of category
SELECT * FROM wp_term_relationships
LEFT JOIN wp_posts ON wp_posts.id = wp_term_relationships.object_id
LEFT JOIN wp_postmeta ON wp_posts.id = wp_postmeta.post_id
WHERE wp_term_relationships.term_taxonomy_id = 35 AND wp_postmeta.meta_key = 'minimal_hours';
@Yelakelly
Yelakelly / sql.sql
Created January 2, 2018 12:53
MySQL - cyrillic to latin (MySQL)
DELIMITER $$
--
-- Functions
--
CREATE FUNCTION `transliterate_func`(original VARCHAR(512)) RETURNS varchar(512) CHARSET utf8
BEGIN
DECLARE translit VARCHAR(512) DEFAULT '';
DECLARE len INT(3) DEFAULT 0;
DECLARE pos INT(3) DEFAULT 1;
@Yelakelly
Yelakelly / bs-config.js
Created December 30, 2017 13:45
bs-config.js
/*
|--------------------------------------------------------------------------
| Browser-sync config file
|--------------------------------------------------------------------------
|
| For up-to-date information about the options:
| http://www.browsersync.io/docs/options/
|
| There are more options than you see here, these are just the ones that are
@Yelakelly
Yelakelly / index.js
Last active December 19, 2017 15:40
Magnific Popup - Success / Error Alert
// Закрыващем предыдущий попап (форму)
$.magnificPopup.close();
// Создаем задержку для завершения анимации закрытия
setTimeout(function(){
$.magnificPopup.open({
items: {
src: $('#message-success')
@Yelakelly
Yelakelly / style.css
Created August 28, 2017 08:49
Background - center (without transform)
img{
position: absolute;
/* Position the image in the middle of its container. */
top: -9999px;
right: -9999px;
bottom: -9999px;
left: -9999px;
margin: auto;
/* The following values determine the exact image behaviour. */
/* You can simulate background-size: cover/contain/etc.
@Yelakelly
Yelakelly / catalog.php
Created July 5, 2017 20:08
Opencart - add related to products without related
public function demo(){
$this->load->model('catalog/product');
$this->load->model('catalog/category');
$empty = $this->model_catalog_product->setRelated();
foreach($empty as $item){
$product_id = $item['product_id'];
$product_categories = $this->model_catalog_product->getCategories($product_id);
@Yelakelly
Yelakelly / example.php
Created June 13, 2017 23:06
Google captcha snippet
<?php
$captcha_res = $_POST['g-recaptcha-response'];
$secret_code = "SECRET KEY";
if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
$ip = $_SERVER['HTTP_CLIENT_IP'];
} elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
} else {
@Yelakelly
Yelakelly / index.html
Created April 18, 2017 20:05
Adaptive navigation
<div class="primary-nav-button">
<button class="hamburger hamburger--collapse js-nav-toggle" type="button">
<span class="hamburger-box">
<span class="hamburger-inner"></span>
</span>
</button>
</div>
<nav class="primary-nav primary-nav--header">
<ul class="primary-nav__list">
@Yelakelly
Yelakelly / index.html
Last active March 22, 2017 12:17
Magnific popup - Gallery
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Demo</title>
</head>
<body>
<div class="images">
<a href="http://lorempixel.com/600/600" class="image-popup"><img class="images__item" src="http://lorempixel.com/200/200"/></a>
<a href="http://lorempixel.com/600/600" class="image-popup"><img class="images__item" src="http://lorempixel.com/200/200"/></a>