Skip to content

Instantly share code, notes, and snippets.

@Arbagen
Arbagen / BulkInsertQuery.php
Created December 11, 2020 14:12 — forked from gskema/BulkInsertQuery.php
PHP PDO / Doctrine DBAL bulk insert query
<?php
namespace YourApp\Repository\Query;
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Schema\Identifier;
/**
* Class BulkInsertQuery
*
ARG INSTALL_XDEBUG=true //instal?
ARG XDEBUG_REMOTE_HOST=dockerhost // linux 172.17.0.1
ARG XDEBUG_VERSION=2.7.2 //version for php
RUN if [ ${INSTALL_XDEBUG} = true ]; then \
pecl install xdebug-${XDEBUG_VERSION} && docker-php-ext-enable xdebug \
&& echo "xdebug.remote_port=9000" >> /usr/local/etc/php/conf.d/xdebug.ini \
&& echo "xdebug.remote_enable=1" >> /usr/local/etc/php/conf.d/xdebug.ini \
&& echo "xdebug.remote_autostart=1" >> /usr/local/etc/php/conf.d/xdebug.ini \
&& echo "xdebug.remote_connect_back=0" >> /usr/local/etc/php/conf.d/xdebug.ini \
&& echo "xdebug.max_nesting_level=500" >> /usr/local/etc/php/conf.d/xdebug.ini \
@Arbagen
Arbagen / email regex
Last active October 26, 2018 08:46
email regex
^([a-z0-9\+_\-]+)(\.[a-z0-9\+_\-]+)*@([a-z0-9\-]+\.)+[a-z]{2,6}
@Arbagen
Arbagen / vim macros
Created May 18, 2018 08:10
vim macros
To enter a macro, type:
q<клавиша a-Z><делаешь какие то действия>q
в режиме команд
To execute the macro <number> times (once by default), type:
<кол-во раз>@<клавишу на которую забиндил>
@Arbagen
Arbagen / gist:f5c705ce0e9b5f140e368616b5ce2ea5
Created March 12, 2018 09:46
mysql update random string (8 chars)
UPDATE table SET field = LEFT(UUID(), 8);
@Arbagen
Arbagen / xdebug in docker and phpstorm
Last active January 15, 2018 10:27
xdebug in docker and phpstorm
важно что бы в php.ini было:
xdebug.remote_host=dockerhost
xdebug.remote_enable = 1
xdebug.remote_port = 9000
xdebug.max_nesting_level = 500
xdebug.remote_autostart=1
xdebug.remote_connect_back=1
а в docker-compose экспортнуть переменную PHP_IDE_CONFIG
services:
php:
unzip -p dump.zip | mysql -h 127.0.0.1 -P 3306 -u root -p projects_ndb
@Arbagen
Arbagen / pdo connection
Created May 24, 2017 14:33
php true pdo connection
$host = '127.0.0.1';
$db = 'test';
$user = 'root';
$pass = '';
$charset = 'utf8';
$dsn = "mysql:host=$host;dbname=$db;charset=$charset";
$opt = [
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
@Arbagen
Arbagen / xdebug.md
Created May 23, 2017 09:34
install xdebug

🪲 Install and Configure xDebug on Ubuntu and Php Storm 🐘

  • Assuming that you have already installed php and apache
  • Install xDebug php extension
# Ubuntu 16.04, php 7.0
sudo apt-get install php-xdebug
# Ubuntu 14.04, php 5.6 
sudo apt-get install php5-xdebug
@Arbagen
Arbagen / solution
Created May 3, 2017 19:36
phpmyadmin HTTP ERROR 500
sudo apt-get install php-mbstring php7.0-mbstring php-gettext