Skip to content

Instantly share code, notes, and snippets.

View mRoca's full-sized avatar
:octocat:
wip

Michel Roca mRoca

:octocat:
wip
  • Freelance
  • Paris
View GitHub Profile
@mRoca
mRoca / EntityNormalizer.php
Last active December 21, 2015 15:46
EntityNormalizer - Max Depth
<?php
namespace AppBundle\JsonLd\Serializer;
use Dunglas\ApiBundle\Api\IriConverterInterface;
use Dunglas\ApiBundle\Api\ResourceCollectionInterface;
use Dunglas\ApiBundle\JsonLd\ContextBuilder;
use Dunglas\ApiBundle\JsonLd\Serializer\ItemNormalizer;
use Dunglas\ApiBundle\Mapping\ClassMetadataFactoryInterface;
use Symfony\Component\PropertyAccess\PropertyAccessorInterface;
@mRoca
mRoca / Makefile
Last active December 11, 2015 16:23
ng-admin sources
WWW_IP := $(shell docker inspect --format '{{ .NetworkSettings.IPAddress }}' $(shell docker-compose ps -q www))
EXEC_WWW=docker exec -ti $(shell docker-compose ps -q www)
NGADMIN_SERVER_URL?=$(WWW_IP)
serve-ngadmin:
if [ ! -d .tmpsrc/ng-admin ]; then git clone git@github.com:marmelab/ng-admin.git .tmpsrc/ng-admin; fi
$(EXEC_WWW) bash -c "cd .tmpsrc/ng-admin && make install"
$(EXEC_WWW) bash -c "sed -i 's/..\/bower_components\/ng-admin\//http:\/\/$(NGADMIN_SERVER_URL):8000\//g' .tmp/serve/index.html"
$(EXEC_WWW) bash -c "sed -i 's/http:\/\/localhost/http:\/\/$(NGADMIN_SERVER_URL)/g' .tmpsrc/ng-admin/examples/blog/index.html"
$(EXEC_WWW) bash -c "cd .tmpsrc/ng-admin && ./node_modules/webpack-dev-server/bin/webpack-dev-server.js --colors --devtool cheap-module-inline-source-map --content-base examples/blog --port 8000 --host=$(WWW_IP)"
@mRoca
mRoca / _readme_api_mocks.md
Last active December 29, 2015 15:10
API mocks

See https://github.com/mRoca/MrocaRequestLogBundle

The theory :

  • A developer runs behat tests on the api project
  • Behat tests generate api mock files (@Then save the response as mock file)
  • Api mock files are saved in a specific path (%behat_mock_responses_dir%)
  • Another git repository contains all mock files, updated from the api directory with a script
  • In the front, a bash script and a private ssh key in the repo allow to get the mocks repository before tests
  • In the front, a fake Guzzle Client is created : for each Guzzle call, if a mock file matching the request exists, its content is returned, else a 404 error us thrown
@mRoca
mRoca / RestApi_Article.php
Last active November 19, 2015 15:39
NgAdmin & Hydra
<?php
namespace AppBundle\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
use Gedmo\Mapping\Annotation as Gedmo;
use Symfony\Component\Serializer\Annotation\Groups;
@mRoca
mRoca / Node.ci.md
Last active October 28, 2015 16:56
Node.ci

Node.ci

From http://www.entreprendre-montpellier.com/actualite/le-projet-nodeci-ete-nomine-parmi-les-3-laureats-nationaux-en-emergence

LE PROJET NODE.CI A ÉTÉ NOMINÉ PARMI LES 3 LAURÉATS NATIONAUX "EN ÉMERGENCE"

Le projet Node.ci, incubé au Business and Innovation Centre (BIC) de Montpellier Agglomération depuis février 2013, a été nominé parmi les 3 lauréats nationaux "en émergence" de la quizième édition du concours de création d'entreprises innovantes du Ministère de l'Education supérieur et de la Recherche et d'OSEO, devenu bpifrance.

Node.ci est un logiciel d'intégration continue sur le Cloud pour langage de programmation Javascript. Il est porté par Eric Burin des Roziers, co-fondateur technique de TripAdvisor.com et ses deux associés Nicolas Herment, spécialiste Javascript et Benjamin Hirsch, expert financier.

@mRoca
mRoca / docker-display-share.sh
Last active September 25, 2015 08:41
Docker display share
# Share the current user with the container
docker run \
--rm \
-e DISPLAY \
-e UNAME=$USER \
-v $(mktemp -d):$HOME \
-v $(mktemp -d):/data \
-v /tmp/.X11-unix:/tmp/.X11-unix \
-v /etc/group:/etc/group:ro \
-v /etc/passwd:/etc/passwd:ro \
@mRoca
mRoca / DockerInDocker.gitlab-ci.yml
Last active September 5, 2017 05:41
gitlab-ci with docker
# TODO add the docker volume dir in /cache
before_script:
- docker info
- docker build -t thom-platine/tests tests/docker/
- docker run --name thom-platine-tests -v $(pwd):/var/www/ -v /cache:/cache -e "COMPOSER_CACHE_DIR=/cache/composer" -d thom-platine/tests tail -f /dev/null
- docker exec thom-platine-tests composer install --no-interaction
stages:
- test
@mRoca
mRoca / Dockerfile
Created July 10, 2015 12:32
docker-nginx-php
# Source : https://github.com/mbentley/docker-nginx-php5
FROM debian:jessie
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update && apt-get install --no-install-recommends -y \
php5-fpm \
php5-curl \
php5-intl \
@mRoca
mRoca / phpstorm_replace.md
Last active August 29, 2015 14:23
Doctrine mapping convert Regex corrector
app/console doctrine:mapping:convert annotation src/Xxxx/XxxxxBundle/Entity --from-database
# Regex replace
@ORM\\Index\(
\n@ORM\\\\Index\(
# String replace
@mRoca
mRoca / 1-docker-gitlab.md
Last active August 29, 2015 14:21
Gitlab docker

Gitlab image and doc : https://github.com/sameersbn/docker-gitlab

Install

Create containers

mkdir -p /srv/docker/images/gitlab/
cat docker-compose.yml > /srv/docker/images/gitlab/docker-compose.yml
# Edit the docker-compose.yml file