Skip to content

Instantly share code, notes, and snippets.

View evanre's full-sized avatar
👨‍💻
Code is poetry.

Yevhen Zhuchenko evanre

👨‍💻
Code is poetry.
View GitHub Profile
@evanre
evanre / log.php
Last active July 26, 2018 19:03
Simple debug trace to wp-content/debug.log
/**
* Simple debug trace to wp-content/debug.log
*
* @usage _log( $var );
*/
if ( ! function_exists( '_log' ) ) {
function _log() {
$args = func_get_args();
@evanre
evanre / is_edit_page.php
Last active June 27, 2017 16:00
Function to check if the current page is a post edit page
<?php
/**
* is_edit_page
* function to check if the current page is a post edit page
*
* @author Ohad Raz <admin@bainternet.info>
* @url https://wordpress.stackexchange.com/questions/50043
*
* @param string $new_edit what page to check for accepts new - new post page ,edit - edit post page, null for either
* @return boolean
@evanre
evanre / custom-setup.php
Last active October 24, 2022 18:44
Just another WordPress debug function
/**
* Simple debug trace to the end of the page
*
* @usage d( $data );
*/
if ( true === WP_DEBUG ) {
function d( $data ) {
@mixin valid-quantity($quantity) {
@if type-of($quantity) != 'number' {
@error 'The "quantity" parameter must be a number!';
}
@if not(unitless($quantity)) {
@error 'The "quantity" parameter must not have a unit!';
}
@if $quantity < 0 {
@error 'The "quantity" parameter must be at least 0!';
}
@evanre
evanre / gulpfile.js
Created May 9, 2017 09:22
Wordpress gulpfile.js
var
// global
gulp = require('gulp'),
watch = require('gulp-watch'),
browserSync = require("browser-sync"),
reload = browserSync.reload,
sass = require('gulp-sass'),
prefixer = require('gulp-autoprefixer'),
cssnano = require('gulp-cssnano'),
@evanre
evanre / debounce-throttle.js
Last active October 20, 2017 14:18
Debounce and throttle function's decorator jQuery plugin
/**
* Debounce and throttle helper function's
*
* https://remysharp.com/2010/07/21/throttling-function-calls
*
* Examples:
* $('input.username').keypress(debounce(function (event) {
* // do the Ajax request
* }, 250));
*
@evanre
evanre / _bp.scss
Last active November 3, 2017 15:59
$breakpoints: (
xsmall: 0,
small: 480px,
medium: 768px,
large: 992px,
xlarge: 1024px,
//xlarge: 1200px,
//xxlarge: 1200px,
) !default;
@evanre
evanre / sql-dump.php
Last active August 25, 2016 00:54
Use this method, if you need site database, but you have access to site only via ftp (and no access to mysqlserver\phpmyadmin\cli). Copy file to site root, paste db acces info to string (delete double underscores), and open in browser http://site.com/sql-dump.php. Done. Warning! It's VERY unsafe to leave file on server. Make your dump and delete…
<?php
// Make dump of database via php
exec('mysqldump --user=__user_name__ --password=__user_pass__ --host=__host(localhost)__ __db_name__ > dump.sql');
print_r('Dump saved');
@evanre
evanre / header.html
Last active August 19, 2016 18:08
Show sticky header when start to scrollup
<div id="page" class="site">
<header id="masthead" class="site-header" role="banner"></header>
</div>
@evanre
evanre / _font-face.scss
Last active April 10, 2018 10:33
Font-face mixin
// To see how it works, copy this code and paste on http://www.sassmeister.com/
//Font-face mixin
//Generate font src string
@function font-src-list($formats, $local, $name, $path, $weight, $type) {
$string: unquote('') !default;
$i: 1;
@if $local {
@each $item in $local {
$string: $string + unquote('local("#{$item}"), ');
}