Skip to content

Instantly share code, notes, and snippets.

View PromisePlus.php
<?php
use GuzzleHttp\Promise\Promise;
use GuzzleHttp\Promise\PromiseInterface;
/**
* Guzzle promise, which can get few params to functions and return few values.
*
* Class PromisePlus
*/
View gist:54e7d9e0c090e05a37d0b2c3abe0392d
find ./ -name "*.jpg" -size +600k -printf '%p %s ' //find images bigger than 600Kb
find ./ -name "*.jpg" -size +800k -exec convert -resize 1920x {} {} \; //resize images
find ./ -name "*.jpg" -size -330k -exec jpegoptim --all-progressive --strip-all '{}' \; //progressive optimization
find ./ -name "*.jpg" -size +330k -exec jpegoptim -S 330K --all-progressive --strip-all '{}' \; //max size 330K
@zhernosekim
zhernosekim / code.js
Created Sep 19, 2018
Копирование стиля с одного элемента на другой Copying style from one element to another
View code.js
/*
mainElement - the element from which we copy styles
secondElement - element to which we apply styles
Code works similar in Chrome and Firefox. I haven't tested it in Safary
*/
//If button is hidden, styles are copying badly. So we show main element
var display = mainElement.style.display;
mainElement.style.cssText = 'display:block!important';
@zhernosekim
zhernosekim / Install_WebStorm.sh
Last active Oct 2, 2018 — forked from almirb/Install_Phpstorm.sh
Update webstorm on Ubuntu linux.
View Install_WebStorm.sh
#!/bin/bash -e
# Original credits to theodorosploumis
# IMPORTANT. My webstorm installation exists on /opt/webstorm.
if [ "$(whoami)" != "root" ]
then
echo "Sorry, you are not root."
exit 1
fi
View gist:099fbb203c70a0e3a1ae6f331bd16c3b
vhost_alias - модуль для апача. установить включить
dnsmasq установить
создать /etc/dnsmasq.d/local.com.conf с текстом address=/local.com/127.0.0.1
В конфиг апача:
<VirtualHost *:80>
UseCanonicalName Off
View gist:5d3aef4f609000a6a8db0ac79760bf8f
Всякие полезные команды
0 4 * * * mysqldump -uroot -p database --ignore-table=database.core_url_rewrite | gzip > `date +database.%Y%m%d.%H%M%S.sql.gz`
0 4 * * * find /backups -type f -mtime +30 -print0 | xargs -0 rm -f
tar -pczvf archive.tar.gz --exclude={'*.avi','*.jpg','*.png','*.jpeg','*.gif'} /path/to/dir
sed -ie 's/ROW_FORMAT=FIXED//g' newdump.sql
select * from cron_schedule where created_at like '2017-05%' GROUP BY job_code
Найти базу и скопировать из огромного файла:
sed -n '/^-- Current Database: `itspurt_shopify_instockreminder`/,/^-- Current Database: `/p' 2016-03-01.sql > isr2016-03-01.sql
@zhernosekim
zhernosekim / gist:41dc95c2184db5f65695f1092599a5bb
Last active Jan 17, 2017
Creating and dropping foreign keys
View gist:41dc95c2184db5f65695f1092599a5bb
/**
* Скрипт создания форейн ключа $foreignKey в таблице $table1 на таблицу $table2.
*
* -Получаем все элементы таблицы1 и таблицы2.
* -Перебираем циклом элементы таблицы1 и проверяем существуют ли они в таблице2.
* -Если элемент в таблице2 не существует, удаляем ссылку на него из таблицы1.
* -Создаем форейн ключ в таблице1.
*/
function validateTableAndCreateForeignKey($table1, $table2, $foreignKey)
{
@zhernosekim
zhernosekim / create_host.sh
Created Dec 20, 2016
Create host for laravel-project for Ubuntu.
View create_host.sh
#!/bin/bash
#Create project folders first. Than run this script
parametr1=$1
projectPath=/home/userName/PhpstormProjects
cp /etc/nginx/example.conf /etc/nginx/conf.d/$parametr1.conf
rpl -iqR example $parametr1 /etc/nginx/conf.d/$parametr1.conf
sed -i -e '1 s/^/127.0.0.1 '$parametr1'.local\n/;' /etc/hosts
service nginx restart
chown www-data $projectPath/$parametr1/bootstrap/cache/
View gist:a72ea944f1fb7daebbee9bbcefb97399
// Step 1. Create this class in the middleware folder (/app/Http/Middleware).
<?php
namespace App\Http\Middleware;
use Closure;
class BeforeAutoTrimmer {