Skip to content

Instantly share code, notes, and snippets.

@NazarkinRoman
NazarkinRoman / readme.md
Created February 25, 2020 14:36
tree traversal implementations

Обход в глубину с рекурсией

function dfsWalkRecursive(node) {
  console.log(node.value)
  if(node.children) node.children.forEach(childNode => dfsWalkRecursive(childNode))
}


const tree = {
@NazarkinRoman
NazarkinRoman / index.js
Last active March 19, 2019 21:01
Gulp wrapper for node-wp-i18n
/* eslint-env node */
/** global: Buffer */
'use strict';
const gutil = require('gulp-util');
const through = require('through2');
const wpi18n = require('node-wp-i18n');
const PluginError = gutil.PluginError;
@NazarkinRoman
NazarkinRoman / main.js
Last active September 25, 2018 08:12
Improved version of Draggable without jQuery UI https://css-tricks.com/snippets/jquery/draggable-without-jquery-ui/
// bug - on each click this code creates a new event listener for all $drag parents
// serious lack of memory and permormance
// solution - unbind this event on 'mouseup' and make 'mouseup' once-executable via one()
(function($) {
$.fn.drags = function(opt) {
opt = $.extend({handle: '', cursor: 'move'}, opt);
if(opt.handle === '') {
@NazarkinRoman
NazarkinRoman / main.js
Created July 17, 2015 14:06
Improved version of Image Comparison Slider from CodyHouse http://codyhouse.co/gem/css-jquery-image-comparison-slider/
// improved drags function, replace it in your code
function drags(dragElement, resizeElement, container, labelContainer, labelResizeElement) {
var $ = jQuery;
dragElement.on('mousedown vmousedown', function (e) {
dragElement.addClass('cd-draggable');
resizeElement.addClass('cd-resizable');
var dragWidth = dragElement.outerWidth(),
xPosition = dragElement.offset().left + dragWidth - e.pageX,