Skip to content

Instantly share code, notes, and snippets.

View genakim's full-sized avatar

Gennadiy Kim genakim

  • Uzbekistan, Tashkent city
View GitHub Profile
@genakim
genakim / SameParity.php
Created November 7, 2019 06:59
[Новый массив, состоящий из элементов, у которых такая же чётность, как и у первого элемента входного массива] #algorithm
<?php
function getSameParity($coll)
{
if (empty($coll)) {
return [];
}
$result = [];
$remainder = $coll[0] % 2;
<template>
<tree-item :nodes="nodes"></tree-item>
</template>
<script>
export default {
props: ['items'],
data() {
return {
nodes: []
<template>
<ul :class="parentClass">
<li v-for="node in nodes" :class="childClass">
<a href="/">{{node.name}}</a>
<tree-item v-if="node.children.length" :nodes="node.children" :isSub="true"></tree-item>
</li>
</ul>
</template>
<script>
@genakim
genakim / procedure.sql
Last active May 12, 2020 19:33
Пример процедуры на MySQL с использование цикла и условий
create
definer = root@`::1` procedure PublicIntoStatuses(IN dateFrom varchar(255), IN dateTo varchar(255),
IN comment varchar(20))
comment 'Процедура вставки в статусы общ. работ. Создает все недостающие статусы'
BEGIN
DECLARE vServiceLogId int;
DECLARE vServiceTypeId int;
DECLARE vServiceId int;
DECLARE vResult varchar(50);
DECLARE vPersonId int;
@genakim
genakim / function.sql
Created May 12, 2020 19:36
Пример функции MySQL
create
definer = root@`::1` function updatePublicWorksDate(serviceLogId int, date date, dateId varchar(255)) returns date
BEGIN
IF (dateId = 'REFERRAL_DATE') THEN
UPDATE m_service_public_works mspw
SET mspw.REFERRAL_DATE = date
WHERE mspw.SERVICE_LOG_ID = serviceLogId;
END IF;
@genakim
genakim / builder.php
Created May 22, 2020 04:47 — forked from ollieread/builder.php
Laravel query builder recursive CTE support
<?php
$recursive = $this->query()
->recursive('parents', function (Builder $query) {
$query
->select([
'*',
new Alias('slug', 'fullslug'),
new Alias(0, 'depth'),
new Alias('id', 'tree_id'),
new Alias('name', 'path'),
@genakim
genakim / paginate.js
Last active June 9, 2020 15:58
Логика пагинации (laravel + vuejs)
this.pages = [];
const pages = 5;
const currentPage = this.data.current_page;
const totalPages = this.data.last_page;
const offSide = Math.floor(pages / 2);
// первая страница
let startPage = currentPage - offSide;
if (startPage <= 1) {
startPage = 1;
@genakim
genakim / install-nginx-with-phpbrew.sh
Created December 22, 2020 08:43 — forked from abenevaut/# Install nginx & phpbrew 7.3.10.md
Install brew nginx with phpbrew php-fpm 7.3.10 on macOS (this installation allows to run nginx and php-fpm (from phpbrew) as root but chrooted with the current user - take care if there is multiple developper account on mac, that will potentially make trouble between accounts).
// First follow https://gist.github.com/abenevaut/fd21704ead845e5bc14ca93fa8d0a18f but modify the line 17 like follow
// add +fpm to compile php-fpm
phpbrew --debug install php-7.3.10 +gd +default +sqlite +mysql +fpm +bz2=/usr/local/Cellar/bzip2/1.0.6_1/ +zlib=/usr/local/Cellar/zlib/1.2.11/ -- --with-gd=shared
brew install nginx
sudo emacs /usr/local/etc/nginx/nginx.conf
sudo emacs /Users/YOUR_MACOS_USERNAME/.phpbrew/php/php-7.1.29/etc/php-fpm.d/www.conf
// In previous config files, we set user and group to run nginx and php-fpm as setted user and user group (logic)..
@genakim
genakim / phpbrew-config.md
Created December 22, 2020 08:43 — forked from goodjack/phpbrew-config.md
How to use switch PHP(using phpbrew) version in nginx config
php -v
PHP 5.6.3 (cli) (built: Oct 28 2015 09:47:41)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2014 Zend Technologies

But this only changes in CLI. You have to tweak you nginx(same for apache) to make it works. Nginx will still using the native PHP-FPM.

> ps aux | grep php-fpm
diff --git a/app/functions/fn.features.php b/app/functions/fn.features.php
index b06227e6b9..31b49f1714 100644
--- a/app/functions/fn.features.php
+++ b/app/functions/fn.features.php
@@ -185,7 +185,19 @@ function fn_update_product_features_value($product_id, $product_features, $add_n
)
) {
$value = empty($value) ? [] : $value;
- $value[] = fn_update_product_feature_variant($feature_id, $feature_type, $add_new_variant[$feature_id], $lang_code);
+ $variant = $add_new_variant[$feature_id]['variant'];