6 Cent OS commands you wont regret to learn

uname -p

your processor architecture, you can determine it by entering the command “uname -p” in a terminal, You should see  something like this:

i386, x86_64

cat /etc/issue

To find out your CentOS version just run, you should see something like this:
CentOS release 5.6 (Final)
Kernel \r on an \m

tac myfile.txt
To print a file in reverse order, Just a reverse of cat command.

wall hello everyone
Allows root or other users allowed to issue commands as root to send a message to everyones terminal.

head myfile.txt
To output the first part of files to the terminal, just a reverse of tail command.

source ~/.bash_profile
Reloads bash_profile / profile without starting a new shell session.

Register Doctrine2 type mapping with Symfony2

Well, few of us may have encountered such error while using Doctrine like “Unknown database type enum requested, Doctrine\DBAL\Platforms\MySqlPlatform may not support it.” or in my case I was trying to use “enum” type with doctrine.

So, here is the app/config.yml hack at mapping_types:

# Doctrine Configuration
        driver:   %database_driver%
        host:     %database_host%
        port:     %database_port%
        dbname:   %database_name%
        user:     %database_user%
        password: %database_password%
        charset:  UTF8

          enum: string
          set: string
          varbinary: string
          tinyblob: text
        auto_generate_proxy_classes: %kernel.debug%
        auto_mapping: true

My Talk | Developing WordPress Plugins : For Begineers

Developing WordPress Plugins : For Begineers 

Download Created Slider WP Plugin here.

Stay tuned at http://www.facebook.com/groups/pxperts/

Smaller – Batch minify HTML, PHP, CSS and JavaScript on the Mac

Honestly, I was looking into JavaScript, HTML & CSS minifiers for my production usage, definitely my preferences were not to visit online-minifier’s website every time I need some minification, something has faster usability, something sells soft obfuscation (‘Packer’ is slow!), something does the work in a batch, merges all in a one (save HTTP requests!), something replaces the original (I don’t want renaming the file with “.min” etc.).

You know, some unplanned tweaking in the CSS/JS occurs at the last moment to/after deploy and non-automated minification of your static files really sucks that time. Better we may use some kind of automatic or semi-automatic automation for those repetitive tasks to buy some time.

Something about the other minifiers bothered me that, those were not ready for production usages like elimination of conditional HTML statements (IE hacks!), non-batch, some were only for JS or CSS etc.

Later I found Smaller, I drag and drop my entire template/layout directory and have my contents minified replacing the original, found handy in my case and a recommended app for Mac.

BTW, I found some backward compatibility issue with it and was not being able to use their latest version (1.3.5) in my Snow Leopard 10.6.8. I call for a support, the lead dev Chen Luo promptly responded “Smaller 1.3.5 was built with Xcode 4.4 but Apple removed OS X 10.6 SDK since then”.  So, 1.3.4 is working for me and haven’t missed much from 1.3.5.

Disclosure: I have written this review in exchange of a license of “Smaller”.

loading jQuery local copy if CDN unavailable

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js"></script>
<script>window.jQuery || document.write('<script src="js/vendor/jquery-1.8.0.min.js"><\/script>')</script>

Setting your PHP development environment in Ubuntu

Instead of installing each item separately we will go with installing LAMP server in a package in Ubuntu that is fairly simple along with a single terminal command:

sudo apt-get install lamp-server^

The apt-get command is a powerful command-line tool used to work with Ubuntu’s Advanced Packaging Tool (APT) performing such functions as installation of new software packages, upgrade of existing software packages, updating of the package list index, and even upgrading the entire Ubuntu system.

sudo used to invoke the current user with the power of super user and a caret ‘^’ symbol placed after package name to indicate performing as tasks together.

The LAMP package will start installing immediately with above command including latest PHP5, Apache 2, MySQL and PHP5-MySQL. By default apache2 and MySQL installed as service and your document root will be at /var/www/

An index.html file shall be there.

Both Apache and MySQL should be running. However, you may start apache by using service start command as

sudo service apache2 start

and stop apache by using:

sudo service apache2 stop

Checking the LAMP installation:

Point your browser to http://localhost/ you will see the default apache2 landing page which means your webserver apache2 is running. Still you can check those service statuses as below:

sudo service apache2 status

you will be shown

Apache is running. Process #

Again to check MySQL status, simple run the command

sudo service mysql status

you will be shown

mysql start/running. Process #

to check the PHP installation simple create a file named test.php, in /var/www/ with the below line:

<?php phpinfo(); ?>

Now point your browser with http://localhost/test.php and you will see the installed PHP and components configuration details.

Installing PhpMyAdmin:

To maintain MySQL database functionality using web based interface we may use phpMyAdmin.

sudo apt-get install phpmyadmin

phpMyAdmin will be installed with the above command and during installation you will receive a blue window asking which server you want to use i.e. apache2, lighttpd ;  choose apache2 and click ok to continue with the installation. After installation point your browser with http://localhost/phpmyadmin/ and you will be viewing phpMyAdmin landing page.

If you receive 404 error at http://localhost/phpmyadmin/ then you need to setup phpMyAdmin under apache manually by modifying /etc/apache2/apache2.conf using gedit

sudo gedit  /etc/apache2/apache2.conf

gedit will open the file in graphical mode and add the below line at bottom inside apache2.conf

Include /etc/phpmyadmin/apache.conf

Now restart apache server to make the changes effective.

sudo service apache2 restart

Now refresh your browser and you will have phpMyAdmin login screen.