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
@IvanAlekseevichPopov
IvanAlekseevichPopov / copy.bash
Created April 25, 2017 05:25
fast copy bash
cp /home/user1/myfile123456789.txt{,-new}
и обратно:
cp /home/user1/myfile123456789.txt{-new,}
@IvanAlekseevichPopov
IvanAlekseevichPopov / delete.php
Created May 15, 2017 13:38
QueryBuilder delete example
<?php
$qb
->delete(ProductImage::class, 'i')
->where($qb->expr()->in('i.oldId', ':ids'))
->setParameter('ids', $outDatedIds)
->getQuery()
->execute();
@IvanAlekseevichPopov
IvanAlekseevichPopov / 1.bash
Created September 4, 2017 10:41
get docker container ID from inside container
cat /proc/self/cgroup | grep -o -e "docker-.*.scope" | head -n 1 | sed "s/docker-\(.*\).scope/\\1/"
@IvanAlekseevichPopov
IvanAlekseevichPopov / 1.html
Created September 25, 2017 06:04
loading animation in button
<div style="margin:3em;">
<button type="button" class="btn btn-primary btn-lg " id="load" data-loading-text="<i class='fa fa-circle-o-notch fa-spin'></i> Processing Order">Submit Order</button>
<br>
<br>
<button type="button" class="btn btn-primary btn-lg" id="load" data-loading-text="<i class='fa fa-spinner fa-spin '></i> Processing Order">Submit Order</button>
</div>
@IvanAlekseevichPopov
IvanAlekseevichPopov / install.sh
Created October 5, 2017 07:58
install latest docker comunity edition
curl -fsSL get.docker.com -o get-docker.sh; sh get-docker.sh
@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);
@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 / 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 / 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]
)
<?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;