Skip to content

Instantly share code, notes, and snippets.

@zim32
zim32 / gist:5a8e6c7c2127f7e91863543fda05f39b
Created August 9, 2022 14:13
Doctrine trait for handling associations
<?php
namespace Zim\Bundle\SymfonyRestHelperBundle\Doctrine;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
trait ORMSetterTrait
{
/**
@zim32
zim32 / tick-sequence.js
Created July 19, 2022 17:57
Vue js hook to queue callbacks and execute then one by one, one callback in one tick
const queue = []
let canExecuteThisTick = true
import {nextTick} from 'vue'
export function useTickSequence() {
const processQueue = () => {
if (canExecuteThisTick) {
canExecuteThisTick = false
}
@zim32
zim32 / gist:807c2d409f9b12140159766d9c51cdeb
Created April 27, 2018 13:27
Fix PHP datetime time zone.
$wrongDate = new \DateTime('2018-04-25 16:00:00', new \DateTimeZone('+0300'));
// Wed, 25 Apr 2018 16:00:00 +0300
fixZone($wrongDate, new \DateTimeZone('UTC'));
// Wed, 25 Apr 2018 16:00:00 +0000
function fixZone(\DateTime $dateTime, DateTimeZone $rightZone)
{
$offset = $dateTime->getOffset();
$zoneOffset = $rightZone->getOffset($dateTime);