Friday, June 29, 2018

Set Up PHP Coding Standards Fixer for Sublime Text 3

Set Up PHP Coding Standards Fixer for Sublime Text 3 on OS X

   Originally published at mariorodriguez.co on Apr 07, 2016

You can save yourself quite some time by running a simple command to automatically format your PHP/Laravel code to follow the PSR-1 and PSR-2 standards. Let me show you how you can set it all up to work with Sublime Text 3 on OS X.

Install php-cs-fixer

You must have at least PHP 5.3.6 on your system. Check with php --version.
Run the following commands to download php-cs-fixer:
cd ~/Downloads
wget http://get.sensiolabs.org/php-cs-fixer.phar -O php-cs-fixer
If you don’t have wget installed, follow these instructions to install it. Inspect this page so you can get the latest version.
or use curl:
curl http://get.sensiolabs.org/php-cs-fixer.phar -o php-cs-fixer
If you prefer a different download method such as composer or homebrew, check out these instructions.
Now that you’ve downloaded php-cs-fixer, make it executable:
sudo chmod a+x php-cs-fixer
Move it to a global location:
sudo mv php-cs-fixer /usr/local/bin/php-cs-fixer
Check that it works by running:
php-cs-fixer
If everything is fine, you should see the version and usage information.

Configure a Build Command in Sublime Text 3

  • Open Sublime Text
  • Got to Tools > Build System > New Build System…
  • Enter the following command and save:
{
    "shell_cmd": "php-cs-fixer fix $file --level=psr2"
}
That’s it. When you run this command, php-cs-fixer will apply psr-2 standards to the current file you have open.
Run the command by pressing Command + B.
Cheers!

Sunday, June 17, 2018

Solution” to Intel Graphics Screen Tearing/Flickering Causes Excessive Fan Use in Ubuntu 16.10/17.04/17.10

https://askubuntu.com/questions/945895/solution-to-intel-graphics-screen-tearing-flickering-causes-excessive-fan-use?noredirect=1&lq=1


sudo gedit /usr/share/X11/xorg.conf.d/20-intel-graphics.conf
Section "Device"
  Identifier  "Intel Graphics"
  Driver      "intel"
  Option      "TripleBuffer" "true"
  Option      "TearFree"     "true"
  Option      "DRI"          "false"
EndSection

Tuesday, June 12, 2018

How can I find broken symlinks


find . -type l ! -exec test -e {} \; -print

Find and delete files recursively in unix

recursively list files by extension
find ./ -type f | awk -F . '{print $NF}' | sort --unique
recursively list files by specific extension
find . -type f -iname "*.css" 

recursively delete them
find . -name "*.html" -type f -delete

Monday, June 11, 2018

Docker wordpress

mkdir wordpress
cd wordpress

touch docker-compose.yml
vi docker-compose.yml

version: '3.3'

services:
   db:
     image: mysql:5.7
     ports:
       - "3306:3306"
     volumes:
       - db_data:/var/lib/mysql
     restart: always
     environment:
       MYSQL_ROOT_PASSWORD: wordpress
       MYSQL_DATABASE: wordpress
       MYSQL_USER: wordpress
       MYSQL_PASSWORD: wordpress

   wordpress:
     depends_on:
       - db
     image: wordpress:latest
     ports:
       - "80:80"
     restart: always
     environment:
       WORDPRESS_DB_HOST: db:3306
       WORDPRESS_DB_USER: wordpress
       WORDPRESS_DB_PASSWORD: wordpress
volumes:
    db_data:



docker image prune --all
docker-compose restart
docker-compose build
docker-compose stop
docker-compose start
docker-compose up


sudo ufw enable
sudo ufw allow ssh
sudo ufw allow 80/tcp
sudo ufw allow 3306
sudo service ufw restart
sudo ufw status


systemd-timesyncd

sudo apt update && sudo apt install systemd-timesyncd && sudo systemctl enable --now systemd-timesyncd