Skip to content

Instantly share code, notes, and snippets.

View antonreshetov's full-sized avatar
:octocat:
Keep hacking

Anton Reshetov antonreshetov

:octocat:
Keep hacking
View GitHub Profile
@antonreshetov
antonreshetov / GUID
Created June 21, 2017 07:51
Generate Random ID
Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15);
// Or more strong
function guid() {
function s4() {
return Math.floor((1 + Math.random()) * 0x10000)
.toString(16)
.substring(1);
}
return s4() + s4() + '-' + s4() + '-' + s4() + '-' +
s4() + '-' + s4() + s4() + s4();
@antonreshetov
antonreshetov / wp_custom_menu_walker.php
Last active June 22, 2017 22:03
WP custom menu walker
// http://wordpress.stackexchange.com/questions/145984/change-an-li-class-name-in-a-wordpress-custom-menu-walker
<?php
class Main_Walker_Nav_Menu extends Walker_Nav_Menu {
function start_lvl( &$output, $depth = 0, $args = [] ) {
$indent = str_repeat( "\t", $depth );
switch ( $depth ) {
case 0:
$class = 'menu__list-sub';
@antonreshetov
antonreshetov / transliterate-filename.js
Created February 16, 2017 14:49
Gulp transliteration filename
var gulp = require('gulp');
var rename = require("gulp-rename");
var translit = require('speakingurl');
gulp.task('translit', function () {
gulp.src("./*.*")
.pipe(rename(function(path){
var trl = translit(path.basename, {
lang: 'en'
})
function textAreaResize() {
var textArea = document.getElementById('text');
textArea.addEventListener('input', resize);
function resize() {
textArea.style.height = 'auto';
textArea.style.height = text.scrollHeight + 2 + 'px';
}
}
textAreaResize();