Mac Cursor Best Configuration

This is actually a note to myself when configuring cursor behavior on mac. Credits to @hafci.

defaults write -g ApplePressAndHoldEnabled -bool false

If you have the dock on autohide and want it to open directly with no delay:

defaults write autohide-delay -float 0

Set a blazingly fast keyboard repeat rate:

defaults write NSGlobalDomain KeyRepeat -int 0

Set a shorter Delay until key repeat:

defaults write NSGlobalDomain InitialKeyRepeat -int 12


EDIT: This works with old macs, but for new Yosemite just go to system keyboard and max the first two sliders. That works better!

Telling Symfony to Use Cached Validation From Doctrine Cache Bundle Provider

Right now Symfony on 2.7-2.8 and probably until before 3.0 will still support apc type validation caching. This will be dropped soon, at least the class support. You could still use apc past that point however you would have to wrap your ApcCache class into a DoctrineCache. The DoctrineCache is a means to adapt any Cache service implementing Doctrine\Common\Cache\Cache interface into a Symfony caching service for validation.

How this looks in code follows:

-        cache: apc
+        cache: vendor.validation_cache.doctrine 
+        vendor_filesystem_validation_cache:
+            file_system:
+                extension: cache
+                directory: %kernel.root_dir%/cache/doctrine
+    vendor.validation_cache.doctrine:
+        class: Symfony\Component\Validator\Mapping\Cache\DoctrineCache
+        arguments:
+            - @doctrine_cache.providers.vendor_filesystem_validation_cache

ArrayCache and FilesystemCache are implementations of doctrine caches, but in order to tube them in to make them available to symfony we have to use this DoctrineCache wrapper.

One extra trick to test services is to include config_prod.yml in config_dev.yml imports and comment the first lines of config_prod.yml importing config.yml since it is already imported in config_dev.yml. Then you can exercise your container:debug –show-private command without problems to test and ensure things are working correctly.


Doctrine File System Caching with Doctrine Cache Bundle

Some people had experience some difficulty configuring a filesystem cache type. Symfony by default comes with some caching because of the doctrine bundle, however if one wants to extend to more types one has to install the Doctrine Cache Bundle which brings more provides into place. Now if you want to still instruct doctrine to cache metadata, the results and the query caching with these service providers then this is the way:

            type: service
            id: doctrine_cache.providers.vendor_filesystem_metadata_cache
            type: service
            id: doctrine_cache.providers.vendor_filesystem_result_cache
            type: service
            id: doctrine_cache.providers.vendor_filesystem_query_cache

                extension: cache
                directory: %kernel.root_dir%/cache/doctrine
                extension: cache
                directory: %kernel.root_dir%/cache/doctrine
                extension: cache
                directory: %kernel.root_dir%/cache/doctrine

I hope this resolves it for you when you need it.

Docker Symfony Development Box with Data Containers

Data containers are containers where you define a path or folder to be mounted onto other containers. The data here can be read only or writeable. This means that for when you need a swap or temp storage for your projects you can use these containers since any other containers that are perhaps mounted on your host will not be writeable.

So we start by defining the cache and logs container as follows:

// cache_container
FROM busybox
RUN mkdir -p /var/cache/repay/dev
VOLUME /var/cache/repay
ENTRYPOINT chmod -R 777 /var/cache/repay; /usr/bin/tail -f /dev/null


// logs_container
FROM busybox
RUN mkdir -p /var/log/repay/
VOLUME /var/log/repay
ENTRYPOINT chmod -R 777 /var/log/repay; /usr/bin/tail -f /dev/null

Here is how you piece everything together. You build those containers, notice that they have entry points so that after running that command gets invoked setting the right permissions for those folders when they get ran.

After the symfony box gets build you can run the whole thing and attach/mount the data containers to your main host shared container where the code is:

!#/usr/bin/env bash
# troubleshoot
# docker exec -i -t repay bash
# kill all previous containers
docker rm -f $(docker ps -a -q)
docker build --rm -t "cache_container:v1" docker/cache_container
docker build --rm -t "logs_container:v1" docker/logs_container
docker run -d --name repay_cache_container cache_container:v1
docker run -d --name repay_logs_container logs_container:v1
# build symfony project box
docker build -rm -t repay .
# run symfony container
docker run \
    -v $PWD:/srv \
    -e DB_NAME=repay \
    -e INIT=bin/reload \
    --volumes-from repay_cache_container:rw \
    --volumes-from repay_logs_container:rw \
    --name repay_development_webserver \
    -itP repay
This can work thanks to adding in the kernel a couple of methods:
<pre lang="php">
     * {@inheritdoc}
    public function getCacheDir()
        return '/var/cache/repay/'.$this->environment;
     * {@inheritdoc}
    public function getLogDir()
        return '/var/log/repay';

I grabbed the top Dockerfile from an adaptation of ubermuda repo for symfony docker:

FROM debian:jessie
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update -y
RUN apt-get install -y nginx php5-fpm php5-mysqlnd php5-cli mysql-server supervisor
RUN sed -e 's/;daemonize = yes/daemonize = no/' -i /etc/php5/fpm/php-fpm.conf
RUN sed -e 's/;listen\.owner/listen.owner/' -i /etc/php5/fpm/pool.d/www.conf
RUN sed -e 's/;listen\.group/' -i /etc/php5/fpm/pool.d/www.conf
RUN echo "\ndaemon off;" >> /etc/nginx/nginx.conf
ADD vhost.conf /etc/nginx/sites-available/default
ADD supervisor.conf /etc/supervisor/conf.d/supervisor.conf
RUN chmod 777 /
VOLUME ["/srv"]
CMD ["/usr/bin/supervisord"]

Now you can enjoy!

My SSH KeyChain And Phansible

I built a box with phansible and was getting this error:

~ vagrant provision                                                                                 Luiss-MacBook-Pro-3 [7:39:07]
==> default: Running provisioner: ansible...
PLAY [all] ********************************************************************
GATHERING FACTS ***************************************************************
fatal: [] => SSH encountered an unknown error during the connection. We recommend you re-run the command using -vvvv, which will enable SSH debugging output to help diagnose the issue
TASK: [init | Update apt] *****************************************************
FATAL: no hosts matched or all hosts have already failed -- aborting
PLAY RECAP ********************************************************************
           to retry, use: --limit @/Users/cordoval/playbook.retry             : ok=0    changed=0    unreachable=1    failed=0
Ansible failed to complete successfully. Any error output should be
visible above. Please fix these errors and try again.

The reason was that my host was not connecting to the vagrant box because I had several things configured in my ~/.ssh/config. So what I did was:

# added entry to ~/.ssh/config
  User vagrant
  IdentitiesOnly yes
  IdentityFile ~/.ssh/vagrant
# added in /etc/hosts  project.local

And you can check with ssh-add -L.

Try to test with ssh -v

Then you will be able to successfully run the rest of your playbooks:

~ vagrant provision                                                                                 Luiss-MacBook-Pro-3 [7:40:45]
==> default: Running provisioner: ansible...
PLAY [all] ********************************************************************
GATHERING FACTS ***************************************************************
ok: []
TASK: [init | Update apt] *****************************************************
ok: []
TASK: [init | Install System Packages] ****************************************
changed: [] => (item=curl,wget,python-software-properties)
TASK: [init | Add ppa Repository] *********************************************
changed: []