Saturday, 16 November 2013

Debug php with Netbeans and Xampp

Xampp is one of the best free tool for develop website in localhost.
With Xampp I can use php with Apache module, database with MySQL, transfer file with FileZilla, web java ee with Tomcat. And it is very easy to install, only download from here and install, open and click start modules.

Netbeans is still one of the best free IDE to develop many language (java, c++, php ... )

But if you only install netbeans and run Xampp to code php, you will only run to view result, you will not debug: run, pause, step lines and view changed variables...


Today, I will present how to debug php with Netbeans and Xampp because Xampp was integrated xdebug and easy to config when compare with others way.

I use Netbeans 7.4 and Xampp 3.1.0.

XAMPP
Config php.ini in XDebug area.

[XDebug]
zend_extension = "E:\xampp\php\ext\php_xdebug.dll"
xdebug.remote_enable=1
xdebug.remote_handler="dbgp"
xdebug.remote_mode=req
xdebug.remote_port=9000

xdebug.profiler_append = 0
xdebug.profiler_enable = 1
xdebug.profiler_enable_trigger = 0
xdebug.profiler_output_dir = "E:\xampp\tmp"
xdebug.profiler_output_name = "cachegrind.out.%t-%s"
xdebug.remote_host = "127.0.0.1"
xdebug.trace_output_dir = "E:\xampp\tmp"

tientuts blogger


Netbeans

Go to menu: Tools -> Options and config like this image


And restart Netbeans, Xampp to active debug

Sunday, 10 November 2013

Install psycopg2 with Postgresql

psycopg2 is a driver in python to connect python application with postgresql.

Install library in python, normal is easy with pip, easy_install but with psycopg2, I met errors in all linux and window.

With window, I can use this option:
http://tientuts.blogspot.com/2013/10/fix-some-errors-when-install-library.html

but with linux, when I install, this is a very common error:

Error: pg_config executable not found.

Please add the directory containing pg_config to the PATH

or specify the full executable path with the option:



    python setup.py build_ext --pg-config /path/to/pg_config build ...



or with the pg_config option in 'setup.cfg'.

----------------------------------------
Command python setup.py egg_info failed with error code 1 in /tmp/pip-build/psycopg2


After search google and try, this is my solution (in Centos):
Install postgresql in here: https://wiki.postgresql.org/wiki/Detailed_installation_guides
In present, the newest version of postgresql is 9.3 and we need setup PATH value for postgresql

PATH=$PATH:/usr/pgsql-9.3/bin/
pip install psycopg2


Saturday, 2 November 2013

Multitask in the Linux Terminal

The oldest operating system I have ever studied is MS-DOS. This is a single tasking operating system, in the easiest way, you can see DOS like a single command line (cmd) window. In a long time, I use DOS single tasking and in the habit, I use cmd only in a single window. And when I use Linux with terminal (more power than cmd in window), the first time, I still use one terminal window, single tasking. But because of job requirements and the convenience of multitask, I changed, have use terminal with multi-task function (in many window/tab or in single window) or can be called: Multiple screen/area.


Multiple window and mutiple tab
With linux GUI (graphic user interface), these are the easiest ways.

Multiple window and multiple tab in terminal


With many terminals, you can easy change folder, run many terminal progresses like install a software and download a file and edit a text simultaneously.


Virtual consoles

Multiple window and mutiple tab are easy but What you do if you control a Ubuntu server without GUI ?

Linux has a function for this, this is virtual consoles, you can do with 6 terminals by use:
Ctrl+Alt+F1
for the first console, Ctrl+Alt+F2 -> F6 for other,  Ctrl+Alt+F7 for return graph (if GUI is installed).


Multitask with screen command

Virtual consoles is good function but if you telnet/ssh from pc to a server with putty, cmd or other, you can't use Ctrl+Alt+F<1-6>. You can do with many window by retype connect commands and password, so slow, and you can use screen command to multitask terminals.

Install (in ubuntu/debian):

sudo apt-get install screen

Some basic command to use

Create a screen:
screen -S name
Exit/detache screen:
ctrl+A, D
Go to an  existed screen
screen -r name
Terminal a screen:
ctrl+A, K


Other way

use a software can auto connect and auto fill password like Multi-Tabbed PuTTY, secure crt ..

Multi-Tabbed PuTTY tientus blogger