Skip to content

Instantly share code, notes, and snippets.

View a-ast's full-sized avatar

Andrey Astakhov a-ast

  • Berlin, Germany
View GitHub Profile
@a-ast
a-ast / DataImportBusinessFactory.php
Last active December 5, 2017 19:31
Spryker DataImport: implement XmlDataReader
<?php
// DataImportBusinessFactory.php
protected function createGlossaryImporter()
{
$dataImporterConfigurationTransfer = $this->getConfig()->getGlossaryDataImporterConfiguration();
$xmlReader = new XmlDataReader($dataImporterConfigurationTransfer->getReaderConfiguration()->getFileName());
$dataImporter = $this->createDataImporter($dataImporterConfigurationTransfer->getImportType(), $xmlReader);
@a-ast
a-ast / DataImportBusinessFactory.php
Last active October 4, 2017 07:37
Spryker DataImport: implement data step
<?php
namespace Pyz\Zed\DataImport\Business;
use Pyz\Zed\AkeneoConnector\Business\Model\Attribute\YourWriterStep;
use Spryker\Zed\DataImport\Business\Model\DataImporterInterface;
use Spryker\Zed\DataImport\Business\DataImportBusinessFactory as SprykerDataImportBusinessFactory;
use Spryker\Zed\DataImport\Business\Model\DataSet\DataSetStepBrokerInterface;
/**
@a-ast
a-ast / LoggerConfig-LineFormatter.php
Last active December 5, 2017 19:59
Spryker DataImport: Add logging to console
<?php
protected function createStreamHandler(): HandlerInterface
{
$handler = new StreamHandler('php://stdout', Logger::INFO);
$formatter = new LineFormatter("\033[1;30m%datetime%\e[0m %message%" . PHP_EOL, 'H:i:s');
$handler->setFormatter($formatter);
return $handler;

CoderDojo Berlin

CoderDojo ist ein Club für Kinder und Jugendliche im Alter von 5 bis 17 Jahren, die programmieren lernen und Spaß haben wollen. Freiwillige Mentor_innen helfen den Kindern, ihre Ideen umzusetzen. Dabei lernen sie spielerisch die Grundlagen des Programmierens. Und auch wenn sie die Grundlagen schon kennen, gibt es noch mehr als genug neue Konzepte zu lernen.

Wann / Wo

Wir treffen uns einmal im Monat, jedesmal woanders. Den nächsten Termin und Ort findest du immer hier: http://bit.ly/coderdojoberlin

Ablauf

@a-ast
a-ast / services.yml
Created January 2, 2017 14:15
Github client with plugins services
services:
# Custom plugin
github_api.plugin.wait_and_retry:
class: AppBundle\Client\Github\WaitAndRetryPlugin
# Bundled plugin
github_api.plugin.authentication:
class: Github\HttpClient\Plugin\Authentication
arguments:
- '%env(GITHUB_CLIENT_ID)%'
@a-ast
a-ast / GithubApiClientWithCaching.php
Last active December 30, 2016 23:41
How to use Github API Client with request/response caching
<?php
use Github\Client;
use Github\HttpClient\Builder;
use Symfony\Component\Cache\Adapter\FilesystemAdapter;
$httpBuilder = new Builder();
$httpBuilder->addCache(new FilesystemAdapter('', 0, 'var/http-cache'));
$client = new Client($httpBuilder);
@a-ast
a-ast / Configuration.php
Created December 12, 2016 15:31
Symfony: use semantic configuration combining yml and xml configuration files
<?php
// src/AppBundle/DependencyInjection/Configuration.php
namespace AppBundle\DependencyInjection;
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\ConfigurationInterface;
class Configuration implements ConfigurationInterface
{% extends 'base.html.twig' %}
{# Set a theme for the whole form #}
{% form_theme form 'bootstrap_3_layout.html.twig' %}
{# Set a theme for the country field #}
{% form_theme form.country 'bootstrap_3_horizontal_layout.html.twig' %}
{{ form_start(form) }}
{{ form_widget(form) }}
{{ form_end(form) }}
@a-ast
a-ast / FixtureAwareTestCase.php
Created May 2, 2016 12:23
Load doctrine fixtures before test
<?php
use Doctrine\Common\DataFixtures\Executor\ORMExecutor;
use Doctrine\Common\DataFixtures\FixtureInterface;
use Doctrine\Common\DataFixtures\Purger\ORMPurger;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bridge\Doctrine\DataFixtures\ContainerAwareLoader;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
abstract class FixtureAwareTestCase extends KernelTestCase
@a-ast
a-ast / Doctrine merge examples
Created April 22, 2016 08:38
Doctrine merge examples
public function test_merge_listing()
{
$listingContact = new ListingContact();
$listingContact
->setId(3)
->setEmail('new333@new.333new')
->setMobilePhonePrefix('01578');
$listing = new Listing();
$listing