basic sql query

Today we learned how to connect to sql using work bench and command line mysql client. We created a simple table, and inserted a row.

Fixed yoga 910 screen flicker in Ubuntu 17.10

To fix it, create or edit the file at /usr/share/X11/xorg.conf.d/20-intel.conf as root with the following:

Section "Device"
    Identifier "Intel Graphics"
    Driver "intel"
    Option "AccelMethod" "sna"
    Option "TearFree" "true"
    Option "DRI" "3"
EndSection

And add this:
GRUB_CMDLINE_LINUX_DEFAULT=”i915.enable_rc6=0″
to: /etc/default/grub
cmd: sudo update-grub
restart computer.

Link

Ubuntu install PHP mail function

It is not installed by default so you have to install it and then a little configuration is required.

sudo apt install sendmail

The run the following command and choose Y for all the options.

sudo sendmailconfig

Now edit the host file:

sudo nano /etc/hosts

And add or edit as:

127.0.0.1    localhost localhost.localdomain your_machine_name

To get your_machine_name run:

hostname

Raspberry PI enable ssh without a monitor

I spent a dozens of minutes today to learn, how to enable ssh to Raspberry Pi without a monitor. SSH is disable by default after October 2016. Here is a one minute solution.

Attach the sd card to your computer and add an empty file SSH on the root of the sd card partition.

Ubuntu 16.04 – PhpStorm – configure xdebug with PHP 7.0

Today I spent a couple of hours to figure out that ONLY the following configuration works. It is not covered in any video/tutorial.

This is the settings that MUST be added to all the files:

[xDebug] zend_extension=/usr/lib/php/20160303/xdebug.so
xdebug.default_enable=1
xdebug.idekey=PHPSTORM
xdebug.remote_port=9000
xdebug.remote_enable=1
xdebug.remote_handler=dbgp
xdebug.remote_autostart = on
xdebug.remote_start = on
xdebug.profiler_enable=1
xdebug.profiler_output_dir=/dev/null
xdebug.remote_host=localhost

 

 

The files are :

/etc/php/7.0/apache2/php.ini
/etc/php/7.0/phpdbg/php.ini
/etc/php/7.0/cli/php.ini

 

MySql change part of the field or column

If you have a table with column that contains eg file names with extension and want to replace the extension of all those file names.

Eg we have a table named menu with column icon. The icon column contains image file names with extension .png eg dress.png , shoes.png and we want to replace only .png by .svg leaving the filename (without extension) intact. we can use the following command in SQL:

UPDATE menus SET icon = replace(icon, RIGHT(icon, 3), ‘svg’)
WHERE id > 0 AND icon <> ”;