Skip to content

Instantly share code, notes, and snippets.

View daylik's full-sized avatar

Олег Мешаев daylik

  • Санкт-Петербург
View GitHub Profile
@daylik
daylik / isset_get.js
Created November 4, 2020 12:08
JavaScript isset_get - test function, return variable
function isset_get(v){
if(typeof v === 'undefined'){
return '';
} else if( typeof v === 'object' && v === null || typeof v === 'object' && Object.keys(v).length === 0){
return '';
} else if( v instanceof Array && v.length === 0){
return '';
} else if (typeof v === 'number' && isNaN(v)){
return '';
}
@daylik
daylik / isset.js
Last active November 4, 2020 12:09
JavaScript isset test function
function isset(v){
if(typeof v === 'undefined'){
return false;
} else if( typeof v === 'object' && v === null || typeof v === 'object' && Object.keys(v).length === 0){
return false;
} else if( v instanceof Array && v.length === 0){
return false;
} else if (typeof v === 'number' && isNaN(v) ){
return false;
}
wp_enqueue_style( 'style', get_template_directory_uri() . '/style.css', array(), filemtime( get_theme_file_path('/style.css')) );
wp_enqueue_script( 'app', get_template_directory_uri() . '/js/app.js', array(), filemtime( get_theme_file_path('/js/app.js')), true );
# Fail2ban configuration file
#
# Author: zEvilz <zevilz13@yandex.ru>
#
[INCLUDES]
before = iptables-common.conf
[Definition]
#!/bin/bash
dr=$1
set_user=$2
set_group=$3
zDir="latest-ru_RU.zip"
wpInstall="https://ru.wordpress.org/"$zDir
eval "mkdir -p "$dr" && cd "$dr" && wget "$wpInstall" && unzip "$zDir" && cp -r "$dr"/wordpress/* "$dr" && rm -rf "$dr"/wordpress && rm -f -r "$zDir" && chown -R "$set_user":"$set_group" "$dr" && find "$dr" -type d -exec chmod 0755 {} \; && find "$dr" -type f -exec chmod 0644 {} \; && echo WordPress installation in directory "$dr" is done. "
global.timer_start = {}; //if browser replace all to window.timer_start
const jr = { //if browser js replace 'const' to 'var'
timer: {
start: function(timer_name) {
global.timer_start[timer_name] = new Date().getTime();
},
stop: function(timer_name) {
var timer_stop = new Date().getTime();
var out = timer_stop - global.timer_start[timer_name];
function each_table_td( selector, td_num, find_regexp, replace_regexp, replace_mask, _e){
_e = {};
$( selector ).each(function(index_1, el) {
_e.num = 0;
$(el).find('tr td').each(function(index_2, el_2) {
_e.num++;
if ( (_e.num % td_num) === 0) {
_e.td = $(this).html();
//$(this).addClass('this_test');
if (find_regexp.test(_e.td)){
<?php
//### STYLES
function include_style( $style_name, $file, $array = '', $is_child){
if( $is_child || $is_child == 'child'){
$file_uri = get_stylesheet_directory_uri() . $file;
$file_path = get_stylesheet_directory() . $file;
} else {
$file_uri = get_template_directory_uri() . $file;
$file_path = get_template_directory() . $file;
function find_replace(selector, attr, find, replace, v){
v = {};
$(selector).each(function(){
v.img_src = $(this).attr(attr);
v.out = v.img_src.replace(find, replace);
$(this).attr(attr, v.out);
});
}
find_replace('img', 'src', /site.ru/i, '127.0.0.1');
<?php
$currentCatId = '1,2';
function is_var_ok( $var, $reg ){
if(isset($reg)){
$is_filter_ok = $reg;
} else {
$is_filter_ok = '#^[0-9,\s]+$#'; //проверка на вхождения в струку только 0-9 запятой и пробелов