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 / foldersize.php
Created June 28, 2021 06:03 — forked from eusonlito/foldersize.php
PHP function to get the folder size including subfolders
<?php
function folderSize ($dir)
{
$size = 0;
foreach (glob(rtrim($dir, '/').'/*', GLOB_NOSORT) as $each) {
$size += is_file($each) ? filesize($each) : folderSize($each);
}
@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
@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 / 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 / GROUP_MAXIMUM.SQL
Created September 13, 2019 10:06 — forked from hackimov/GROUP_MAXIMUM.SQL
#SQL #MAXIMUM #WITHOUT_GROUP_BY #SPEED #QUERY
SELECT maintable.*
FROM TABLE_NAME maintable
LEFT OUTER JOIN TABLE_NAME temporarytable
ON maintable.GROUPING_BY_COLUMN = temporarytable.GROUPING_BY_COLUMN
AND maintable.COLUMN_WHERE_THE_MAXIMUM_IS_NEEDED < temporarytable.COLUMN_WHERE_THE_MAXIMUM_IS_NEEDED
WHERE temporarytable.COLUMN_WHERE_THE_MAXIMUM_IS_NEEDED IS NULL
ORDER BY PRIMARY_KEY_COLUMN DESC
LIMIT 50;
# Step 1 - install java 1.8
yum install java-1.8.0-openjdk.x86_64
# Step 2 - install jmeter 3.2
curl https://archive.apache.org/dist/jmeter/binaries/apache-jmeter-3.2.tgz > $HOME/apache-jmeter-3.2.tgz
tar -xvzf $HOME/apache-jmeter-3.2.tgz
ln -s $HOME/apache-jmeter-3.2 $HOME/jmeter
# Step 3 - add to your path in ~/.bashrc
export JMETER_HOME=$HOME/jmeter

Download Vagrant boxes manually

In this example, we're going to download the Midnight Sun box.

# The box URL is https://app.vagrantup.com/uwmidsun/boxes/box/versions/2.1.0
# In general, we just take the box URL, and then append the provider URL
# https://app.vagrantup.com/<organization name>/boxes/<box name>/versions/<version>/providers/<provider>.box
wget https://app.vagrantup.com/uwmidsun/boxes/box/versions/2.1.0/providers/virtualbox.box -O box-2.1.0.box
@genakim
genakim / README.md
Created May 30, 2019 09:29 — forked from sameoldmadness/README.md
Нагрузочное тестирование c Yandex.Tank и JMeter

Нагрузочное тестирование c Yandex.Tank и JMeter

На этой странице описывается процесс настройки нагрузочного тестирования внешних ресурсов.

Кратко

Для тестирования поведения сервиса под нагрузкой используется утилита Yandex Tank.

Танку можно указать патроны (HTTP-запросы, которые будут отправлены на целевой сервер) и расписание (количество запросов в секунду к целевому серверу в каждый момент времени стрельб, а также продолжительность стрельб). Также к танку можно подключить плагин мониторинга, позволяющий снимать показатели (например, количество свободной памяти или загрузку процессора) с целевого сервера.

@genakim
genakim / Instructions.sh
Created March 30, 2019 20:07 — forked from GhazanfarMir/Instructions.sh
Install PHP7.2 NGINX and PHP7.2-FPM on Ubuntu 16.04
########## Install NGINX ##############
# Install software-properties-common package to give us add-apt-repository package
sudo apt-get install -y software-properties-common
# Install latest nginx version from community maintained ppa
sudo add-apt-repository ppa:nginx/stable
# Update packages after adding ppa
@genakim
genakim / gist:48dd144434e315e8ae3bd3f40594cace
Created January 23, 2019 11:35 — forked from davepoon/gist:4371622
Added the .gitignore, and refresh the file index so the files get ignored properly.
git rm -r --cached .
git add .
git commit -m ".gitignore is now working"