Sunday, April 30, 2017

Changing Ubuntu full Screen Resolution in a Hyper-V VM

Changing Ubuntu full Screen Resolution in a Hyper-V VM

# vi /etc/default/grub

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash video=hyperv_fb:1920×1080"

# update-grub
# sync; reboot


Friday, April 14, 2017

Save the selected lines to a file

To save the selected lines to a file, select a region using visual mode and then enter:

:w /tmp/filename

To insert/paste text from a file:

:r /tmp/filename

Set up Xdebug

Set up Xdebug

SELinux does not allow httpd to connect to other network resources by default. Turn it on:

# setsebool -P httpd_can_network_connect 1
# getsebool -a | grep httpd_can
# chcon -v -t httpd_sys_content_t /usr/lib64/php/modules/


Edit ~/.vimrc:

# vim ~/.vimrc

let g:vdebug_options = {}
let g:vdebug_options["port"] = 9009

Edit xdebug configuration:

# vim /etc/php.d/15-xdebug.ini

; Enable xdebug extension module



Sample script:

# vim test.php


function here() {
    echo name('Jun');

function name($name) {
    $name .= '1';
    return 'Hello ' . $name . ' ' . date('Y-m-d H:i:s');

Once in debugging mode, the following default mappings are available:

<F5>: start/run (to next breakpoint/end of script)
<F2>: step over
<F3>: step into
<F4>: step out
<F6>: stop debugging (kills script)
<F7>: detach script from debugger
<F9>: run to cursor
<F10>: toggle line breakpoint
<F11>: show context variables (e.g. after "eval")
<F12>: evaluate variable under cursor
:Breakpoint <type> <args>: set a breakpoint of any type (see :help VdebugBreakpoints)
:VdebugEval <code>: evaluate some code and display the result
<Leader>e: evaluate the expression under visual highlight and display the result

To stop debugging, press <F6>. Press it again to close the debugger interface.

If you can't get a connection, then chances are you need to spend a bit of time setting up your environment. Type :help Vdebug for more information.



Note: Append XDEBUG_SESSION_START=1 to the end of the URL.

Tuesday, April 11, 2017

Compile the latest Vim 8.0 on CentOS 7

Compile the latest Vim 8.0 on CentOS 7

Remove the existing vim if you have already installed it:

# yum list installed | grep -i vim

vim-common.x86_64                    2:7.4.160-1.el7                @base
vim-enhanced.x86_64                  2:7.4.160-1.el7                @base
vim-filesystem.x86_64                2:7.4.160-1.el7                @base
vim-minimal.x86_64                   2:7.4.160-1.el7                @anaconda

# yum remove vim-enhanced vim-common vim-filesystem

Note: You do not need to remove vim-minimal because sudo depends on it.

For Red Hat/CentOS users:

# yum install gcc make ncurses ncurses-devel
# yum git
# yum install ruby ruby-devel lua lua-devel luajit \
luajit-devel ctags python python-devel \
python3 python3-devel tcl-devel \
perl perl-devel perl-ExtUtils-ParseXS \
perl-ExtUtils-XSpp perl-ExtUtils-CBuilder \


# yum clean all
# yum grouplist
# yum groupinfo "Development Tools"
# yum groupinstall "Development tools"
# yum install ncurses ncurses-devel

For debian/Ubuntu users:

# apt-get remove vim vim-runtime vim-tiny vim-common

# apt-get install libncurses5-dev libgnome2-dev libgnomeui-dev \
libgtk2.0-dev libatk1.0-dev libbonoboui2-dev \
libcairo2-dev libx11-dev libxpm-dev libxt-dev python-dev \
python3-dev ruby-dev git

# apt-get install libncurses5-dev python-dev libperl-dev ruby-dev liblua5.2-dev

// Fix liblua paths
# ln -s /usr/include/lua5.2 /usr/include/lua
# ln -s /usr/lib/x86_64-linux-gnu/ /usr/local/lib/

If you want to install the optional packages With yum groupinstall command:

# vim /etc/yum.conf

group_package_types=default, mandatory, optional

Note: the default setting is default, mandatory.

Install ctags and cscope:

# yum install ctags cscope

Build vim:

# cd /usr/local/src

Download vim source (it is better to get it from GitHub because you can get all the latest patches from there):

# git clone
# cd vim
# wget
# tar -xjf vim-7.4.tar.bz2
# cd vim74

Show the configuration options:

# ./configure --help


# ./configure --prefix=/usr --with-features=huge --enable-multibyte --enable-rubyinterp --enable-pythoninterp --enable-perlinterp --enable-luainterp --enable-cscope


# make
# make VIMRUNTIMEDIR=/usr/share/vim/vim74

# make install

re-hash the environment:

# hash -r

Check vim version:

# vim --version | less

VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Jul 24 2016 14:27:26)
Included patches: 1-2102
+lua +multi_byte +perl +python +ruby

Check vim patches:

# vim

:echo has("patch-7.4-2102")



Sunday, April 9, 2017



; reload the autohotkey script.

; input date and time
  FormatTime, mydatetime,, M/d/yyyy HH:mm:ss
  SendInput, %mydatetime%

; input date
  FormatTime, mydate,, M/d/yyyy
  SendInput, %mydate%

; input date
  FormatTime, mydate,, yyyy-MM-dd
  SendInput, %mydate%

Wednesday, April 5, 2017

PHPUnit did not output the result in color

PHPUnit did not output the result in color when colors=true in phpunit.xml. It's because it was missing the posix extension, which is provided by the php-process package.

# yum install php71u-process

Tuesday, April 4, 2017

ReflectionException: Class PHPUnit_Framework_Error does not exist

ReflectionException: Class PHPUnit_Framework_Error does not exist

     * @expectedException PHPUnit_Framework_Error
    public function testFailingInclude()
        include 'not_existing_file.php';

Solution 1:

 * @expectedException \PHPUnit\Framework\Error\Warning
public function testFailingInclude()
    include 'not_existing_file.php';

Solution 2:

public function testFailingInclude()

    include 'not_existing_file.php';