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 / Symfony-eZPublish: Set permissions for project files
Last active August 29, 2015 14:20
Symfony/eZPublish: Set permissions for project files
# Set permissions for project files
sudo setfacl -R -m u:www-data:rwX -m u:`whoami`:rwX /var/www/project/
sudo setfacl -dR -m u:www-data:rwX -m u:`whoami`:rwX /var/www/project/
@a-ast
a-ast / MySQL clone database
Created June 1, 2015 14:30
MySQL clone database
# Created database to be cloned
mysql -u [user] -p -e "create database [destination_database] character set utf8;"
# Backup database with compression
mysqldump -h localhost -u [user] -p --quick [source_database] | gzip > [backup_file]
# Uncompress and restore database
gunzip -c [backup_file] | mysql -u [user] -p [destination_database]
@a-ast
a-ast / gist:e7e059eccfae8f04edf0
Created July 14, 2015 10:55
eZ Publish: How to generate url alias form location or location id
$router = $this->container->get('router');
$url = $router->generate(
$targetLocation,
array(
'siteaccess' => ...
), // it is possible to pass another siteaccess here
UrlGeneratorInterface::ABSOLUTE_URL
);
@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
@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
{% 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 / 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
@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 / 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)%'

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