Skip to content

Instantly share code, notes, and snippets.

View alongosz's full-sized avatar

Andrew Longosz alongosz

View GitHub Profile
@alongosz
alongosz / ez_rest_io.md
Created February 8, 2019 11:20
eZ Platform REST XML Schemas Input/Output
Schema Input/Output
Common Definitions Input/Output
Root Resources Output
Content Output
Relation Output
Version Output
VersionInfo Output
VersionList Output
VersionUpdate Input
@alongosz
alongosz / fixstagedcode.sh
Created June 27, 2018 07:48
Applies php-cs-fixer to the code staged for commit
#!/bin/bash
#
# Copyright (c) 2017 - 2018, Andrew Longosz
#
files=$(git diff --cached --name-only --diff-filter=ACMRTU|grep '.php$'|paste -sd ' ' -)
echo "Fixing new and/or modified files: $files"
php-cs-fixer -v --config=.php_cs fix $files
@alongosz
alongosz / ezUpdateFieldDefDefaultValue.php
Created April 12, 2018 12:40
eZ Platform - update FieldDefinition Default Value
<?php
use eZ\Publish\Core\Base\Exceptions\ContentTypeFieldDefinitionValidationException;
use eZ\Publish\Core\FieldType\Country\Value as CountryValue;
$countryContentType = $contentTypeService->loadContentTypeByIdentifier('country_t');
$countryFieldDefinition = $countryContentType->getFieldDefinition('country');
$countryFieldType = $fieldTypeService->getFieldType(
$countryFieldDefinition->fieldTypeIdentifier
);
@alongosz
alongosz / resolveAssetUrl.php
Created February 5, 2018 13:20
eZ Design namespace for assets
<?php
/**
* Resolve Asset URL optionally prefixed with package name.
*
* @param string $path Asset URL
*
* @return string
*/
@alongosz
alongosz / parameters.yaml
Created September 8, 2017 09:01
eZ Platform Solr parameters.yml
parameters:
# ... other stuff
search_engine: solr
solr_dsn: 'http://localhost:8983/solr'
@alongosz
alongosz / PR_2051_DefaultRouter.php
Created July 18, 2017 09:43
eZ\Bundle\EzPublishCoreBundle\Routing\DefaultRouter::generate suggestion
<?php
try {
$url = parent::generate($name, $parameters, $referenceType);
// Now putting back SiteAccess URI if needed.
if ($isSiteAccessAware && $siteAccess && $siteAccess->matcher instanceof URILexer) {
if ($referenceType === self::ABSOLUTE_URL || $referenceType === self::NETWORK_PATH) {
$scheme = $context->getScheme();
$port = '';
@alongosz
alongosz / fastcgi.conf
Created July 1, 2017 12:18
Apache2 php-fpm 7.1 as fastcgi configuration
<IfModule mod_fastcgi.c>
AddType application/x-httpd-fastphp7 .php
Action application/x-httpd-fastphp7 /php7-fcgi
Alias /php7-fcgi /usr/lib/cgi-bin/php7-fcgi
FastCgiExternalServer /usr/lib/cgi-bin/php7-fcgi -socket /var/run/php7-fpm.sock -pass-header Authorization
<Directory /usr/lib/cgi-bin>
Require all granted
</Directory>
</IfModule>
@alongosz
alongosz / pre-commit.py
Last active November 22, 2017 16:23
[Python][Git] php-cs-fixer Git pre-commit hook
#!/usr/bin/env python
#
# by @Nattfarinn, improved by @alongosz
# Requires php-cs-fixer executable
# Place it in your repository, in .git/hooks/pre-commit
import sys
import subprocess
process = subprocess.Popen(['git', 'diff', '--cached', '--name-only', '--diff-filter=ACMRT'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
@alongosz
alongosz / SfConsoleDisplayDbTable.php
Last active June 22, 2017 15:11
Display database table contents using Symfony Table helper and Doctrine\DBAL\Connection
/**
* @param \Doctrine\DBAL\Connection $connection
* @param string $table db table name
* @param array $predicates
*/
private function displayDbTable(\Doctrine\DBAL\Connection $connection, $table, array $predicates = [])
{
$query = $connection->createQueryBuilder();
$query
->select('*')
@alongosz
alongosz / 0_reuse_code.js
Created May 27, 2016 09:59
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console