Make paging output from your python script

pydoc is a python library to make your console output paginates for easier reading. to use it follow the simple example below:

import pydoc

text = "...paginate me..."
pager = pydoc.ttypager(text)
print pager

you will see the output is gonna be truncated at the beginning when you start to see like when you open up a man page, then you have to scroll down with keyboard to read the rest of the text line by line. pretty cool!


How to find out what application that using specific port

Just a case if you want to know some application or service who is running under specific port :

$ netstat -tulpn | grep :80

Sometimes you need to run with sudo to see all services :

$ sudo netstat -tulpn | grep :80

Output :

tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      1393/nginx.conf

It turns out that 1393 is the pid of service


WordPress still cannot Establishing a Database Connection – Error

Do you ever experiencing this problem like this, after your install wordpress, setup anything, webserver, database, everything is completed. But wordpress still cannot establishing your database connection eventhough you already make sure that your database is up and running (I’m using MySQL) and your port is already open. Trust me, I’ve done anything properly, I spent hours just to figure out what the root cause was and after some googling and stackoverflowing, I found this problem was due to SE in linux.

$ sudo setsebool -P httpd_can_network_connect_db=1