Skip to content

Instantly share code, notes, and snippets.

View dmouse's full-sized avatar
🏠
Working from home

David Flores dmouse

🏠
Working from home
View GitHub Profile
@dmouse
dmouse / export.php
Last active August 29, 2015 14:02
Export configuration in Drupal 8
<?php
use Drupal\Core\Config\FileStorage;
// Empty destination dir and then write all .yml files there.
$source_storage = Drupal::service('config.storage');
$destination_storage = new FileStorage('/tmp/config');
// Export configuration
foreach ($source_storage->listAll() as $name) {
$destination_storage->write($name, $source_storage->read($name));
@dmouse
dmouse / EntityResource.php
Last active August 29, 2015 14:07
Drupal 8 Current User in Entity Resource Plugin #rest
<?php
// ...
use Drupal\Core\Session\AccountProxyInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Psr\Log\LoggerInterface;
class EntityResource extends ResourceBase {
@dmouse
dmouse / SubRequestController.php
Last active January 13, 2025 13:04
Drupal 8: how to create a sub-request
<?php
/**
* @file
* Contains Drupal\dmouse\Controller\SubRequestController.
* Generated by drupal/console.
*/
namespace Drupal\dmouse\Controller;
@dmouse
dmouse / xdebug.ini
Created February 2, 2015 02:52
Yes another, yes another xdebug configuration. Configuration for phpstorm to use xdebug on remote server
; Enable xdebug extension module
zend_extension=/usr/lib64/php/modules/xdebug.so
xdebug.collect_params=3
xdebug.show_local_vars=5
xdebug.dump.GET=*
xdebug.dump.POST=*
; see http://xdebug.org/docs/all_settings
xdebug.collect_params=1
@dmouse
dmouse / config.fish
Last active August 29, 2015 14:15
My config to fish shell
function _git_branch_name
echo (git symbolic-ref HEAD ^/dev/null | sed -e 's|^refs/heads/||')
end
function fish_prompt
set_color green --bold
printf '%s [at] ' (whoami)
set_color blue
printf '%s ' (hostname)
@dmouse
dmouse / Dockerfile
Last active February 9, 2016 00:57
Drupal 8 docker-compose
FROM php:5.5-apache
RUN apt-get update && apt-get install -y \
libfreetype6-dev \
libjpeg62-turbo-dev \
libmcrypt-dev \
libpng12-dev \
libbz2-dev \
curl \
git \
@dmouse
dmouse / Dockerfile
Last active June 2, 2022 20:52
Run Firefox or Google Chrome into a Docker container | based on http://fabiorehm.com/blog/2014/09/11/running-gui-apps-with-docker/
FROM ubuntu:14.04
# Replace 1000 with your user / group id
RUN export uid=1000 gid=1000 && \
mkdir -p /home/developer && \
echo "developer:x:${uid}:${gid}:Developer,,,:/home/developer:/bin/bash" >> /etc/passwd && \
echo "developer:x:${uid}:" >> /etc/group && \
echo "developer ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/developer && \
chmod 0440 /etc/sudoers.d/developer && \
chown ${uid}:${gid} -R /home/developer
@dmouse
dmouse / cursor.php
Last active November 20, 2015 18:19
Move cursos in PHP Command Line from Symfony Console check https://github.com/dmouse/select-helper
<?php
$sttyMode = shell_exec('stty -g');
shell_exec('stty -icanon -echo');
$stdout = fopen('php://stdout', 'w');
fwrite($stdout, " 1.- option 1" . PHP_EOL );
fwrite($stdout, " 2.- option 2" . PHP_EOL );
fwrite($stdout, " 3.- option 3" . PHP_EOL );
@dmouse
dmouse / docker-ip.fish
Created July 8, 2016 17:51
docker-ip show the IP address and container name
function docker-ip
docker inspect --format '{{ .Name }} {{ .NetworkSettings.IPAddress }}' $argv;
end