Skip to content

Instantly share code, notes, and snippets.

View IvanAlekseevichPopov's full-sized avatar
🏠
Working from home

Ivan Alekseevich Popov IvanAlekseevichPopov

🏠
Working from home
  • Saint-Petersburg Russia
View GitHub Profile
sudo os-prober
grub2-mkconfig -o /boot/efi/EFI/fedora/grub.cfg
+ * @Assert\Choice(callback={IepBundle\Enum\StudentSelectionStates::class, "getValues"})
@IvanAlekseevichPopov
IvanAlekseevichPopov / repo.php
Created June 18, 2018 13:33
doctrine join with on other side of unidirectional relation
<?php
$qb = $this->createQueryBuilder('country');
return $qb
->join(Source::class, 'source', Join::WITH, 'source.country = country')
->getQuery()
->getResult();
@IvanAlekseevichPopov
IvanAlekseevichPopov / gist:187d3701f02f56d3cd75fbdc6f5308e9
Last active January 27, 2019 12:55
Docker под мак с нормальной скоростью работы
1) Скачать `docker`, в состав входит `docker-machine`
2) Скачать `virtualbox`, но есть и другие способы
3) Запустить `docker-machine create NAME`
4) Поставить nfs для более быстрой синхронизации через `docker-machine-nfs NAME`, пакет можно скачать через brew
5) Экспортировать в окружение переменные машины, которые можно получить через `docker-machine env NAME`
6) Запустить `docker-compose up`
7) В хостам вместо `127.0.0.1` указать ip машины
8) Следовать дальнейшей инструкции
`VBoxManage modifyvm "VM name" --natdnshostresolver1 on
<?php
class CustomsStatisticsController {
/**
* @SWG\Response(
* response=200,
* description="Returns customs statistics list joined by tnved",
* @Model(type=\App\Form\Model\View\CustomStatisticsListView::class)
*/
<?php
declare(strict_types=1);
namespace App\Form\Model;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\HttpFoundation\File\File;
@IvanAlekseevichPopov
IvanAlekseevichPopov / repo.php
Last active April 17, 2018 15:23
in query with array as parameter
use Doctrine\DBAL\Connection;
...
return $this
->getEntityManager()
->getConnection()
->executeQuery(
'SELECT * from posts WHERE id IN (?)',
[$postIdCollection],
[Connection::PARAM_INT_ARRAY]
)
@IvanAlekseevichPopov
IvanAlekseevichPopov / query.php
Created March 27, 2018 08:26
Doctrine query with unidirectional reverse side join
use Doctrine\ORM\Query\Expr\Join;
//...
//Many Sources has one country
$qb = $this->createQueryBuilder('country');
return $qb
->join(Source::class, 'source', Join::WITH, 'source.country = country')
->getQuery()
->getResult();
@IvanAlekseevichPopov
IvanAlekseevichPopov / main.go
Created December 22, 2017 16:14
sessions example with concurency
package main
import (
"fmt"
"sync"
)
type userSession struct {
sync.Mutex
userID int64
@IvanAlekseevichPopov
IvanAlekseevichPopov / SomeRepository.php
Created December 21, 2017 14:40
How bind IN () in PDO. And using FETCH_UNIQUE same time!
return $this
->getEntityManager()
->getConnection()
->executeQuery(
"SELECT id, concat(first_name, ' ', last_name) name, avatar FROM profiles WHERE id IN (?)",
[$userIds],
[Connection::PARAM_INT_ARRAY]
)
->fetchAll(\PDO::FETCH_UNIQUE);