Skip to content

Instantly share code, notes, and snippets.

View fhuitelec's full-sized avatar

Fabien Huitelec fhuitelec

View GitHub Profile
@fhuitelec
fhuitelec / 0010.doctrine.yaml
Last active October 12, 2017 13:37
[Doctrine custom type] Wrap primitives and map them in doctrine #symfony #doctrine #custom
doctrine:
dbal:
# [...]
types:
member_id: My\Super\Namespace\Infrastructure\ORM\Type\MyCustomIdType
@fhuitelec
fhuitelec / 0010.doctrine.yaml
Created October 12, 2017 13:52
[Doctrine YAML mapping in SF config] Add mapping information in symfony framework config #symfony #doctrine #conf
doctrine:
# [...]
orm:
# [...]
mappings:
Your\Base\Namespace\Infrastructure:
is_bundle: false
type: yml
dir: '%kernel.project_dir%/config/mapping/Infrastructure'
prefix: Your\Base\Namespace\Infrastructure
@fhuitelec
fhuitelec / check_command_is_installed.zsh
Last active November 25, 2017 06:12
[Check command is installed] Cheatsheet to check if command is installed #zsh #shell #cheatsheet
#!/usr/bin/env zsh
#
# Check command is installed
#
if ! [ -x "$(command -v jq)" ]; then
echo 'Error: jq is not installed. Please install it to run this command' >&2
exit 127
fi
@fhuitelec
fhuitelec / check_file_exists.zsh
Created November 25, 2017 06:11
[Check file exists] Cheatsheet to check if file exists #zsh #shell #cheatsheet
#!/usr/bin/env zsh
#
# Check file exists
#
if [ ! -f /tmp/foo.txt ]; then
echo "File not found!" >&2
exit 1
fi
@fhuitelec
fhuitelec / loop_over_an_associative_array.zsh
Created November 25, 2017 06:13
[Loop over an associative array] Cheatsheet to loop over an associative array in ZSH #zsh #shell #cheatsheet
#!/usr/bin/env zsh
#
# Loop over an associative array
#
typeset -A knock_sequence
knock_sequence[server1]="0000 1111 2222"
knock_sequence[server2]="3333 4444 5555"
@fhuitelec
fhuitelec / check_if_array_is_empty.zsh
Last active September 15, 2023 22:38
[Check if array is empty] #zsh #shell #cheatsheet
#!/usr/bin/env zsh
#
# Check if array is empty
#
typeset -A knock_sequences
if [ ${#knock_sequences[@]} -eq 0 ]; then
echo "No knock sequence found."
@fhuitelec
fhuitelec / .env
Last active September 1, 2019 15:20
[Docker permanent localtunnel] #docker #docker-compose #localtunnel #slack
# This file must be placed where you run your `docker-compose` command
SUBDOMAIN=yourdomain # Your fully qualified domain without dash
@fhuitelec
fhuitelec / check_argument_is_provided.zsh
Created November 25, 2017 23:48
[Check argument is provided] #zsh #cheatsheet
#!/usr/bin/env zsh
#
# Check argument is provided
#
if [ -n "$1" ]; then
echo "Command must have one argument" >&2
exit 1
fi
@fhuitelec
fhuitelec / Makefile
Last active January 3, 2018 09:22
[SF Flex docker container] Run a dedicated composer container with Flex #docker #symfony #flex #php
export COMPOSER_COMPOSE_EXEC = docker-compose -f composer.docker-compose.yaml
.PHONY: composer
composer:
$(COMPOSER_COMPOSE_EXEC) run --rm composer
@fhuitelec
fhuitelec / Makefile
Last active January 3, 2018 15:06
[Bootstrap PHPUnit] #docker #php #unittests #makefile
# ######### #
# VARIABLES #
# ######### #
export PHP_VERSION = 7.1
export PROJECT_NAME = your-project-name
# ####### #
# TARGETS #
# ####### #