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
var mediaJSON = { "categories" : [ { "name" : "Movies",
"videos" : [
{ "description" : "Big Buck Bunny tells the story of a giant rabbit with a heart bigger than himself. When one sunny day three rodents rudely harass him, something snaps... and the rabbit ain't no bunny anymore! In the typical cartoon tradition he prepares the nasty rodents a comical revenge.\n\nLicensed under the Creative Commons Attribution license\nhttp://www.bigbuckbunny.org",
"sources" : [ "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4" ],
"subtitle" : "By Blender Foundation",
"thumb" : "images/BigBuckBunny.jpg",
"title" : "Big Buck Bunny"
},
{ "description" : "The first Blender Open Movie from 2006",
"sources" : [ "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ElephantsDream.mp4" ],
@evanre
evanre / contact-form-7-code-editor.php
Created October 23, 2018 21:44
Contact Form 7 Code Editor
<?php
/**
* Plugin Name: Contact Form 7 Code Editor
* Version: 1.0.0
* Plugin URI: https://latinandcode.com/
* Author: Eugene Zhuchenko
* Author URI: eugenezhuchenko.com
* Text Domain: elementor-latinandcode
* Domain Path: /languages/
* License: GPL v3
@evanre
evanre / map_value.php
Created August 30, 2018 15:35
Re-maps a number from one range to another
/**
* map_value()
*
* Re-maps a number from one range to another. That is, a value of fromLow would get mapped to toLow, a value of fromHigh to toHigh, values in-between to values in-between, etc.
* @url: https://www.arduino.cc/reference/en/language/functions/math/map/
*
* @param $val integer - the number to map
* @param $in_min integer - the lower bound of the value’s current range
* @param $in_max integer - the upper bound of the value’s current range
* @param $out_min integer - the lower bound of the value’s target range
@evanre
evanre / script.js
Created August 19, 2018 16:50
Search for nice and short domains script
/**
* Search for nice and short domains.
* Use for example a NameCheap
*/
// Flatten array. Ex.: ['aa', 'ab', ['ac', 'ad']] => ['aa', 'ab', 'ac', 'ad']
const flatten = arr => [].concat.apply([], arr);
// Remove non-unique items from given array
const uniq = a => [...new Set(a)];
@evanre
evanre / extend.scss
Created May 31, 2018 11:40
Sass add configuration objects to extend default params for mixins
// Configuration objects / Extend default mixin params with custom ones
// @src: https://hugogiraudel.com/2014/05/05/bringing-configuration-objects-to-sass/
// Default var for overriding
$params: () !default;
// @param {map} $obj - object with default params
// @param {map} $ext-obj - object params to extend the default
@function extend($obj, $ext-obj) {
@return map-merge($obj, $ext-obj);
}
startAnimating(function(){
console.log('test')
}, 10);
function startAnimating(cb, fps) {
var stop = false;
var frameCount = 0;
var fps, fpsInterval, startTime, now, then, elapsed;
fpsInterval = 1000 / fps;
@evanre
evanre / _flexbox.scss
Last active March 13, 2018 09:53
Flexbox mixin
/* Flex mixin */
// Map of all flexbox container properties
$flex-config: (
flex-direction: (row, row-reverse, column, column-reverse),
flex-wrap: (nowrap, wrap, wrap-reverse),
justify-content: (flex-start, flex-end, center, space-between, space-around),
align-items: (stretch, flex-start, flex-end, center, baseline),
align-content: (stretch, flex-start, flex-end, center, space-between, space-around)
);
@evanre
evanre / multi-inherit.scss
Last active March 3, 2018 13:44
Sass multi selector inheritance mixin
/// Dependency - str-replace mixin from https://css-tricks.com/snippets/sass/str-replace-function/
/// Replace `$search` with `$replace` in `$string`
/// @author Hugo Giraudel
/// @param {String} $string - Initial string
/// @param {String} $search - Substring to replace
/// @param {String} $replace ('') - New value
/// @return {String} - Updated string
@function str-replace($string, $search, $replace: '') {
$index: str-index($string, $search);
@evanre
evanre / rand-date-time.njk
Created February 9, 2018 12:19
random date and time in nunjucks
{%- macro zeroCheck(num=0) -%}
{{- '0'+num if num < 9 else num -}}
{%- endmacro -%}
{%- macro checkDefault(num=0, rand=1) -%}
{{- num if num else range(1, rand) | random -}}
{%- endmacro -%}
{%- macro randTime(hour='', minute='') -%}
{{- zeroCheck(checkDefault(hour, 24)) -}}:{{- zeroCheck(checkDefault(minute, 59)) -}}
@evanre
evanre / inline-svg-function.scss
Last active March 3, 2018 13:27 — forked from JacobDB/inline-svg-function.scss
Inline SVG function [SASS]
/// Dependency - str-replace mixin from https://css-tricks.com/snippets/sass/str-replace-function/
/// Replace `$search` with `$replace` in `$string`
/// @author Hugo Giraudel
/// @param {String} $string - Initial string
/// @param {String} $search - Substring to replace
/// @param {String} $replace ('') - New value
/// @return {String} - Updated string
@function str-replace($string, $search, $replace: '') {
$index: str-index($string, $search);