Skip to content

Instantly share code, notes, and snippets.

View ashgaliyev's full-sized avatar

Andrey Ashgaliyev ashgaliyev

  • Uralsk, Kazakhstan
View GitHub Profile
// before
renderPageLinks = () => {
const {page, pages} = this.props
let array_pages = Array.from({length: pages}, (v, k) => 1+k)
if(pages < page) {
this.props.onChangePage(pages)
}
return array_pages.map((item) => {
@ashgaliyev
ashgaliyev / some bash.sh
Created June 28, 2018 08:42
Kill app on port
# place this func into the .bashrc, .bash_profile, ....
function kill-on-port { kill -9 $(lsof -i tcp:"$1" -t); }
var path = require('path');
var fs = require('fs');
function mkdirP(p, mode) {
if (p.charAt(0) != '/') { return }
var ps = path.normalize(p).split('/');
if(!fs.existsSync(p)) {
mkdirP(ps.slice(0,-1).join('/'), mode);
fs.mkdirSync(p, mode);
@ashgaliyev
ashgaliyev / gist:0f134a293208da0ccef4194625ed941c
Created June 28, 2017 05:57
Bash command for install npm peer dependencies
(
export PKG=eslint-config-react-app;
npm info "$PKG@latest" peerDependencies --json | command sed 's/[\{\},]//g ; s/: /@/g' | xargs sudo npm -g install --save-dev "$PKG@latest"
)
@ashgaliyev
ashgaliyev / Selective_Walker
Created November 15, 2014 11:10
Selective_Walker
class Selective_Walker extends Walker_Nav_Menu
{
function walk( $elements, $max_depth) {
$args = array_slice(func_get_args(), 2);
$output = '';
if ($max_depth < -1) //invalid parameter
return $output;
@ashgaliyev
ashgaliyev / cutom_metabox
Last active August 29, 2015 14:07
Custom post types & taxonomy metabox snippet
/*
In case if we need to define custom post types manually
*/
/*
Define constants at first for avoid hidden errors while working with custom post types
*/
if ( !defined( 'POST_TYPE_PRODUCT' ) ) define( 'POST_TYPE_PRODUCT', 'product');
if ( !defined( 'POST_TYPE_ORDER' ) ) define( 'POST_TYPE_ORDER', 'product_order');
if ( !defined( 'TAXONOMY_CATEGORY' ) ) define( 'TAXONOMY_CATEGORY', 'product_cat');